summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'connectivity/source/drivers')
-rw-r--r--connectivity/source/drivers/adabas/BCatalog.cxx168
-rw-r--r--connectivity/source/drivers/adabas/BColumns.cxx184
-rw-r--r--connectivity/source/drivers/adabas/BConnection.cxx274
-rw-r--r--connectivity/source/drivers/adabas/BDatabaseMetaData.cxx161
-rw-r--r--connectivity/source/drivers/adabas/BDriver.cxx1819
-rw-r--r--connectivity/source/drivers/adabas/BFunctions.cxx275
-rw-r--r--connectivity/source/drivers/adabas/BGroup.cxx94
-rw-r--r--connectivity/source/drivers/adabas/BGroups.cxx93
-rw-r--r--connectivity/source/drivers/adabas/BIndex.cxx106
-rw-r--r--connectivity/source/drivers/adabas/BIndexColumns.cxx124
-rw-r--r--connectivity/source/drivers/adabas/BIndexes.cxx192
-rw-r--r--connectivity/source/drivers/adabas/BKeys.cxx181
-rw-r--r--connectivity/source/drivers/adabas/BPreparedStatement.cxx76
-rw-r--r--connectivity/source/drivers/adabas/BResultSet.cxx223
-rw-r--r--connectivity/source/drivers/adabas/BResultSetMetaData.cxx87
-rw-r--r--connectivity/source/drivers/adabas/BStatement.cxx79
-rw-r--r--connectivity/source/drivers/adabas/BTable.cxx376
-rw-r--r--connectivity/source/drivers/adabas/BTables.cxx522
-rw-r--r--connectivity/source/drivers/adabas/BUser.cxx332
-rw-r--r--connectivity/source/drivers/adabas/BUsers.cxx128
-rw-r--r--connectivity/source/drivers/adabas/BViews.cxx194
-rw-r--r--connectivity/source/drivers/adabas/Bservices.cxx176
-rw-r--r--connectivity/source/drivers/adabas/adabas.mxp.map148
-rwxr-xr-xconnectivity/source/drivers/adabas/adabas.xcu130
-rw-r--r--connectivity/source/drivers/adabas/adabas.xml27
-rw-r--r--connectivity/source/drivers/adabas/exports.dxp3
-rw-r--r--connectivity/source/drivers/adabas/makefile.mk106
-rw-r--r--connectivity/source/drivers/ado/ACallableStatement.cxx235
-rw-r--r--connectivity/source/drivers/ado/ACatalog.cxx127
-rw-r--r--connectivity/source/drivers/ado/AColumn.cxx300
-rw-r--r--connectivity/source/drivers/ado/AColumns.cxx142
-rw-r--r--connectivity/source/drivers/ado/AConnection.cxx625
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaData.cxx1093
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx608
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx1218
-rw-r--r--connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx233
-rw-r--r--connectivity/source/drivers/ado/ADriver.cxx271
-rw-r--r--connectivity/source/drivers/ado/AGroup.cxx192
-rw-r--r--connectivity/source/drivers/ado/AGroups.cxx88
-rw-r--r--connectivity/source/drivers/ado/AIndex.cxx157
-rw-r--r--connectivity/source/drivers/ado/AIndexes.cxx90
-rw-r--r--connectivity/source/drivers/ado/AKey.cxx167
-rw-r--r--connectivity/source/drivers/ado/AKeyColumn.cxx71
-rw-r--r--connectivity/source/drivers/ado/AKeyColumns.cxx97
-rw-r--r--connectivity/source/drivers/ado/AKeys.cxx115
-rw-r--r--connectivity/source/drivers/ado/APreparedStatement.cxx564
-rw-r--r--connectivity/source/drivers/ado/AResultSet.cxx1169
-rw-r--r--connectivity/source/drivers/ado/AResultSetMetaData.cxx262
-rw-r--r--connectivity/source/drivers/ado/AStatement.cxx841
-rw-r--r--connectivity/source/drivers/ado/ATable.cxx257
-rw-r--r--connectivity/source/drivers/ado/ATables.cxx115
-rw-r--r--connectivity/source/drivers/ado/AUser.cxx227
-rw-r--r--connectivity/source/drivers/ado/AUsers.cxx87
-rw-r--r--connectivity/source/drivers/ado/AView.cxx123
-rw-r--r--connectivity/source/drivers/ado/AViews.cxx104
-rw-r--r--connectivity/source/drivers/ado/Aolevariant.cxx791
-rw-r--r--connectivity/source/drivers/ado/Aservices.cxx175
-rw-r--r--connectivity/source/drivers/ado/Awrapado.cxx2201
-rwxr-xr-xconnectivity/source/drivers/ado/ado.xcu259
-rw-r--r--connectivity/source/drivers/ado/ado.xml29
-rw-r--r--connectivity/source/drivers/ado/ado_post_sys_include.h32
-rw-r--r--connectivity/source/drivers/ado/ado_pre_sys_include.h37
-rw-r--r--connectivity/source/drivers/ado/adoimp.cxx336
-rw-r--r--connectivity/source/drivers/ado/exports.dxp3
-rw-r--r--connectivity/source/drivers/ado/makefile.mk114
-rw-r--r--connectivity/source/drivers/calc/CCatalog.cxx80
-rw-r--r--connectivity/source/drivers/calc/CColumns.cxx55
-rw-r--r--connectivity/source/drivers/calc/CConnection.cxx295
-rw-r--r--connectivity/source/drivers/calc/CDatabaseMetaData.cxx490
-rw-r--r--connectivity/source/drivers/calc/CDriver.cxx105
-rw-r--r--connectivity/source/drivers/calc/CPreparedStatement.cxx43
-rw-r--r--connectivity/source/drivers/calc/CResultSet.cxx191
-rw-r--r--connectivity/source/drivers/calc/CStatement.cxx43
-rw-r--r--connectivity/source/drivers/calc/CTable.cxx871
-rw-r--r--connectivity/source/drivers/calc/CTables.cxx62
-rw-r--r--connectivity/source/drivers/calc/CalcDriver.xml32
-rw-r--r--connectivity/source/drivers/calc/Cservices.cxx175
-rwxr-xr-xconnectivity/source/drivers/calc/calc.xcu63
-rw-r--r--connectivity/source/drivers/calc/exports.dxp3
-rw-r--r--connectivity/source/drivers/calc/makefile.mk96
-rw-r--r--connectivity/source/drivers/dbase/DCatalog.cxx70
-rw-r--r--connectivity/source/drivers/dbase/DCode.cxx131
-rw-r--r--connectivity/source/drivers/dbase/DColumns.cxx91
-rw-r--r--connectivity/source/drivers/dbase/DConnection.cxx135
-rw-r--r--connectivity/source/drivers/dbase/DDatabaseMetaData.cxx416
-rw-r--r--connectivity/source/drivers/dbase/DDriver.cxx127
-rw-r--r--connectivity/source/drivers/dbase/DIndex.cxx679
-rw-r--r--connectivity/source/drivers/dbase/DIndexColumns.cxx94
-rw-r--r--connectivity/source/drivers/dbase/DIndexIter.cxx315
-rw-r--r--connectivity/source/drivers/dbase/DIndexes.cxx137
-rw-r--r--connectivity/source/drivers/dbase/DNoException.cxx650
-rw-r--r--connectivity/source/drivers/dbase/DPreparedStatement.cxx42
-rw-r--r--connectivity/source/drivers/dbase/DResultSet.cxx249
-rw-r--r--connectivity/source/drivers/dbase/DStatement.cxx44
-rw-r--r--connectivity/source/drivers/dbase/DTable.cxx2855
-rw-r--r--connectivity/source/drivers/dbase/DTables.cxx144
-rw-r--r--connectivity/source/drivers/dbase/Dservices.cxx175
-rw-r--r--connectivity/source/drivers/dbase/dbase.mxp.map173
-rwxr-xr-xconnectivity/source/drivers/dbase/dbase.xcu100
-rw-r--r--connectivity/source/drivers/dbase/dbase.xml33
-rw-r--r--connectivity/source/drivers/dbase/dindexnode.cxx1056
-rw-r--r--connectivity/source/drivers/dbase/exports.dxp3
-rw-r--r--connectivity/source/drivers/dbase/makefile.mk129
-rw-r--r--connectivity/source/drivers/evoab/LCatalog.cxx72
-rw-r--r--connectivity/source/drivers/evoab/LCatalog.hxx49
-rw-r--r--connectivity/source/drivers/evoab/LColumnAlias.cxx232
-rw-r--r--connectivity/source/drivers/evoab/LColumnAlias.hxx113
-rw-r--r--connectivity/source/drivers/evoab/LColumns.cxx57
-rw-r--r--connectivity/source/drivers/evoab/LColumns.hxx52
-rw-r--r--connectivity/source/drivers/evoab/LConfigAccess.cxx161
-rw-r--r--connectivity/source/drivers/evoab/LConfigAccess.hxx46
-rw-r--r--connectivity/source/drivers/evoab/LConnection.cxx267
-rw-r--r--connectivity/source/drivers/evoab/LConnection.hxx78
-rw-r--r--connectivity/source/drivers/evoab/LDatabaseMetaData.cxx391
-rw-r--r--connectivity/source/drivers/evoab/LDatabaseMetaData.hxx56
-rw-r--r--connectivity/source/drivers/evoab/LDebug.cxx42
-rw-r--r--connectivity/source/drivers/evoab/LDebug.hxx42
-rw-r--r--connectivity/source/drivers/evoab/LDriver.cxx505
-rw-r--r--connectivity/source/drivers/evoab/LDriver.hxx115
-rw-r--r--connectivity/source/drivers/evoab/LFolderList.cxx563
-rw-r--r--connectivity/source/drivers/evoab/LFolderList.hxx92
-rw-r--r--connectivity/source/drivers/evoab/LNoException.cxx324
-rw-r--r--connectivity/source/drivers/evoab/LPreparedStatement.cxx43
-rw-r--r--connectivity/source/drivers/evoab/LPreparedStatement.hxx50
-rw-r--r--connectivity/source/drivers/evoab/LResultSet.cxx190
-rw-r--r--connectivity/source/drivers/evoab/LResultSet.hxx81
-rw-r--r--connectivity/source/drivers/evoab/LServices.cxx175
-rw-r--r--connectivity/source/drivers/evoab/LStatement.cxx43
-rw-r--r--connectivity/source/drivers/evoab/LStatement.hxx49
-rw-r--r--connectivity/source/drivers/evoab/LTable.cxx870
-rw-r--r--connectivity/source/drivers/evoab/LTable.hxx100
-rw-r--r--connectivity/source/drivers/evoab/LTables.cxx62
-rw-r--r--connectivity/source/drivers/evoab/LTables.hxx52
-rwxr-xr-xconnectivity/source/drivers/evoab/evoab.xcu61
-rw-r--r--connectivity/source/drivers/evoab/evoab.xml33
-rw-r--r--connectivity/source/drivers/evoab/exports.dxp3
-rw-r--r--connectivity/source/drivers/evoab/makefile.mk104
-rw-r--r--connectivity/source/drivers/evoab2/EApi.cxx135
-rw-r--r--connectivity/source/drivers/evoab2/EApi.h143
-rw-r--r--connectivity/source/drivers/evoab2/NCatalog.cxx100
-rw-r--r--connectivity/source/drivers/evoab2/NCatalog.hxx56
-rw-r--r--connectivity/source/drivers/evoab2/NColumns.cxx90
-rw-r--r--connectivity/source/drivers/evoab2/NColumns.hxx57
-rw-r--r--connectivity/source/drivers/evoab2/NConnection.cxx292
-rw-r--r--connectivity/source/drivers/evoab2/NConnection.hxx123
-rw-r--r--connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx1192
-rw-r--r--connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx236
-rw-r--r--connectivity/source/drivers/evoab2/NDebug.cxx40
-rw-r--r--connectivity/source/drivers/evoab2/NDebug.hxx42
-rw-r--r--connectivity/source/drivers/evoab2/NDriver.cxx190
-rw-r--r--connectivity/source/drivers/evoab2/NDriver.hxx98
-rw-r--r--connectivity/source/drivers/evoab2/NPreparedStatement.cxx335
-rw-r--r--connectivity/source/drivers/evoab2/NPreparedStatement.hxx138
-rw-r--r--connectivity/source/drivers/evoab2/NResultSet.cxx1020
-rw-r--r--connectivity/source/drivers/evoab2/NResultSet.hxx183
-rw-r--r--connectivity/source/drivers/evoab2/NResultSetMetaData.cxx194
-rw-r--r--connectivity/source/drivers/evoab2/NResultSetMetaData.hxx88
-rw-r--r--connectivity/source/drivers/evoab2/NServices.cxx175
-rw-r--r--connectivity/source/drivers/evoab2/NStatement.cxx682
-rw-r--r--connectivity/source/drivers/evoab2/NStatement.hxx288
-rw-r--r--connectivity/source/drivers/evoab2/NTable.cxx89
-rw-r--r--connectivity/source/drivers/evoab2/NTable.hxx67
-rw-r--r--connectivity/source/drivers/evoab2/NTables.cxx105
-rw-r--r--connectivity/source/drivers/evoab2/NTables.hxx54
-rw-r--r--connectivity/source/drivers/evoab2/evoab.xml30
-rwxr-xr-xconnectivity/source/drivers/evoab2/evoab2.xcu76
-rw-r--r--connectivity/source/drivers/evoab2/makefile.mk112
-rw-r--r--connectivity/source/drivers/file/FCatalog.cxx121
-rw-r--r--connectivity/source/drivers/file/FColumns.cxx94
-rw-r--r--connectivity/source/drivers/file/FConnection.cxx461
-rw-r--r--connectivity/source/drivers/file/FDatabaseMetaData.cxx1223
-rw-r--r--connectivity/source/drivers/file/FDateFunctions.cxx289
-rw-r--r--connectivity/source/drivers/file/FDriver.cxx285
-rw-r--r--connectivity/source/drivers/file/FNoException.cxx131
-rw-r--r--connectivity/source/drivers/file/FNumericFunctions.cxx249
-rw-r--r--connectivity/source/drivers/file/FPreparedStatement.cxx634
-rw-r--r--connectivity/source/drivers/file/FResultSet.cxx1896
-rw-r--r--connectivity/source/drivers/file/FResultSetMetaData.cxx219
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx860
-rw-r--r--connectivity/source/drivers/file/FStringFunctions.cxx267
-rw-r--r--connectivity/source/drivers/file/FTable.cxx257
-rw-r--r--connectivity/source/drivers/file/FTables.cxx83
-rw-r--r--connectivity/source/drivers/file/fanalyzer.cxx322
-rw-r--r--connectivity/source/drivers/file/fcode.cxx519
-rw-r--r--connectivity/source/drivers/file/fcomp.cxx917
-rw-r--r--connectivity/source/drivers/file/file.xml32
-rw-r--r--connectivity/source/drivers/file/makefile.mk108
-rw-r--r--connectivity/source/drivers/file/quotedstring.cxx164
-rw-r--r--connectivity/source/drivers/flat/ECatalog.cxx75
-rw-r--r--connectivity/source/drivers/flat/EColumns.cxx56
-rw-r--r--connectivity/source/drivers/flat/EConnection.cxx181
-rw-r--r--connectivity/source/drivers/flat/EDatabaseMetaData.cxx267
-rw-r--r--connectivity/source/drivers/flat/EDriver.cxx145
-rw-r--r--connectivity/source/drivers/flat/EPreparedStatement.cxx46
-rw-r--r--connectivity/source/drivers/flat/EResultSet.cxx189
-rw-r--r--connectivity/source/drivers/flat/EStatement.cxx43
-rw-r--r--connectivity/source/drivers/flat/ETable.cxx844
-rw-r--r--connectivity/source/drivers/flat/ETables.cxx62
-rw-r--r--connectivity/source/drivers/flat/Eservices.cxx175
-rw-r--r--connectivity/source/drivers/flat/exports.dxp3
-rw-r--r--connectivity/source/drivers/flat/flat.mxp.map141
-rwxr-xr-xconnectivity/source/drivers/flat/flat.xcu110
-rw-r--r--connectivity/source/drivers/flat/flat.xml33
-rw-r--r--connectivity/source/drivers/flat/makefile.mk107
-rw-r--r--connectivity/source/drivers/hsqldb/HCatalog.cxx166
-rw-r--r--connectivity/source/drivers/hsqldb/HColumns.cxx89
-rw-r--r--connectivity/source/drivers/hsqldb/HConnection.cxx422
-rw-r--r--connectivity/source/drivers/hsqldb/HDriver.cxx886
-rw-r--r--connectivity/source/drivers/hsqldb/HStorage.hxx118
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageAccess.cxx555
-rw-r--r--connectivity/source/drivers/hsqldb/HStorageMap.cxx360
-rw-r--r--connectivity/source/drivers/hsqldb/HTable.cxx427
-rw-r--r--connectivity/source/drivers/hsqldb/HTables.cxx200
-rw-r--r--connectivity/source/drivers/hsqldb/HTerminateListener.cxx64
-rw-r--r--connectivity/source/drivers/hsqldb/HTerminateListener.hxx66
-rw-r--r--connectivity/source/drivers/hsqldb/HTools.cxx73
-rw-r--r--connectivity/source/drivers/hsqldb/HUser.cxx351
-rw-r--r--connectivity/source/drivers/hsqldb/HUsers.cxx120
-rw-r--r--connectivity/source/drivers/hsqldb/HView.cxx213
-rw-r--r--connectivity/source/drivers/hsqldb/HViews.cxx169
-rw-r--r--connectivity/source/drivers/hsqldb/Hservices.cxx177
-rw-r--r--connectivity/source/drivers/hsqldb/StorageFileAccess.cxx180
-rw-r--r--connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx306
-rw-r--r--connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx219
-rw-r--r--connectivity/source/drivers/hsqldb/accesslog.cxx83
-rw-r--r--connectivity/source/drivers/hsqldb/accesslog.hxx145
-rw-r--r--connectivity/source/drivers/hsqldb/exports.dxp30
-rw-r--r--connectivity/source/drivers/hsqldb/hsqldb.map35
-rwxr-xr-xconnectivity/source/drivers/hsqldb/hsqldb.xcu78
-rw-r--r--connectivity/source/drivers/hsqldb/hsqldb.xml28
-rw-r--r--connectivity/source/drivers/hsqldb/hsqlui.hrc36
-rw-r--r--connectivity/source/drivers/hsqldb/hsqlui.src53
-rw-r--r--connectivity/source/drivers/hsqldb/makefile.mk117
-rw-r--r--connectivity/source/drivers/jdbc/Array.cxx152
-rw-r--r--connectivity/source/drivers/jdbc/Blob.cxx148
-rw-r--r--connectivity/source/drivers/jdbc/Boolean.cxx68
-rw-r--r--connectivity/source/drivers/jdbc/CallableStatement.cxx359
-rw-r--r--connectivity/source/drivers/jdbc/Class.cxx73
-rw-r--r--connectivity/source/drivers/jdbc/Clob.cxx146
-rw-r--r--connectivity/source/drivers/jdbc/ConnectionLog.cxx134
-rw-r--r--connectivity/source/drivers/jdbc/ContextClassLoader.cxx131
-rw-r--r--connectivity/source/drivers/jdbc/DatabaseMetaData.cxx1462
-rw-r--r--connectivity/source/drivers/jdbc/Date.cxx53
-rw-r--r--connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx141
-rw-r--r--connectivity/source/drivers/jdbc/Exception.cxx48
-rw-r--r--connectivity/source/drivers/jdbc/InputStream.cxx110
-rw-r--r--connectivity/source/drivers/jdbc/JBigDecimal.cxx89
-rw-r--r--connectivity/source/drivers/jdbc/JConnection.cxx873
-rw-r--r--connectivity/source/drivers/jdbc/JDriver.cxx256
-rw-r--r--connectivity/source/drivers/jdbc/JStatement.cxx829
-rw-r--r--connectivity/source/drivers/jdbc/Object.cxx437
-rw-r--r--connectivity/source/drivers/jdbc/PreparedStatement.cxx666
-rw-r--r--connectivity/source/drivers/jdbc/Reader.cxx121
-rw-r--r--connectivity/source/drivers/jdbc/Ref.cxx61
-rw-r--r--connectivity/source/drivers/jdbc/ResultSet.cxx1087
-rw-r--r--connectivity/source/drivers/jdbc/ResultSetMetaData.cxx238
-rw-r--r--connectivity/source/drivers/jdbc/SQLException.cxx100
-rw-r--r--connectivity/source/drivers/jdbc/SQLWarning.cxx48
-rw-r--r--connectivity/source/drivers/jdbc/String.cxx82
-rw-r--r--connectivity/source/drivers/jdbc/Throwable.cxx69
-rw-r--r--connectivity/source/drivers/jdbc/Timestamp.cxx201
-rw-r--r--connectivity/source/drivers/jdbc/exports.dxp3
-rw-r--r--connectivity/source/drivers/jdbc/jdbc.mxp.map154
-rwxr-xr-xconnectivity/source/drivers/jdbc/jdbc.xcu214
-rw-r--r--connectivity/source/drivers/jdbc/jdbc.xml30
-rw-r--r--connectivity/source/drivers/jdbc/jservices.cxx177
-rw-r--r--connectivity/source/drivers/jdbc/makefile.mk112
-rw-r--r--connectivity/source/drivers/jdbc/tools.cxx274
-rw-r--r--connectivity/source/drivers/kab/KCatalog.cxx124
-rw-r--r--connectivity/source/drivers/kab/KCatalog.hxx64
-rw-r--r--connectivity/source/drivers/kab/KColumns.cxx98
-rw-r--r--connectivity/source/drivers/kab/KColumns.hxx54
-rw-r--r--connectivity/source/drivers/kab/KConnection.cxx328
-rw-r--r--connectivity/source/drivers/kab/KConnection.hxx139
-rw-r--r--connectivity/source/drivers/kab/KDEInit.cxx155
-rw-r--r--connectivity/source/drivers/kab/KDEInit.h44
-rw-r--r--connectivity/source/drivers/kab/KDatabaseMetaData.cxx1080
-rw-r--r--connectivity/source/drivers/kab/KDatabaseMetaData.hxx213
-rw-r--r--connectivity/source/drivers/kab/KDriver.cxx473
-rw-r--r--connectivity/source/drivers/kab/KDriver.hxx223
-rw-r--r--connectivity/source/drivers/kab/KPreparedStatement.cxx390
-rw-r--r--connectivity/source/drivers/kab/KPreparedStatement.hxx119
-rw-r--r--connectivity/source/drivers/kab/KResultSet.cxx987
-rw-r--r--connectivity/source/drivers/kab/KResultSet.hxx224
-rw-r--r--connectivity/source/drivers/kab/KResultSetMetaData.cxx187
-rw-r--r--connectivity/source/drivers/kab/KResultSetMetaData.hxx92
-rw-r--r--connectivity/source/drivers/kab/KServices.cxx177
-rw-r--r--connectivity/source/drivers/kab/KStatement.cxx584
-rw-r--r--connectivity/source/drivers/kab/KStatement.hxx172
-rw-r--r--connectivity/source/drivers/kab/KTable.cxx96
-rw-r--r--connectivity/source/drivers/kab/KTable.hxx68
-rw-r--r--connectivity/source/drivers/kab/KTables.cxx90
-rw-r--r--connectivity/source/drivers/kab/KTables.hxx61
-rw-r--r--connectivity/source/drivers/kab/exports.dxp3
-rwxr-xr-xconnectivity/source/drivers/kab/kab.xcu46
-rw-r--r--connectivity/source/drivers/kab/kab.xml79
-rw-r--r--connectivity/source/drivers/kab/kabdrv.map9
-rw-r--r--connectivity/source/drivers/kab/kcondition.cxx229
-rw-r--r--connectivity/source/drivers/kab/kcondition.hxx162
-rw-r--r--connectivity/source/drivers/kab/kfields.cxx94
-rw-r--r--connectivity/source/drivers/kab/kfields.hxx47
-rw-r--r--connectivity/source/drivers/kab/korder.cxx88
-rw-r--r--connectivity/source/drivers/kab/korder.hxx74
-rw-r--r--connectivity/source/drivers/kab/makefile.mk137
-rwxr-xr-xconnectivity/source/drivers/macab/MacabAddressBook.cxx256
-rwxr-xr-xconnectivity/source/drivers/macab/MacabAddressBook.hxx72
-rwxr-xr-xconnectivity/source/drivers/macab/MacabCatalog.cxx124
-rwxr-xr-xconnectivity/source/drivers/macab/MacabCatalog.hxx64
-rwxr-xr-xconnectivity/source/drivers/macab/MacabColumns.cxx98
-rwxr-xr-xconnectivity/source/drivers/macab/MacabColumns.hxx54
-rwxr-xr-xconnectivity/source/drivers/macab/MacabConnection.cxx324
-rwxr-xr-xconnectivity/source/drivers/macab/MacabConnection.hxx131
-rwxr-xr-xconnectivity/source/drivers/macab/MacabDatabaseMetaData.cxx1126
-rwxr-xr-xconnectivity/source/drivers/macab/MacabDatabaseMetaData.hxx212
-rwxr-xr-xconnectivity/source/drivers/macab/MacabDriver.cxx348
-rwxr-xr-xconnectivity/source/drivers/macab/MacabDriver.hxx196
-rw-r--r--connectivity/source/drivers/macab/MacabGroup.cxx102
-rw-r--r--connectivity/source/drivers/macab/MacabGroup.hxx51
-rw-r--r--connectivity/source/drivers/macab/MacabHeader.cxx343
-rw-r--r--connectivity/source/drivers/macab/MacabHeader.hxx71
-rwxr-xr-xconnectivity/source/drivers/macab/MacabPreparedStatement.cxx407
-rwxr-xr-xconnectivity/source/drivers/macab/MacabPreparedStatement.hxx119
-rwxr-xr-xconnectivity/source/drivers/macab/MacabRecord.cxx347
-rwxr-xr-xconnectivity/source/drivers/macab/MacabRecord.hxx77
-rwxr-xr-xconnectivity/source/drivers/macab/MacabRecords.cxx1212
-rwxr-xr-xconnectivity/source/drivers/macab/MacabRecords.hxx136
-rwxr-xr-xconnectivity/source/drivers/macab/MacabResultSet.cxx1073
-rwxr-xr-xconnectivity/source/drivers/macab/MacabResultSet.hxx226
-rwxr-xr-xconnectivity/source/drivers/macab/MacabResultSetMetaData.cxx224
-rwxr-xr-xconnectivity/source/drivers/macab/MacabResultSetMetaData.hxx94
-rwxr-xr-xconnectivity/source/drivers/macab/MacabServices.cxx177
-rwxr-xr-xconnectivity/source/drivers/macab/MacabStatement.cxx611
-rwxr-xr-xconnectivity/source/drivers/macab/MacabStatement.hxx176
-rwxr-xr-xconnectivity/source/drivers/macab/MacabTable.cxx96
-rwxr-xr-xconnectivity/source/drivers/macab/MacabTable.hxx68
-rwxr-xr-xconnectivity/source/drivers/macab/MacabTables.cxx90
-rwxr-xr-xconnectivity/source/drivers/macab/MacabTables.hxx61
-rwxr-xr-xconnectivity/source/drivers/macab/exports.dxp3
-rwxr-xr-xconnectivity/source/drivers/macab/macab.xcu46
-rwxr-xr-xconnectivity/source/drivers/macab/macab.xml79
-rwxr-xr-xconnectivity/source/drivers/macab/macabcondition.cxx250
-rwxr-xr-xconnectivity/source/drivers/macab/macabcondition.hxx169
-rwxr-xr-xconnectivity/source/drivers/macab/macaborder.cxx86
-rwxr-xr-xconnectivity/source/drivers/macab/macaborder.hxx74
-rw-r--r--connectivity/source/drivers/macab/macabutilities.hxx149
-rwxr-xr-xconnectivity/source/drivers/macab/makefile.mk129
-rw-r--r--connectivity/source/drivers/mozab/MCatalog.cxx127
-rw-r--r--connectivity/source/drivers/mozab/MCatalog.hxx66
-rw-r--r--connectivity/source/drivers/mozab/MColumnAlias.cxx191
-rw-r--r--connectivity/source/drivers/mozab/MColumnAlias.hxx85
-rw-r--r--connectivity/source/drivers/mozab/MColumns.cxx100
-rw-r--r--connectivity/source/drivers/mozab/MColumns.hxx58
-rw-r--r--connectivity/source/drivers/mozab/MConfigAccess.cxx273
-rw-r--r--connectivity/source/drivers/mozab/MConfigAccess.hxx39
-rw-r--r--connectivity/source/drivers/mozab/MConnection.cxx603
-rw-r--r--connectivity/source/drivers/mozab/MConnection.hxx231
-rw-r--r--connectivity/source/drivers/mozab/MDatabaseMetaData.cxx1031
-rw-r--r--connectivity/source/drivers/mozab/MDatabaseMetaData.hxx204
-rw-r--r--connectivity/source/drivers/mozab/MDriver.cxx329
-rw-r--r--connectivity/source/drivers/mozab/MDriver.hxx110
-rw-r--r--connectivity/source/drivers/mozab/MExtConfigAccess.hxx46
-rw-r--r--connectivity/source/drivers/mozab/MPreparedStatement.cxx544
-rw-r--r--connectivity/source/drivers/mozab/MPreparedStatement.hxx169
-rw-r--r--connectivity/source/drivers/mozab/MResultSet.cxx1980
-rw-r--r--connectivity/source/drivers/mozab/MResultSet.hxx366
-rw-r--r--connectivity/source/drivers/mozab/MResultSetMetaData.cxx212
-rw-r--r--connectivity/source/drivers/mozab/MResultSetMetaData.hxx98
-rw-r--r--connectivity/source/drivers/mozab/MServices.cxx225
-rw-r--r--connectivity/source/drivers/mozab/MStatement.cxx561
-rw-r--r--connectivity/source/drivers/mozab/MStatement.hxx213
-rw-r--r--connectivity/source/drivers/mozab/MTable.cxx95
-rw-r--r--connectivity/source/drivers/mozab/MTable.hxx72
-rw-r--r--connectivity/source/drivers/mozab/MTables.cxx104
-rw-r--r--connectivity/source/drivers/mozab/MTables.hxx55
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx334
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx101
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx171
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx46
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx139
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx83
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx347
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx45
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx631
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx74
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx240
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx83
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx535
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx134
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx113
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx80
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx98
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx68
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/makefile.mk93
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h54
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h89
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h41
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h46
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h84
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/post_include_windows.h30
-rw-r--r--connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h31
-rw-r--r--connectivity/source/drivers/mozab/exports.dxp3
-rw-r--r--connectivity/source/drivers/mozab/makefile.mk186
-rw-r--r--connectivity/source/drivers/mozab/makefile_mozab.mk128
-rwxr-xr-xconnectivity/source/drivers/mozab/mozab.xcu154
-rw-r--r--connectivity/source/drivers/mozab/mozab.xml82
-rwxr-xr-xconnectivity/source/drivers/mozab/mozab2.xcu118
-rw-r--r--connectivity/source/drivers/mozab/mozabdrv.map8
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx806
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx80
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx77
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx450
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx75
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx52
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx81
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx404
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx119
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx86
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx57
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx142
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx83
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx823
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx282
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx635
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx142
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx138
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx66
-rw-r--r--connectivity/source/drivers/mozab/mozillasrc/makefile.mk77
-rw-r--r--connectivity/source/drivers/mozab/post_include_mozilla.h58
-rw-r--r--connectivity/source/drivers/mozab/pre_include_mozilla.h70
-rw-r--r--connectivity/source/drivers/mysql/YCatalog.cxx174
-rw-r--r--connectivity/source/drivers/mysql/YColumns.cxx89
-rw-r--r--connectivity/source/drivers/mysql/YDriver.cxx481
-rw-r--r--connectivity/source/drivers/mysql/YTable.cxx385
-rw-r--r--connectivity/source/drivers/mysql/YTables.cxx243
-rw-r--r--connectivity/source/drivers/mysql/YUser.cxx350
-rw-r--r--connectivity/source/drivers/mysql/YUsers.cxx118
-rw-r--r--connectivity/source/drivers/mysql/YViews.cxx162
-rw-r--r--connectivity/source/drivers/mysql/Yservices.cxx176
-rw-r--r--connectivity/source/drivers/mysql/exports.dxp3
-rw-r--r--connectivity/source/drivers/mysql/makefile.mk84
-rwxr-xr-xconnectivity/source/drivers/mysql/mysql.xcu258
-rw-r--r--connectivity/source/drivers/mysql/mysql.xml29
-rw-r--r--connectivity/source/drivers/odbc/OFunctions.cxx285
-rw-r--r--connectivity/source/drivers/odbc/ORealDriver.cxx369
-rw-r--r--connectivity/source/drivers/odbc/ORealDriver.hxx50
-rw-r--r--connectivity/source/drivers/odbc/makefile.mk78
-rwxr-xr-xconnectivity/source/drivers/odbc/odbc.xcu175
-rw-r--r--connectivity/source/drivers/odbc/odbc.xml28
-rw-r--r--connectivity/source/drivers/odbc/oservices.cxx177
-rw-r--r--connectivity/source/drivers/odbcbase/OConnection.cxx670
-rw-r--r--connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx1743
-rw-r--r--connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx1323
-rw-r--r--connectivity/source/drivers/odbcbase/ODriver.cxx229
-rw-r--r--connectivity/source/drivers/odbcbase/OPreparedStatement.cxx973
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSet.cxx1755
-rw-r--r--connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx312
-rw-r--r--connectivity/source/drivers/odbcbase/OStatement.cxx1154
-rw-r--r--connectivity/source/drivers/odbcbase/OTools.cxx946
-rw-r--r--connectivity/source/drivers/odbcbase/makefile.mk90
459 files changed, 115737 insertions, 0 deletions
diff --git a/connectivity/source/drivers/adabas/BCatalog.cxx b/connectivity/source/drivers/adabas/BCatalog.cxx
new file mode 100644
index 000000000000..ec9454a1fef7
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BCatalog.cxx
@@ -0,0 +1,168 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include "adabas/BGroups.hxx"
+#include "adabas/BUsers.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BViews.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -----------------------------------------------------------------------------
+OAdabasCatalog::OAdabasCatalog(SQLHANDLE _aConnectionHdl, OAdabasConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_aConnectionHdl(_aConnectionHdl)
+{
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasCatalog::buildName(const Reference< XRow >& _xRow)
+{
+ ::rtl::OUString sName;
+ sName = _xRow->getString(2);
+ if ( sName.getLength() )
+ sName += OAdabasCatalog::getDot();
+ sName += _xRow->getString(3);
+
+
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OAdabasCatalog::fillVector(const ::rtl::OUString& _sQuery,TStringVector& _rVector)
+{
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ OSL_ENSURE(xStmt.is(),"OAdabasCatalog::fillVector: Could not create a statement!");
+ Reference< XResultSet > xResult = xStmt->executeQuery(_sQuery);
+
+ fillNames(xResult,_rVector);
+ ::comphelper::disposeComponent(xStmt);
+
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshTables()
+{
+ TStringVector aVector;
+ {
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ aTypes);
+ fillNames(xResult,aVector);
+ }
+
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshViews()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sView(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,DOMAIN.VIEWDEFS.OWNER, DOMAIN.VIEWDEFS.VIEWNAME FROM DOMAIN.VIEWDEFS"));
+ fillVector(s_sView,aVector);
+
+ if(m_pViews)
+ m_pViews->reFill(aVector);
+ else
+ m_pViews = new OViews(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshGroups()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sGroup(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,NULL,GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' '"));
+ fillVector(s_sGroup,aVector);
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+void OAdabasCatalog::refreshUsers()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sUsers(RTL_CONSTASCII_USTRINGPARAM("SELECT DISTINCT NULL,NULL,USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL'"));
+ fillVector(s_sUsers,aVector);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString& OAdabasCatalog::getDot()
+{
+ static const ::rtl::OUString sDot(RTL_CONSTASCII_USTRINGPARAM("."));
+ return sDot;
+}
+// -----------------------------------------------------------------------------
+void OAdabasCatalog::correctColumnProperties(sal_Int32 /*_nPrec*/, sal_Int32& _rnType,::rtl::OUString& _rsTypeName)
+{
+ switch(_rnType)
+ {
+ case DataType::DECIMAL:
+ {
+ static const ::rtl::OUString sDecimal(RTL_CONSTASCII_USTRINGPARAM("DECIMAL"));
+ if(_rnType == DataType::DECIMAL && _rsTypeName == sDecimal)
+ _rnType = DataType::NUMERIC;
+ }
+ break;
+ case DataType::FLOAT:
+ // if(_nPrec >= 16)
+ {
+ static const ::rtl::OUString sDouble(RTL_CONSTASCII_USTRINGPARAM("DOUBLE PRECISION"));
+ _rsTypeName = sDouble;
+ _rnType = DataType::DOUBLE;
+ }
+// else if(_nPrec > 15)
+// {
+// static const ::rtl::OUString sReal = ::rtl::OUString::createFromAscii("REAL");
+// _rsTypeName = sReal;
+// _rnType = DataType::REAL;
+// }
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BColumns.cxx b/connectivity/source/drivers/adabas/BColumns.cxx
new file mode 100644
index 000000000000..bb0363792c12
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BColumns.cxx
@@ -0,0 +1,184 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "adabas/BTable.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include <comphelper/property.hxx>
+
+using namespace ::comphelper;
+
+
+using namespace connectivity::adabas;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+ OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
+ sal_Bool bAutoIncrement = sal_False;
+ if ( !_rName.equalsAscii("DEFAULT") && !m_pTable->getSchema().equalsAscii("DOMAIN") && !m_pTable->getTableName().equalsAscii("COLUMNS") )
+ {
+ Reference< XStatement > xStmt = m_pTable->getMetaData()->getConnection()->createStatement( );
+ ::rtl::OUString sQuery(RTL_CONSTASCII_USTRINGPARAM("SELECT \"DEFAULT\" FROM DOMAIN.COLUMNS WHERE OWNER = '"));
+ sQuery += m_pTable->getSchema();
+ sQuery += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' AND TABLENAME = '"));
+ sQuery += m_pTable->getTableName() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("' AND COLUMNNAME = '"));
+ sQuery += _rName + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("'"));
+ try
+ {
+ Reference< XResultSet > xResult2 = xStmt->executeQuery(sQuery);
+ Reference< XRow > xRow2(xResult2,UNO_QUERY);
+ if ( xRow2.is() && xResult2->next() )
+ bAutoIncrement = xRow2->getString(1) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DEFAULT STAMP"));
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ xRet = new OColumn(_rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ bAutoIncrement,sal_False,sal_False,sal_True);
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OColumns::createDescriptor()
+{
+ return new OColumn(sal_True);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::osl::MutexGuard aGuard(m_rMutex);
+ if ( m_pTable->isNew() )
+ return cloneDescriptor( descriptor );
+
+ ::rtl::OUString aSql(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
+ ::rtl::OUString sQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ m_pTable->beginTransAction();
+ try
+ {
+ aSql += ::dbtools::quoteName(sQuote,m_pTable->getSchema()) + sDot + ::dbtools::quoteName(sQuote,m_pTable->getTableName());
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ADD ("));
+ aSql += ::dbtools::quoteName(sQuote,_rForName);
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ aSql += OTables::getColumnSqlType(descriptor);
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" )"));
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement();
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ m_pTable->alterNotNullValue(getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))),_rForName);
+ }
+ catch(const Exception&)
+ {
+ m_pTable->rollbackTransAction();
+ throw;
+ }
+ m_pTable->endTransAction();
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OColumns::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ OSL_ENSURE(m_pTable,"OColumns::dropByName: Table is null!");
+ if(!m_pTable->isNew())
+ {
+ ::rtl::OUString aSql(RTL_CONSTASCII_USTRINGPARAM("ALTER TABLE "));
+ ::rtl::OUString sQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql += ::dbtools::quoteName(sQuote,m_pTable->getSchema()) + sDot + ::dbtools::quoteName(sQuote,m_pTable->getTableName());
+ aSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP "));
+ aSql += ::dbtools::quoteName(sQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BConnection.cxx b/connectivity/source/drivers/adabas/BConnection.cxx
new file mode 100644
index 000000000000..ec6d56f45d83
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BConnection.cxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "adabas/BConnection.hxx"
+#include "adabas/BDriver.hxx"
+#include "adabas/BCatalog.hxx"
+#include "odbc/OFunctions.hxx"
+#include "odbc/OTools.hxx"
+#ifndef _CONNECTIVITY_ODBC_ODATABASEMETADATA_HXX_
+#include "adabas/BDatabaseMetaData.hxx"
+#endif
+#include "adabas/BStatement.hxx"
+#include "adabas/BPreparedStatement.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbcharset.hxx>
+#include "connectivity/sqliterator.hxx"
+#include <connectivity/sqlparse.hxx>
+
+#include <string.h>
+
+using namespace connectivity::adabas;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+//------------------------------------------------------------------------------
+namespace starlang = ::com::sun::star::lang;
+// --------------------------------------------------------------------------------
+OAdabasConnection::OAdabasConnection(const SQLHANDLE _pDriverHandle, connectivity::odbc::ODBCDriver* _pDriver)
+ : OConnection_BASE2(_pDriverHandle,_pDriver)
+{
+ m_bUseOldDateFormat = sal_True;
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OAdabasConnection::Construct( const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ m_aConnectionHandle = SQL_NULL_HANDLE;
+ setURL(url);
+ setConnectionInfo(info);
+
+ // Connection allozieren
+ N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle);
+ if(m_aConnectionHandle == SQL_NULL_HANDLE)
+ throw SQLException();
+
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ ::rtl::OUString sHostName;
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
+ sal_Int32 nTimeout = 20;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if ( !pBegin->Name.compareToAscii("Timeout") )
+ pBegin->Value >>= nTimeout;
+ else if(!pBegin->Name.compareToAscii("user"))
+ pBegin->Value >>= aUID;
+ else if(!pBegin->Name.compareToAscii("password"))
+ pBegin->Value >>= aPWD;
+ else if(!pBegin->Name.compareToAscii("HostName"))
+ pBegin->Value >>= sHostName;
+ else if(0 == pBegin->Name.compareToAscii("CharSet"))
+ {
+ ::rtl::OUString sIanaName;
+ OSL_VERIFY( pBegin->Value >>= sIanaName );
+
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end())
+ m_nTextEncoding = (*aLookup).getEncoding();
+ else
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if(m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW)
+ m_nTextEncoding = osl_getThreadTextEncoding();
+ }
+ }
+ m_sUser = aUID;
+
+ if ( sHostName.getLength() )
+ aDSN = sHostName + ':' + aDSN;
+ SQLRETURN nSQLRETURN = openConnectionWithAuth(aDSN,nTimeout, aUID,aPWD);
+
+ return nSQLRETURN;
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OAdabasConnection::openConnectionWithAuth(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, const ::rtl::OUString& _uid,const ::rtl::OUString& _pwd)
+{
+ if (m_aConnectionHandle == SQL_NULL_HANDLE)
+ return -1;
+
+ SQLRETURN nSQLRETURN = 0;
+ SDB_ODBC_CHAR szDSN[4096];
+ SDB_ODBC_CHAR szUID[20];
+ SDB_ODBC_CHAR szPWD[20];
+
+ memset(szDSN,'\0',4096);
+ memset(szUID,'\0',20);
+ memset(szPWD,'\0',20);
+
+ ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,getTextEncoding()));
+ ::rtl::OString aUID(::rtl::OUStringToOString(_uid,getTextEncoding()));
+ ::rtl::OString aPWD(::rtl::OUStringToOString(_pwd,getTextEncoding()));
+ memcpy(szDSN, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()));
+ memcpy(szUID, (SDB_ODBC_CHAR*) aUID.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()));
+ memcpy(szPWD, (SDB_ODBC_CHAR*) aPWD.getStr(), ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength()));
+
+
+
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_INTEGER);
+ // Verbindung aufbauen
+
+ nSQLRETURN = N3SQLConnect(m_aConnectionHandle,
+ szDSN,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()),
+ szUID,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aUID.getLength()),
+ szPWD,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)20,aPWD.getLength()));
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ return nSQLRETURN;
+
+ m_bClosed = sal_False;
+
+ // autocoomit ist immer default
+
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER);
+
+ return nSQLRETURN;
+}
+
+//------------------------------------------------------------------------------
+void OAdabasConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ Reference< XTablesSupplier > xTableSupplier(m_xCatalog);
+ ::comphelper::disposeComponent(xTableSupplier);
+
+ m_xCatalog = WeakReference< XTablesSupplier >();
+
+ OConnection_BASE2::disposing();
+}
+//------------------------------------------------------------------------------
+Reference< XTablesSupplier > OAdabasConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ xTab = new OAdabasCatalog(m_aConnectionHandle,this);
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OAdabasConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OAdabasDatabaseMetaData(m_aConnectionHandle,this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OAdabasConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+ Reference< XStatement > xReturn = new OAdabasStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OAdabasConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE2::rBHelper.bDisposed);
+
+ Reference< XPreparedStatement > xReturn = new OAdabasPreparedStatement(this,sql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OAdabasConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OConnection_BASE2::getSomething(rId);
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdabasConnection::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -----------------------------------------------------------------------------
+::connectivity::odbc::OConnection* OAdabasConnection::cloneConnection()
+{
+ return new OAdabasConnection(m_pDriverHandleCopy,m_pDriver);
+}
+// -----------------------------------------------------------------------------
+::vos::ORef<OSQLColumns> OAdabasConnection::createSelectColumns(const ::rtl::OUString& _rSql)
+{
+ ::vos::ORef<OSQLColumns> aRet;
+ OSQLParser aParser(getDriver()->getORB());
+ ::rtl::OUString sErrorMessage;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_rSql);
+ if(pNode)
+ {
+ Reference< XTablesSupplier> xCata = createCatalog();
+ OSQLParseTreeIterator aParseIter(this, xCata->getTables(),
+ aParser, pNode);
+ aParseIter.traverseAll();
+ aRet = aParseIter.getSelectColumns();
+ }
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx
new file mode 100644
index 000000000000..63bbd34bcc34
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BDatabaseMetaData.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_BDATABASEMETADATA_HXX_
+#include "adabas/BDatabaseMetaData.hxx"
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+::rtl::OUString SAL_CALL OAdabasDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:"));
+ aValue += OAdabasDatabaseMetaData_BASE::getURLImpl();
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > OAdabasDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xNewRes = pResult;
+ static ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ aRows.reserve(19);
+ Reference< XResultSet > xRes = OAdabasDatabaseMetaData_BASE::impl_getTypeInfo_throw();
+
+ if(xRes.is())
+ {
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ Reference< XRow> xRow(xRes,UNO_QUERY);
+ while(xRes->next())
+ {
+ sal_Int32 nPos = 1;
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (1));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (2));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (3));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (4));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (5));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (6));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (7));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (8));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (9));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (10));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (11));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getBoolean (12));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getString (13));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (14));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getShort (15));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (16));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator(xRow->getInt (17));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+ aRow[nPos++] = new ::connectivity::ORowSetValueDecorator((sal_Int16)xRow->getInt(18));
+ if(xRow->wasNull())
+ aRow[nPos-1]->setNull();
+
+ // we have to fix some incorrect entries
+ if(!aRow[2]->getValue().isNull())
+ {
+ switch((sal_Int32)aRow[2]->getValue())
+ {
+ case DataType::FLOAT:
+// aRow[3] = sal_Int32(15);
+// break;
+ case DataType::REAL:
+// aRow[3] = sal_Int32(16);
+// break;
+ case DataType::DOUBLE:
+ aRow[2]->setValue(DataType::DOUBLE);
+ aRow[3]->setValue(sal_Int32(18));
+ break;
+ case DataType::TIMESTAMP:
+ aRow[3]->setValue(sal_Int32(27));
+ break;
+ default:
+ break;
+ }
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ pResult->setRows(aRows);
+ return xNewRes;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BDriver.cxx b/connectivity/source/drivers/adabas/BDriver.cxx
new file mode 100644
index 000000000000..e9a0798761b9
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BDriver.cxx
@@ -0,0 +1,1819 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <unotools/tempfile.hxx>
+#include "adabas/BDriver.hxx"
+#include "adabas/BConnection.hxx"
+#include "odbc/OFunctions.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "odbc/OTools.hxx"
+#include "connectivity/dbexception.hxx"
+#include "TConnection.hxx"
+#include "diagnose_ex.h"
+#include <vos/process.hxx>
+#include <osl/process.h>
+#include <unotools/ucbhelper.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <unotools/localfilehelper.hxx>
+#include "resource/adabas_res.hrc"
+#include "resource/sharedresources.hxx"
+
+
+#include <memory>
+#include <sys/stat.h>
+
+#if defined(MAC)
+const char sNewLine = '\015';
+#elif defined(UNX)
+const char sNewLine = '\012';
+#else
+const char sNewLine[] = "\015\012"; // \015\012 and not \n
+#endif
+#define ADABAS_DB_11 "11.02.00"
+#define ADABAS_KERNEL_11 "11.02"
+#define ADABAS_DB_12 "12.01.00"
+#define ADABAS_KERNEL_12 "12.01"
+#define CURRENT_DB_VERSION "13.01.00"
+#define CURRENT_KERNEL_VERSION "13.01"
+
+#define OPROCESS_ADABAS (OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath)
+#define OPROCESS_ADABAS_DBG (OProcess::TOption_Wait | OProcess::TOption_SearchPath)
+
+
+using namespace connectivity;
+namespace connectivity
+{
+ namespace adabas
+ {
+ // extern declaration of the function pointer
+ extern T3SQLAllocHandle pODBC3SQLAllocHandle;
+ extern T3SQLConnect pODBC3SQLConnect;
+ extern T3SQLDriverConnect pODBC3SQLDriverConnect;
+ extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+ extern T3SQLDataSources pODBC3SQLDataSources;
+ extern T3SQLDrivers pODBC3SQLDrivers;
+ extern T3SQLGetInfo pODBC3SQLGetInfo;
+ extern T3SQLGetFunctions pODBC3SQLGetFunctions;
+ extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+ extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+ extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+ extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+ extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+ extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+ extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+ //extern T3SQLSetDescField pODBC3SQLSetDescField;
+ //extern T3SQLGetDescField pODBC3SQLGetDescField;
+ //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
+ //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
+ extern T3SQLPrepare pODBC3SQLPrepare;
+ extern T3SQLBindParameter pODBC3SQLBindParameter;
+ //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLSetCursorName pODBC3SQLSetCursorName;
+ extern T3SQLExecute pODBC3SQLExecute;
+ extern T3SQLExecDirect pODBC3SQLExecDirect;
+ //extern T3SQLNativeSql pODBC3SQLNativeSql;
+ extern T3SQLDescribeParam pODBC3SQLDescribeParam;
+ extern T3SQLNumParams pODBC3SQLNumParams;
+ extern T3SQLParamData pODBC3SQLParamData;
+ extern T3SQLPutData pODBC3SQLPutData;
+ extern T3SQLRowCount pODBC3SQLRowCount;
+ extern T3SQLNumResultCols pODBC3SQLNumResultCols;
+ extern T3SQLDescribeCol pODBC3SQLDescribeCol;
+ extern T3SQLColAttribute pODBC3SQLColAttribute;
+ extern T3SQLBindCol pODBC3SQLBindCol;
+ extern T3SQLFetch pODBC3SQLFetch;
+ extern T3SQLFetchScroll pODBC3SQLFetchScroll;
+ extern T3SQLGetData pODBC3SQLGetData;
+ extern T3SQLSetPos pODBC3SQLSetPos;
+ extern T3SQLBulkOperations pODBC3SQLBulkOperations;
+ extern T3SQLMoreResults pODBC3SQLMoreResults;
+ //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
+ extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+ extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+ extern T3SQLColumns pODBC3SQLColumns;
+ extern T3SQLForeignKeys pODBC3SQLForeignKeys;
+ extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+ extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+ extern T3SQLProcedures pODBC3SQLProcedures;
+ extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+ extern T3SQLStatistics pODBC3SQLStatistics;
+ extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+ extern T3SQLTables pODBC3SQLTables;
+ extern T3SQLFreeStmt pODBC3SQLFreeStmt;
+ extern T3SQLCloseCursor pODBC3SQLCloseCursor;
+ extern T3SQLCancel pODBC3SQLCancel;
+ extern T3SQLEndTran pODBC3SQLEndTran;
+ extern T3SQLDisconnect pODBC3SQLDisconnect;
+ extern T3SQLFreeHandle pODBC3SQLFreeHandle;
+ extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLNativeSql pODBC3SQLNativeSql;
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace utl;
+using namespace osl;
+using namespace vos;
+using namespace ::dbtools;
+
+ sal_Bool LoadFunctions(oslModule pODBCso);
+ sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath);
+ // --------------------------------------------------------------------------------
+void ODriver::fillInfo(const Sequence< PropertyValue >& info, TDatabaseStruct& _rDBInfo)
+{
+ const PropertyValue* pIter = info.getConstArray();
+ const PropertyValue* pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseName"))))
+ {
+ pIter->Value >>= _rDBInfo.sDBName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))))
+ {
+ pIter->Value >>= _rDBInfo.sControlUser;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))))
+ {
+ pIter->Value >>= _rDBInfo.sControlPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))))
+ pIter->Value >>= _rDBInfo.nDataIncrement;
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))))
+ pIter->Value >>= _rDBInfo.bShutDown;
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("User"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysUser;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Password"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DomainPassword"))))
+ {
+ pIter->Value >>= _rDBInfo.sDomainPassword;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CacheSize"))))
+ {
+ pIter->Value >>= _rDBInfo.sCacheSize;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RestoreDatabase"))))
+ {
+ pIter->Value >>= _rDBInfo.bRestoreDatabase;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Backup"))))
+ {
+ pIter->Value >>= _rDBInfo.sBackupFile;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSpace"))))
+ {
+ pIter->Value >>= _rDBInfo.sDataDevName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE"))))
+ {
+ pIter->Value >>= _rDBInfo.sSysDevSpace;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG"))))
+ {
+ pIter->Value >>= _rDBInfo.sTransLogName;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataDevSize"))))
+ {
+ pIter->Value >>= _rDBInfo.nDataSize;
+ }
+ else if(pIter->Name.equalsIgnoreAsciiCase(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LogDevSize"))))
+ {
+ pIter->Value >>= _rDBInfo.nLogSize;
+ }
+ }
+}
+
+
+// --------------------------------------------------------------------------------
+ODriver::ODriver(const Reference< XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory)
+{
+ osl_incrementInterlockedCount(&m_refCount);
+ fillEnvironmentVariables();
+ Reference< XComponent > xComponent(m_xORB, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< ::com::sun::star::lang::XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->addEventListener(xEvtL);
+ }
+ osl_decrementInterlockedCount(&m_refCount);
+}
+//------------------------------------------------------------------------------
+void ODriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ODriver_BASE::disposing();
+ Reference< XComponent > xComponent(m_xORB, UNO_QUERY);
+ if (xComponent.is())
+ {
+ Reference< XEventListener> xEvtL((::cppu::OWeakObject*)this,UNO_QUERY);
+ xComponent->removeEventListener(xEvtL);
+ }
+ m_xORB.clear();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.sdbcx.adabas.ODriver"));
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver"));
+ aSNS[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.Driver"));
+ return aSNS;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ const Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+//------------------------------------------------------------------
+Any SAL_CALL ODriver::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType, static_cast<XDataDefinitionSupplier*>(this));
+ if ( !aRet.hasValue() )
+ aRet = ODriver_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ODriver_BASE2::queryInterface(rType);
+}
+//------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODriver_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
+{
+ return *(new ODriver(_rxFac));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::disposing( const EventObject& Source ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if(m_xORB.is() && Reference< XMultiServiceFactory >(Source.Source,UNO_QUERY) == m_xORB)
+ {
+ TDatabaseMap::iterator aIter = m_aDatabaseMap.begin();
+ for(;aIter != m_aDatabaseMap.end();++aIter)
+ {
+ if(aIter->second.bShutDown)
+ {
+ ::rtl::OUString sName;
+ if(getDBName(aIter->first,sName))
+ {
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),sName,aIter->second.sControlUser,aIter->second.sControlPassword);
+ X_STOP(sName);
+ }
+ }
+ }
+ m_xORB.clear();
+ }
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ TDatabaseStruct aDBInfo;
+ aDBInfo.bShutDown = sal_False;
+ fillInfo(info,aDBInfo);
+ aDBInfo.sControlUser = aDBInfo.sControlUser.toAsciiUpperCase();
+ aDBInfo.sControlPassword = aDBInfo.sControlPassword.toAsciiUpperCase();
+ aDBInfo.sSysUser = aDBInfo.sSysUser.toAsciiUpperCase();
+ aDBInfo.sSysPassword = aDBInfo.sSysPassword.toAsciiUpperCase();
+
+
+ TDatabaseMap::iterator aFind = m_aDatabaseMap.find(url);
+ if(aFind == m_aDatabaseMap.end()) // only when not found yet
+ m_aDatabaseMap[url] = aDBInfo;
+ else
+ {
+ if(aFind->second.bShutDown != aDBInfo.bShutDown)
+ aFind->second.bShutDown &= aDBInfo.bShutDown;
+ }
+
+ ::rtl::OUString sName;
+ if(aDBInfo.sControlPassword.getLength() && aDBInfo.sControlUser.getLength() && getDBName(url,sName))
+ {
+ // check if we have to add a new data dev space
+ checkAndInsertNewDevSpace(sName,aDBInfo);
+
+ convertOldVersion(sName,aDBInfo);
+ // check if we must restart the database
+ checkAndRestart(sName,aDBInfo);
+ }
+
+
+ if(!m_pDriverHandle)
+ {
+ ::rtl::OUString aPath;
+ if(!EnvironmentHandle(aPath))
+ throw SQLException(aPath,*this,::rtl::OUString(),1000,Any());
+ }
+ OAdabasConnection* pCon = new OAdabasConnection(m_pDriverHandle,this);
+ Reference< XConnection > xCon = pCon;
+ SQLRETURN nSQLRETURN = pCon->Construct(url,info);
+
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ {
+ odbc::OTools::ThrowException(pCon,nSQLRETURN,pCon->getConnection(),SQL_HANDLE_DBC,*this);
+ }
+
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::getDBName(const ::rtl::OUString& _rName,::rtl::OUString& sDBName) const
+{
+ sDBName = ::rtl::OUString();
+ ::rtl::OUString sName = _rName.copy(12);
+ sal_Int32 nPos = sName.indexOf(':');
+ if(nPos != -1 && nPos < 1)
+ sDBName = sName.copy(1);
+ return (nPos != -1 && nPos < 1);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return (!url.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:adabas:")),12));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShutdownDatabase"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Shut down service when closing."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlUser"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control user name."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ControlPassword"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Control password."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DataCacheSizeIncrement"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Data increment (MB)."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+// XCreateCatalog
+void SAL_CALL ODriver::createCatalog( const Sequence< PropertyValue >& info ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ try
+ {
+ TDatabaseStruct aDBInfo;
+ fillInfo(info,aDBInfo);
+ static char envName[] = "DBSERVICE=0";
+ putenv( envName );
+
+ m_sDbRunDir = m_sDbWorkURL + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/wrk/")) + aDBInfo.sDBName;
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(m_sDbRunDir,sTemp);
+ m_sDbRunDir = sTemp;
+
+ createNeededDirs(aDBInfo.sDBName);
+ if(CreateFiles(aDBInfo))
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",aDBInfo.sDBName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if(CreateFiles(aDBInfo))
+
+ createDb(aDBInfo);
+ }
+ catch( SQLException&)
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ throw SQLException();
+ }
+
+}
+// -----------------------------------------------------------------------------
+// XDropCatalog
+void SAL_CALL ODriver::dropCatalog( const ::rtl::OUString& /*catalogName*/, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ ::dbtools::throwFeatureNotImplementedException( "!XDropCatalog::dropCatalog", *this );
+}
+//-----------------------------------------------------------------------------
+// ODBC Environment (gemeinsam fuer alle Connections):
+SQLHANDLE ODriver::EnvironmentHandle(::rtl::OUString &_rPath)
+{
+ // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden?
+ if (!m_pDriverHandle)
+ {
+ SQLHANDLE h = SQL_NULL_HANDLE;
+ // Environment allozieren
+
+ // ODBC-DLL jetzt laden:
+ if (! LoadLibrary_ADABAS(_rPath))
+ return SQL_NULL_HANDLE;
+
+ if (N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
+ return SQL_NULL_HANDLE;
+
+ // In globaler Struktur merken ...
+ m_pDriverHandle = h;
+ SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
+ OSL_UNUSED( nError );
+ //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
+ }
+
+ return m_pDriverHandle;
+}
+// --------------------------------------------------------------------------------
+// XDataDefinitionSupplier
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ Reference< XTablesSupplier > xTab;
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+
+ OAdabasConnection* pConnection = NULL;
+ OAdabasConnection* pSearchConnection = reinterpret_cast< OAdabasConnection* >( xTunnel->getSomething(OAdabasConnection::getUnoTunnelImplementationId()) );
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ if ( (OAdabasConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection )
+ {
+ pConnection = pSearchConnection;
+ break;
+ }
+ }
+
+
+ if ( pConnection )
+ xTab = pConnection->createCatalog();
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ {
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+
+ return getDataDefinitionByConnection(connect(url,info));
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::acquire() throw()
+{
+ ODriver_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODriver::release() throw()
+{
+ ODriver_BASE::release();
+}
+ODriver::~ODriver()
+{
+}
+// -----------------------------------------------------------------------------
+oslGenericFunction ODriver::getOdbcFunction(sal_Int32 _nIndex) const
+{
+ oslGenericFunction pFunction = NULL;
+ switch(_nIndex)
+ {
+ case ODBC3SQLAllocHandle:
+ pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;;
+ break;
+ case ODBC3SQLConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLConnect;
+ break;
+ case ODBC3SQLDriverConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLDriverConnect;
+ break;
+ case ODBC3SQLBrowseConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect;
+ break;
+ case ODBC3SQLDataSources:
+ pFunction = (oslGenericFunction)pODBC3SQLDataSources;
+ break;
+ case ODBC3SQLDrivers:
+ pFunction = (oslGenericFunction)pODBC3SQLDrivers;
+ break;
+ case ODBC3SQLGetInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetInfo;
+ break;
+ case ODBC3SQLGetFunctions:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetFunctions;
+ break;
+ case ODBC3SQLGetTypeInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo;
+ break;
+ case ODBC3SQLSetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr;
+ break;
+ case ODBC3SQLGetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr;
+ break;
+ case ODBC3SQLSetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr;
+ break;
+ case ODBC3SQLGetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr;
+ break;
+ case ODBC3SQLSetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr;
+ break;
+ case ODBC3SQLGetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr;
+ break;
+ case ODBC3SQLPrepare:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrepare;
+ break;
+ case ODBC3SQLBindParameter:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindParameter;
+ break;
+ case ODBC3SQLSetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetCursorName;
+ break;
+ case ODBC3SQLExecute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecute;
+ break;
+ case ODBC3SQLExecDirect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecDirect;
+ break;
+ case ODBC3SQLDescribeParam:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeParam;
+ break;
+ case ODBC3SQLNumParams:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumParams;
+ break;
+ case ODBC3SQLParamData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLParamData;
+ break;
+ case ODBC3SQLPutData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPutData;
+ break;
+ case ODBC3SQLRowCount:
+
+ pFunction = (oslGenericFunction)pODBC3SQLRowCount;
+ break;
+ case ODBC3SQLNumResultCols:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumResultCols;
+ break;
+ case ODBC3SQLDescribeCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeCol;
+ break;
+ case ODBC3SQLColAttribute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColAttribute;
+ break;
+ case ODBC3SQLBindCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindCol;
+ break;
+ case ODBC3SQLFetch:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetch;
+ break;
+ case ODBC3SQLFetchScroll:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetchScroll;
+ break;
+ case ODBC3SQLGetData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetData;
+ break;
+ case ODBC3SQLSetPos:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetPos;
+ break;
+ case ODBC3SQLBulkOperations:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBulkOperations;
+ break;
+ case ODBC3SQLMoreResults:
+
+ pFunction = (oslGenericFunction)pODBC3SQLMoreResults;
+ break;
+ case ODBC3SQLGetDiagRec:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec;
+ break;
+ case ODBC3SQLColumnPrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges;
+ break;
+ case ODBC3SQLColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumns;
+ break;
+ case ODBC3SQLForeignKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLForeignKeys;
+ break;
+ case ODBC3SQLPrimaryKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys;
+ break;
+ case ODBC3SQLProcedureColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns;
+ break;
+ case ODBC3SQLProcedures:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedures;
+ break;
+ case ODBC3SQLSpecialColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns;
+ break;
+ case ODBC3SQLStatistics:
+
+ pFunction = (oslGenericFunction)pODBC3SQLStatistics;
+ break;
+ case ODBC3SQLTablePrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges;
+ break;
+ case ODBC3SQLTables:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTables;
+ break;
+ case ODBC3SQLFreeStmt:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeStmt;
+ break;
+ case ODBC3SQLCloseCursor:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCloseCursor;
+ break;
+ case ODBC3SQLCancel:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCancel;
+ break;
+ case ODBC3SQLEndTran:
+
+ pFunction = (oslGenericFunction)pODBC3SQLEndTran;
+ break;
+ case ODBC3SQLDisconnect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDisconnect;
+ break;
+ case ODBC3SQLFreeHandle:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeHandle;
+ break;
+ case ODBC3SQLGetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetCursorName;
+ break;
+ case ODBC3SQLNativeSql:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNativeSql;
+ break;
+ default:
+ OSL_ENSURE(0,"Function unknown!");
+ }
+ return pFunction;
+}
+// -----------------------------------------------------------------------------
+void ODriver::createNeededDirs(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sDbWork,sDBConfig,sTemp;
+
+ if(m_sDbWork.getLength())
+ {
+ sDbWork = m_sDbWorkURL;
+ if(!UCBContentHelper::IsFolder(m_sDbWorkURL))
+ UCBContentHelper::MakeFolder(m_sDbWorkURL);
+
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wrk"));
+ if(!UCBContentHelper::IsFolder(sDbWork))
+ UCBContentHelper::MakeFolder(sDbWork);
+
+ sDbWork += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ sTemp = sDbWork;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDbWork;
+ sTemp += sDBName;
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+ }
+
+ if(m_sDbConfig.getLength())
+ {
+ sDBConfig = m_sDbConfigURL;
+ if(!UCBContentHelper::IsFolder(sDBConfig))
+ UCBContentHelper::MakeFolder(sDBConfig);
+
+ sDBConfig += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("config"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+ sTemp += sDBName;
+ if(UCBContentHelper::Exists(sTemp))
+ UCBContentHelper::Kill(sTemp);
+
+#if !(defined(WIN) || defined(WNT))
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("diag"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ipc"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+
+ sTemp = sDBConfig;
+ sTemp += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("spool"));
+ if(!UCBContentHelper::IsFolder(sTemp))
+ UCBContentHelper::MakeFolder(sTemp);
+#endif
+ }
+}
+// -----------------------------------------------------------------------------
+void ODriver::clearDatabase(const ::rtl::OUString& sDBName)
+{ // stop the database
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+ ::rtl::OUString sStop = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stop"));
+ OArgumentList aArgs(2,&sDBName,&sStop);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_cons.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_clear"));
+#endif
+
+ OProcess aApp( sCommand,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption) OPROCESS_ADABAS, aArgs );
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::clearDatabase: calling the executable failed!" );
+}
+// -----------------------------------------------------------------------------
+void ODriver::createDb( const TDatabaseStruct& _aInfo)
+{
+
+ clearDatabase(_aInfo.sDBName);
+
+ X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,String::CreateFromAscii("BINIT"));
+
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sSysDevSpace,sTemp);
+
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYSDEVSPACE")),sTemp);
+
+ sTemp.Erase();
+ LocalFileHelper::ConvertURLToPhysicalName(_aInfo.sTransLogName,sTemp);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TRANSACTION_LOG")),sTemp);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXUSERTASKS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("3")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("7")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATADEVSPACES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("5")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXDATAPAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("25599")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXBACKUPDEVS")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MAXSERVERDB")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),_aInfo.sCacheSize);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CONV_CACHE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("23")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PROC_DATA_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("40")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RUNDIRECTORY")),m_sDbRunDir);
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KERNELTRACESIZE")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("100")));
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOG_QUEUE_PAGES")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("10")));
+
+#if !(defined(WIN) || defined(WNT))
+ PutParam(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OPMSG1")),::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/dev/null")));
+#endif
+
+ X_PARAM(_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+
+ X_START(_aInfo.sDBName);
+
+ // SHOW_STATE()
+ // %m_sDbRoot%\bin\xutil -d %_aInfo.sDBName% -u %CONUSR%,%CONPWD% -b %INITCMD%
+ ::rtl::OUString aBatch2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b "));
+
+// if(!bBsp && INITCMD.Len() >= 40)
+// {
+// DirEntry aTmp(INITCMD);
+// aTmp.CopyTo(aInitFile, FSYS_ACTION_COPYFILE);
+// INITCMD = aInitFile.GetFull();
+// }
+ // generate the init file for the database
+ String sInitFile = getDatabaseInitFile(_aInfo);
+
+ LocalFileHelper::ConvertURLToPhysicalName(sInitFile,sTemp);
+ aBatch2 += sTemp;
+ XUTIL(aBatch2,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sInitFile))
+ UCBContentHelper::Kill(sInitFile);
+#endif
+
+ // install system tables
+ installSystemTables(_aInfo);
+ // now we have to make our SYSDBA user "NOT EXCLUSIVE"
+ {
+ String sExt;
+ sExt.AssignAscii(".sql");
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+ aInitFile.EnableKillingFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(aInitFile.GetURL(),STREAM_WRITE) );
+ (*pFileStream) << "ALTER USER \""
+ << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding())
+ << "\" NOT EXCLUSIVE "
+ << sNewLine;
+ pFileStream->Flush();
+ }
+ { // just to get sure that the tempfile still lives
+ sTemp.Erase();
+ LocalFileHelper::ConvertURLToPhysicalName(aInitFile.GetURL(),sTemp);
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ }
+}
+
+
+//-------------------------------------------------------------------------------------------------
+int ODriver::X_PARAM(const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USR,
+ const ::rtl::OUString& _PWD,
+ const ::rtl::OUString& _CMD)
+{
+ // %XPARAM% -u %CONUSR%,%CONPWD% BINIT
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "x_param"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " -d "
+ << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_USR,_USR.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_PWD,_PWD.getLength(),gsl_getSystemTextEncoding())
+ << " "
+ << ::rtl::OString(_CMD,_CMD.getLength(),gsl_getSystemTextEncoding())
+#if (defined(WIN) || defined(WNT))
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> %DBWORK%\\create.log 2>&1"
+#endif
+#else
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> /tmp/kstart.log"
+#else
+ << " > /dev/null"
+#endif
+#endif
+ << " "
+ << sNewLine
+ << sNewLine;
+
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::X_PARAM: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODriver::CreateFiles(const TDatabaseStruct& _aInfo)
+{
+ int nRet = CreateFile(_aInfo.sSysDevSpace,_aInfo.nDataSize/50) ? 0 : -9;
+ if(!nRet)
+ nRet = CreateFile(_aInfo.sTransLogName,_aInfo.nLogSize) ? 0 : -10;
+ if(!nRet)
+ nRet = CreateFile(_aInfo.sDataDevName,_aInfo.nDataSize) ? 0 : -11;
+
+ return nRet;
+
+}
+// -----------------------------------------------------------------------------
+void ODriver::PutParam(const ::rtl::OUString& sDBName,
+ const ::rtl::OUString& rWhat,
+ const ::rtl::OUString& rHow)
+{
+ OArgumentList aArgs(3,&sDBName,&rWhat,&rHow);
+ ::rtl::OUString sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("putparam"));
+#if defined(WIN) || defined(WNT)
+ sCommand += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".exe"));
+#endif
+
+ OProcess aApp(sCommand,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS,aArgs );
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::PutParam: calling the executable failed!" );
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::CreateFile(const ::rtl::OUString &_FileName,
+ sal_Int32 _nSize)
+{
+OSL_TRACE("CreateFile %d",_nSize);
+ sal_Bool bOK = sal_True;
+ try
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(_FileName,STREAM_WRITE));
+ if( !pFileStream.get())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",_FileName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ (*pFileStream).SetFiller('\0');
+ sal_Int32 nNewSize = 0;
+ sal_Int32 nCount = _nSize /2;
+ for(sal_Int32 i=0; bOK && i < nCount; ++i)
+ {
+ nNewSize += 8192;//4096;
+ bOK = (*pFileStream).SetStreamSize(nNewSize);
+ pFileStream->Flush();
+ }
+
+ bOK = bOK && static_cast<sal_Int32>(pFileStream->Seek(STREAM_SEEK_TO_END)) == nNewSize;
+ }
+ catch(Exception&)
+ {
+ OSL_TRACE("Exception");
+ }
+ if(!bOK)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_DISK_SPACE,
+ "$filename$",_FileName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+ return bOK;
+ // dd if=/dev/zero bs=4k of=$DEV_NAME count=$2
+}
+// -----------------------------------------------------------------------------
+int ODriver::X_START(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+
+ ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d"));
+ ::rtl::OUString sArg3 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService"));
+ ::rtl::OUString sArg4 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBWindow"));
+
+ OArgumentList aArgs(4,&sArg1,&sDBName,&sArg3,&sArg4);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("strt.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_start"));
+#endif
+
+ OProcess aApp( sCommand ,m_sDbWorkURL);
+ OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs);
+
+ if(eError == OProcess::E_NotFound)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_COMMAND_NOT_FOUND,
+ "$databasename$",sDBName,
+ "$progname$",sCommand
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ OSL_ASSERT(eError == OProcess::E_None);
+
+ OProcess::TProcessInfo aInfo;
+ if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code)
+ return aInfo.Code;
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+int ODriver::X_STOP(const ::rtl::OUString& sDBName)
+{
+ ::rtl::OUString sCommand;
+#if defined(WIN) || defined(WNT)
+
+ ::rtl::OUString sArg1 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-d"));
+ ::rtl::OUString sArg2 = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-NoDBService"));
+
+ OArgumentList aArgs(3,&sArg1,&sDBName,&sArg2);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("stp.exe"));
+#else
+ OArgumentList aArgs(1,&sDBName);
+ sCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("x_stop"));
+#endif
+ OProcess aApp( sCommand ,m_sDbWorkURL);
+
+ OProcess::TProcessError eError = aApp.execute((OProcess::TProcessOption)OPROCESS_ADABAS,aArgs);
+
+
+ OSL_ASSERT(eError == OProcess::E_None);
+ if(eError != OProcess::E_None)
+ return 1;
+ OProcess::TProcessInfo aInfo;
+ if(aApp.getInfo(OProcess::TData_ExitCode,&aInfo) == OProcess::E_None && aInfo.Code)
+ return aInfo.Code;
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+void ODriver::XUTIL(const ::rtl::OUString& _rParam,
+ const ::rtl::OUString& _DBNAME,
+ const ::rtl::OUString& _USRNAME,
+ const ::rtl::OUString& _USRPWD)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".log");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("xutil"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) <<
+#if defined(WIN) || defined(WNT)
+ "xutil.exe"
+#else
+ "utility"
+#endif
+ << " -u "
+ << ::rtl::OString(_USRNAME,_USRNAME.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_USRPWD,_USRPWD.getLength(),gsl_getSystemTextEncoding())
+ << " -d "
+ << ::rtl::OString(_DBNAME,_DBNAME.getLength(),gsl_getSystemTextEncoding())
+ << " "
+ << ::rtl::OString(_rParam,_rParam.getLength(),gsl_getSystemTextEncoding())
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << " 2>&1"
+ << sNewLine;
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::XUTIL: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::LoadBatch(const ::rtl::OUString& sDBName,
+ const ::rtl::OUString& _rUSR,
+ const ::rtl::OUString& _rPWD,
+ const ::rtl::OUString& _rBatch)
+{
+ OSL_ENSURE(_rBatch.getLength(),"No batch file given!");
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".log");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("LoadBatch"),&sExt,&sWorkUrl);
+#if OSL_DEBUG_LEVEL < 2
+ aCmdFile.EnableKillingFile();
+#endif
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "xload"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " -d "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_rUSR,_rUSR.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_rPWD,_rPWD.getLength(),gsl_getSystemTextEncoding());
+
+ if ( !isKernelVersion(CURRENT_DB_VERSION) )
+ (*pFileStream) << " -S adabas -b ";
+ else
+ (*pFileStream) << " -S NATIVE -b ";
+
+ (*pFileStream) << ::rtl::OString(_rBatch,_rBatch.getLength(),gsl_getSystemTextEncoding())
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << " 2>&1"
+ << sNewLine;
+
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+#if OSL_DEBUG_LEVEL > 0
+ OProcess::TProcessError eError =
+#endif
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+ OSL_ENSURE( eError == OProcess::E_None, "ODriver::LoadBatch: calling the executable failed!" );
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::fillEnvironmentVariables()
+{
+ // read the environment vars
+ struct env_data
+ {
+ const sal_Char* pAsciiEnvName;
+ ::rtl::OUString* pValue;
+ ::rtl::OUString* pValueURL;
+ } EnvData[] = {
+ { "DBWORK", &m_sDbWork, &m_sDbWorkURL },
+ { "DBCONFIG", &m_sDbConfig, &m_sDbConfigURL },
+ { "DBROOT", &m_sDbRoot, &m_sDbRootURL }
+ };
+
+ for ( size_t i = 0; i < sizeof( EnvData ) / sizeof( EnvData[0] ); ++i )
+ {
+ ::rtl::OUString sVarName = ::rtl::OUString::createFromAscii( EnvData[i].pAsciiEnvName );
+ ::rtl::OUString sEnvValue;
+ if(osl_getEnvironment( sVarName.pData, &sEnvValue.pData ) == osl_Process_E_None )
+ {
+ *EnvData[i].pValue = sEnvValue;
+ String sURL;
+ LocalFileHelper::ConvertPhysicalNameToURL( *EnvData[i].pValue, sURL );
+ *EnvData[i].pValueURL = sURL;
+ }
+ }
+
+ m_sDelimit = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODriver::generateInitFile() const
+{
+ String sExt;
+#if !(defined(WIN) || defined(WNT))
+ sExt = String::CreateFromAscii(".sh");
+#else
+ sExt = String::CreateFromAscii(".bat");
+#endif
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+#if !(defined(WIN) || defined(WNT))
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+ chmod(ByteString(sPhysicalPath,gsl_getSystemTextEncoding()).GetBuffer(),S_IRUSR|S_IWUSR|S_IXUSR);
+#endif
+
+#if !(defined(WIN) || defined(WNT))
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_WRITE);
+ (*pFileStream) << "#!/bin/sh"
+ << sNewLine
+ << "cd \"$DBWORK\""
+ << sNewLine
+ << sNewLine;
+ pFileStream->Flush();
+#endif
+
+ return aCmdFile.GetURL();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODriver::getDatabaseInitFile( const TDatabaseStruct& _aDBInfo)
+{
+ String sExt;
+ sExt.AssignAscii(".ins");
+
+
+ String sWorkUrl(m_sDbWorkURL);
+ ::utl::TempFile aInitFile(String::CreateFromAscii("Init"),&sExt,&sWorkUrl);
+ {
+ SvStream* pFileStream = aInitFile.GetStream(STREAM_WRITE);
+ (*pFileStream) << "* @(#)init.cmd 6.1.1 1994-11-10\n";
+ (*pFileStream) << "init config\n";
+ (*pFileStream) << "* default code:\n";
+ (*pFileStream) << "ascii\n";
+ (*pFileStream) << "* date time format\n";
+ (*pFileStream) << "internal\n";
+ (*pFileStream) << "* command timeout:\n";
+ (*pFileStream) << "900\n";
+ (*pFileStream) << "* lock timeout:\n";
+ (*pFileStream) << "360\n";
+ (*pFileStream) << "* request timeout:\n";
+ (*pFileStream) << "180\n";
+ (*pFileStream) << "* log mode:\n";
+ (*pFileStream) << "demo\n";
+ (*pFileStream) << "* log segment size:\n";
+ (*pFileStream) << "0\n";
+ (*pFileStream) << "* no of archive logs:\n";
+ (*pFileStream) << "0\n";
+ (*pFileStream) << "* no of data devspaces:\n";
+ (*pFileStream) << "1\n";
+ (*pFileStream) << "* mirror devspaces:\n";
+ (*pFileStream) << "n\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "*--- device description ---\n";
+ (*pFileStream) << "* sys devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sSysDevSpace,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "\n* log devspace size:\n";
+ (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nLogSize);
+ (*pFileStream) << "\n* log devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sTransLogName,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "\n* data devspace size:\n";
+ (*pFileStream) << ::rtl::OString::valueOf(_aDBInfo.nDataSize);
+ (*pFileStream) << "\n* data devspace name:\n";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sDataDevName,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+
+ (*pFileStream) << "\n* END INIT CONFIG\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ if(_aDBInfo.bRestoreDatabase)
+ {
+ (*pFileStream) << "RESTORE DATA QUICK FROM '";
+ {
+ String sTemp;
+ LocalFileHelper::ConvertURLToPhysicalName(_aDBInfo.sBackupFile,sTemp);
+ (*pFileStream) << ::rtl::OString(sTemp.GetBuffer(),sTemp.Len(),gsl_getSystemTextEncoding());
+ }
+ (*pFileStream) << "' BLOCKSIZE 8\n";
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "RESTART\n";
+
+ }
+ else
+ {
+ (*pFileStream) << "ACTIVATE SERVERDB SYSDBA \"";
+ (*pFileStream) << ::rtl::OString(_aDBInfo.sSysUser,_aDBInfo.sSysUser.getLength(),gsl_getSystemTextEncoding());
+ (*pFileStream) << "\" PASSWORD \"";
+ (*pFileStream) << ::rtl::OString(_aDBInfo.sSysPassword,_aDBInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding());
+ (*pFileStream) << "\"\n";
+ }
+ (*pFileStream) << "if $rc <> 0 then stop\n";
+ (*pFileStream) << "exit\n";
+ }
+ return aInitFile.GetURL();
+}
+// -----------------------------------------------------------------------------
+void ODriver::X_CONS(const ::rtl::OUString& sDBName,const ::rtl::OString& _ACTION,const ::rtl::OUString& _FILENAME)
+{
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(_FILENAME,sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "x_cons"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " SHOW "
+ << _ACTION
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ pFileStream->Flush();
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+}
+// -----------------------------------------------------------------------------
+void ODriver::checkAndRestart(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("State"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ X_CONS(sDBName,"STATE",aCmdFile.GetURL());
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_SHARE_DENYALL);
+ if ( pFileStream )
+ {
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Int32 nStart = 2;
+ while(bRead && !pFileStream->IsEof())
+ {
+ String aLine;
+ bRead = pFileStream->ReadLine(sStateLine);
+ if(bRead)
+ {
+ if(sStateLine.Search("WARM") != STRING_NOTFOUND)
+ { // nothing to do
+ nStart = 0;
+ break;
+ }
+ else if(sStateLine.Search("COLD") != STRING_NOTFOUND)
+ {
+ nStart = 1;
+ break;
+ }
+ }
+ }
+ switch(nStart)
+ {
+ case 2:
+ clearDatabase(sDBName);
+ X_START(sDBName);
+ // don't break here
+ case 1:
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword);
+ case 0:
+ break;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::isVersion(const ::rtl::OUString& sDBName, const char* _pVersion)
+{
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "getparam"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " KERNELVERSION > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Bool bIsVersion = sal_False;
+ while ( pFileStream && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead )
+ {
+ bIsVersion = sStateLine.GetToken(1,' ').Equals(_pVersion) != 0;
+ break;
+ }
+ }
+ return bIsVersion;
+}
+// -----------------------------------------------------------------------------
+void ODriver::checkAndInsertNewDevSpace(const ::rtl::OUString& sDBName,
+ const TDatabaseStruct& _rDBInfo)
+{
+ // %DBROOT%\pgm\getparam %2 DATA_CACHE_PAGES > %3
+ String sWorkUrl(m_sDbWorkURL);
+ String sExt = String::CreateFromAscii(".st");
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("DevSpaces"),&sExt,&sWorkUrl);
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "getparam"
+#if defined(WIN) || defined(WNT)
+ << ".exe"
+#endif
+ << " "
+ << ::rtl::OString(sDBName,sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " DATA_CACHE_PAGES > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Int32 nDataPages = 0;
+ while(pFileStream && bRead && !pFileStream->IsEof())
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if(bRead)
+ {
+ nDataPages = sStateLine.ToInt32();
+ if(nDataPages && nDataPages < 100)
+ {
+ // the space isn't big enough anymore so we increment it
+ PutParam(sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATA_CACHE_PAGES")),::rtl::OUString::valueOf(nDataPages));
+ X_PARAM(sDBName,_rDBInfo.sControlUser,_rDBInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODriver::isKernelVersion(const char* _pVersion)
+{
+ ::utl::TempFile aCmdFile(String::CreateFromAscii("KernelVersion"));
+ aCmdFile.EnableKillingFile();
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(aCmdFile.GetURL(),sPhysicalPath);
+
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+
+ (*pFileStream) << "dbversion"
+ << " > "
+ << ::rtl::OString(sPhysicalPath.GetBuffer(),sPhysicalPath.Len(),gsl_getSystemTextEncoding())
+ << sNewLine;
+ }
+
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)OPROCESS_ADABAS);
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+ SvStream* pFileStream = aCmdFile.GetStream(STREAM_STD_READWRITE);
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ sal_Bool bIsVersion = sal_True;
+ while ( pFileStream && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead )
+ {
+ // convert a 11.02.00 to a 12.01.30 version
+ bIsVersion = sStateLine.GetToken(0).Equals(_pVersion) != 0;
+ break;
+ }
+ }
+ return bIsVersion;
+}
+// -----------------------------------------------------------------------------
+void ODriver::installSystemTables( const TDatabaseStruct& _aInfo)
+{
+#if defined(WIN) || defined(WNT)
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% -b %m_sDbRoot%\env\TERMCHAR.ind
+ ::rtl::OUString aBatch = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-b "));
+ ::rtl::OUString sTemp2 = m_sDbRootURL + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TERMCHAR.ind"));
+ String sTemp;
+ sal_Bool bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ aBatch += sTemp;
+
+ XUTIL(aBatch,_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER OFF
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\DBS.ins %_DOMAINPWD%
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DBS.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+ sTemp.AppendAscii(" ");
+ sTemp += String(_aInfo.sDomainPassword);
+
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\XDD.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("XDD.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+
+ LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u %_SYSDBA_USER%,%_SYSDBA_PWD% -S NATIVE -b %m_sDbRoot%\env\QP.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("QP.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+ LoadBatch(_aInfo.sDBName,_aInfo.sSysUser,_aInfo.sSysPassword,sTemp);
+ }
+ // xload -d %_DBNAME% -u DOMAIN,%_DOMAINPWD% -S NATIVE -b %m_sDbRoot%\env\SPROC.ins
+ {
+ sTemp2 = m_sDbRootURL
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env"))
+ + m_sDelimit
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SPROC.ins"));
+ sTemp.Erase();
+ bOk = LocalFileHelper::ConvertURLToPhysicalName(sTemp2,sTemp);
+ OSL_ENSURE(bOk,"File could be converted into file system path!");
+
+ LoadBatch(_aInfo.sDBName,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOMAIN")),_aInfo.sDomainPassword,sTemp);
+ }
+
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% DIAGNOSE TRIGGER ON
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DIAGNOSE TRIGGER ON")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SET NOLOG OFF
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET NOLOG OFF")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% SHUTDOWN QUICK
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN QUICK")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+ // xutil -d %_DBNAME% -u %_CONTROL_USER%,%_CONTROL_PWD% RESTART
+ XUTIL(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RESTART")),_aInfo.sDBName,_aInfo.sControlUser,_aInfo.sControlPassword);
+
+#else // UNX
+ String sCommandFile = generateInitFile();
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READWRITE));
+ pFileStream->Seek(STREAM_SEEK_TO_END);
+ (*pFileStream) << "x_dbinst"
+ << " -d "
+ << ::rtl::OString(_aInfo.sDBName,_aInfo.sDBName.getLength(),gsl_getSystemTextEncoding())
+ << " -u "
+ << ::rtl::OString(_aInfo.sSysUser,_aInfo.sSysUser.getLength(),gsl_getSystemTextEncoding())
+ << ","
+ << ::rtl::OString(_aInfo.sSysPassword,_aInfo.sSysPassword.getLength(),gsl_getSystemTextEncoding())
+ << " -w "
+ << ::rtl::OString(_aInfo.sDomainPassword,_aInfo.sDomainPassword.getLength(),gsl_getSystemTextEncoding())
+ << " -b ";
+
+ if ( isKernelVersion(ADABAS_KERNEL_11) )
+ (*pFileStream) << "-i all";
+ (*pFileStream)
+#if (OSL_DEBUG_LEVEL > 1) || defined(DBG_UTIL)
+ << " >> /tmp/kstart.log"
+#else
+ << " > /dev/null"
+#endif
+ << sNewLine
+ << sNewLine;
+ pFileStream->Flush();
+ }
+ // now execute the command
+ OProcess aApp(sCommandFile ,m_sDbWorkURL);
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait));
+#if OSL_DEBUG_LEVEL < 2
+ if(UCBContentHelper::Exists(sCommandFile))
+ UCBContentHelper::Kill(sCommandFile);
+#endif
+
+#endif //WNT,UNX
+}
+// -----------------------------------------------------------------------------
+void ODriver::convertOldVersion(const ::rtl::OUString& sDBName,const TDatabaseStruct& _rDbInfo)
+{
+ // first we have to check if this databse is a old version and we have to update the system tables
+ if ( !isVersion(sDBName,CURRENT_DB_VERSION) && isKernelVersion(CURRENT_DB_VERSION) )
+ {
+ if ( !_rDbInfo.sControlUser.getLength()
+ || !_rDbInfo.sControlPassword.getLength())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_DATABASE_NEEDS_CONVERTING) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ String sCommandFile = m_sDbWorkURL;
+ sCommandFile += String::CreateFromAscii("/xparam.prt");
+ if ( UCBContentHelper::Exists(sCommandFile) )
+ UCBContentHelper::Kill(sCommandFile);
+ X_PARAM(sDBName,_rDbInfo.sControlUser,_rDbInfo.sControlPassword,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BCHECK")));
+
+ if ( UCBContentHelper::Exists(sCommandFile) )
+ {
+ {
+ ::std::auto_ptr<SvStream> pFileStream( UcbStreamHelper::CreateStream(sCommandFile,STREAM_STD_READ) );
+ ByteString sStateLine;
+ sal_Bool bRead = sal_True;
+ static ByteString s_ErrorId("-21100");
+ while ( pFileStream.get() && bRead && !pFileStream->IsEof() )
+ {
+ bRead = pFileStream->ReadLine(sStateLine);
+ if ( bRead && s_ErrorId == sStateLine.GetToken(0,' ') )
+ {
+ UCBContentHelper::Kill(sCommandFile);
+ ::rtl::OUString sError(::rtl::OUString::createFromAscii(sStateLine.GetBuffer()));
+ throw SQLException(sError,*this,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000")),1000,Any());
+ }
+ }
+ }
+
+ UCBContentHelper::Kill(sCommandFile);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+ } // namespace adabas
+}// namespace connectivity
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/adabas/BFunctions.cxx b/connectivity/source/drivers/adabas/BFunctions.cxx
new file mode 100644
index 000000000000..3a57e4818e88
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BFunctions.cxx
@@ -0,0 +1,275 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+//--------------------------------------------------------------------------
+#include "odbc/OFunctions.hxx"
+#include <osl/process.h>
+
+// Implib-Definitionen fuer ODBC-DLL/shared library:
+
+namespace connectivity
+{
+ namespace adabas
+ {
+ T3SQLAllocHandle pODBC3SQLAllocHandle;
+T3SQLConnect pODBC3SQLConnect;
+T3SQLDriverConnect pODBC3SQLDriverConnect;
+T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+T3SQLDataSources pODBC3SQLDataSources;
+T3SQLDrivers pODBC3SQLDrivers;
+T3SQLGetInfo pODBC3SQLGetInfo;
+T3SQLGetFunctions pODBC3SQLGetFunctions;
+T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+//T3SQLSetDescField pODBC3SQLSetDescField;
+//T3SQLGetDescField pODBC3SQLGetDescField;
+//T3SQLGetDescRec pODBC3SQLGetDescRec;
+//T3SQLSetDescRec pODBC3SQLSetDescRec;
+T3SQLPrepare pODBC3SQLPrepare;
+T3SQLBindParameter pODBC3SQLBindParameter;
+//T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLSetCursorName pODBC3SQLSetCursorName;
+T3SQLExecute pODBC3SQLExecute;
+T3SQLExecDirect pODBC3SQLExecDirect;
+//T3SQLNativeSql pODBC3SQLNativeSql;
+T3SQLDescribeParam pODBC3SQLDescribeParam;
+T3SQLNumParams pODBC3SQLNumParams;
+T3SQLParamData pODBC3SQLParamData;
+T3SQLPutData pODBC3SQLPutData;
+T3SQLRowCount pODBC3SQLRowCount;
+T3SQLNumResultCols pODBC3SQLNumResultCols;
+T3SQLDescribeCol pODBC3SQLDescribeCol;
+T3SQLColAttribute pODBC3SQLColAttribute;
+T3SQLBindCol pODBC3SQLBindCol;
+T3SQLFetch pODBC3SQLFetch;
+T3SQLFetchScroll pODBC3SQLFetchScroll;
+T3SQLGetData pODBC3SQLGetData;
+T3SQLSetPos pODBC3SQLSetPos;
+T3SQLBulkOperations pODBC3SQLBulkOperations;
+T3SQLMoreResults pODBC3SQLMoreResults;
+//T3SQLGetDiagField pODBC3SQLGetDiagField;
+T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+T3SQLColumns pODBC3SQLColumns;
+T3SQLForeignKeys pODBC3SQLForeignKeys;
+T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+T3SQLProcedures pODBC3SQLProcedures;
+T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+T3SQLStatistics pODBC3SQLStatistics;
+T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+T3SQLTables pODBC3SQLTables;
+T3SQLFreeStmt pODBC3SQLFreeStmt;
+T3SQLCloseCursor pODBC3SQLCloseCursor;
+T3SQLCancel pODBC3SQLCancel;
+T3SQLEndTran pODBC3SQLEndTran;
+T3SQLDisconnect pODBC3SQLDisconnect;
+T3SQLFreeHandle pODBC3SQLFreeHandle;
+T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLNativeSql pODBC3SQLNativeSql;
+
+
+sal_Bool LoadFunctions(oslModule pODBCso);
+// -------------------------------------------------------------------------
+sal_Bool LoadLibrary_ADABAS(::rtl::OUString &_rPath)
+{
+ static sal_Bool bLoaded = sal_False;
+ static oslModule pODBCso = NULL;
+
+ if (bLoaded)
+ return sal_True;
+
+ rtl_uString* pPath = NULL;
+ ::rtl::OUString sTemp(RTL_CONSTASCII_USTRINGPARAM("DBROOT"));
+ if ( osl_getEnvironment(sTemp.pData,&pPath) == osl_Process_E_None && pPath )
+ {
+
+#if ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX) || defined(MACOSX)
+ _rPath = ::rtl::OUString(pPath);
+ _rPath += ::rtl::OUString::createFromAscii("/lib/");
+#endif
+ rtl_uString_release(pPath);
+ }
+ else
+ {
+ _rPath = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The variable DBROOT is not set."));
+ return sal_False;
+ }
+ const sal_Char* pLibraryAsciiName = NULL;
+
+#if defined(WIN) || defined(WNT)
+ pLibraryAsciiName = "SQLOD32.DLL";
+#elif ( defined(SOLARIS) && defined(SPARC)) || defined(LINUX)
+ pLibraryAsciiName = "odbclib.so";
+#elif defined(MACOSX)
+ pLibraryAsciiName = "odbclib.dylib";
+#endif
+ if ( !pLibraryAsciiName )
+ return sal_False;
+
+ _rPath += ::rtl::OUString::createFromAscii( pLibraryAsciiName );
+ pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
+ if( !pODBCso)
+ return sal_False;
+
+
+ return bLoaded = LoadFunctions(pODBCso);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool LoadFunctions(oslModule pODBCso)
+{
+
+ if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLAllocHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDriverConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBrowseConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetInfo").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetTypeInfo").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetStmtAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetStmtAttr").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLSetDescField = (T3SQLSetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescField").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetDescField = (T3SQLGetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescField").pData )) == NULL )
+ return sal_False;*/
+ /*if( ( pODBC3SQLGetDescRec = (T3SQLGetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetDescRec = (T3SQLSetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescRec").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrepare").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindParameter").pData )) == NULL )
+ return sal_False;
+// if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+// return sal_False;
+ if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecDirect").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeParam").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumParams").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLParamData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPutData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLRowCount").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumResultCols").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColAttribute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetch").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetchScroll").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetPos").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLMoreResults").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLGetDiagField = (T3SQLGetDiagField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagField").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumnPrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLForeignKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrimaryKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedureColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedures").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSpecialColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLStatistics").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTablePrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTables").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeStmt").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCloseCursor").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCancel").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLEndTran").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDisconnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+ }
+}
+
diff --git a/connectivity/source/drivers/adabas/BGroup.cxx b/connectivity/source/drivers/adabas/BGroup.cxx
new file mode 100644
index 000000000000..00b94fe1311d
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BGroup.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_GROUP_HXX_
+#include "adabas/BGroup.hxx"
+#endif
+#include "adabas/BUsers.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection) : connectivity::sdbcx::OGroup(sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ TStringVector aVector;
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+OAdabasGroup::OAdabasGroup( OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OGroup(_Name,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ refreshUsers();
+}
+// -------------------------------------------------------------------------
+void OAdabasGroup::refreshUsers()
+{
+ if(!m_pConnection)
+ return;
+
+ TStringVector aVector;
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT USERNAME FROM DOMAIN.USERS WHERE USERNAME IS NOT NULL AND USERNAME <> ' ' AND USERNAME <> 'CONTROL' AND GROUPNAME = '");
+ aSql += getName( );
+ aSql += ::rtl::OUString::createFromAscii("'");
+
+ Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_pConnection,this);
+}
+
+
diff --git a/connectivity/source/drivers/adabas/BGroups.cxx b/connectivity/source/drivers/adabas/BGroups.cxx
new file mode 100644
index 000000000000..96ad5f79b022
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BGroups.cxx
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BGroups.hxx"
+#include "adabas/BGroup.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OGroups::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdabasGroup(m_pConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OGroups::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshGroups();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OGroups::createDescriptor()
+{
+ // OAdabasGroup* pNew =
+ return new OAdabasGroup(m_pConnection);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OGroups::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& /*descriptor*/ )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USERGROUP ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ aSql = aSql + aQuote + _rForName + aQuote;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OGroups::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USERGROUP ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ aSql = aSql + aQuote + _sElementName + aQuote;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BIndex.cxx b/connectivity/source/drivers/adabas/BIndex.cxx
new file mode 100644
index 000000000000..90da508c64ec
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndex.cxx
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BIndex.hxx"
+#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+#include "adabas/BIndexColumns.hxx"
+#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BTable.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OAdabasIndex::OAdabasIndex( OAdabasTable* _pTable,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Catalog,
+ sal_Bool _isUnique,
+ sal_Bool _isPrimaryKeyIndex,
+ sal_Bool _isClustered
+ ) : connectivity::sdbcx::OIndex(_Name,
+ _Catalog,
+ _isUnique,
+ _isPrimaryKeyIndex,
+ _isClustered,sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+OAdabasIndex::OAdabasIndex(OAdabasTable* _pTable)
+ : connectivity::sdbcx::OIndex(sal_True)
+ ,m_pTable(_pTable)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+
+void OAdabasIndex::refreshColumns()
+{
+ if(!m_pTable)
+ return;
+
+ TStringVector aVector;
+ if(!isNew())
+ {
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),sal_False,sal_False);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aColName;
+ while(xResult->next())
+ {
+ if(xRow->getString(6) == m_Name)
+ {
+ aColName = xRow->getString(9);
+ if(!xRow->wasNull())
+ aVector.push_back(aColName);
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OIndexColumns(this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BIndexColumns.cxx b/connectivity/source/drivers/adabas/BIndexColumns.cxx
new file mode 100644
index 000000000000..1811a78428c7
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndexColumns.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_INDEXCOLUMNS_HXX_
+#include "adabas/BIndexColumns.hxx"
+#endif
+#include "connectivity/sdbcx/VIndexColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "adabas/BTable.hxx"
+#include "adabas/BCatalog.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+
+using namespace connectivity::adabas;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+ObjectType OIndexColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ Reference< XResultSet > xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getIndexInfo(Any(),
+ m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),sal_False,sal_False);
+
+ sal_Bool bAsc = sal_True;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aD(::rtl::OUString::createFromAscii("D"));
+ while(xResult->next())
+ {
+ if(xRow->getString(9) == _rName)
+ bAsc = xRow->getString(10) != aD;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ xResult = m_pIndex->getTable()->getConnection()->getMetaData()->getColumns(Any(),
+ m_pIndex->getTable()->getSchema(),m_pIndex->getTable()->getTableName(),_rName);
+
+ ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+ OAdabasCatalog::correctColumnProperties(nPrec,nType,sTypeName);
+
+ OIndexColumn* pRet = new OIndexColumn(bAsc,
+ _rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexColumns::createDescriptor()
+{
+ return new OIndexColumn(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OIndexColumns::impl_refresh() throw(::com::sun::star::uno::RuntimeException)
+{
+ m_pIndex->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+ObjectType OIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
+{
+ return cloneDescriptor( descriptor );
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BIndexes.cxx b/connectivity/source/drivers/adabas/BIndexes.cxx
new file mode 100644
index 000000000000..242d4c031015
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BIndexes.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BIndexes.hxx"
+#include "adabas/BIndex.hxx"
+#include "adabas/BTable.hxx"
+#include "connectivity/sdbcx/VIndex.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <comphelper/types.hxx>
+#include <comphelper/types.hxx>
+#include "adabas/BCatalog.hxx"
+#include "connectivity/dbexception.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aQualifier;
+ sal_Int32 nLen = _rName.indexOf('.');
+ if(nLen != -1)
+ {
+ aQualifier = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+ }
+ else
+ aName = _rName;
+
+
+ Reference< XResultSet > xResult = m_pTable->getMetaData()->getIndexInfo(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),sal_False,sal_False);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(6) == aName && (!aQualifier.getLength() || xRow->getString(5) == aQualifier ))
+ {
+ OAdabasIndex* pRet = new OAdabasIndex(m_pTable,aName,aQualifier,!xRow->getBoolean(4),
+ aName == ::rtl::OUString::createFromAscii("SYSPRIMARYKEYINDEX"),
+ xRow->getShort(7) == IndexType::CLUSTERED);
+ xRet = pRet;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OIndexes::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexes::createDescriptor()
+{
+ return new OAdabasIndex(m_pTable);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ if ( m_pTable->isNew() )
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(this));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE ");
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ if(getBOOL(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ aSql = aSql + ::rtl::OUString::createFromAscii("UNIQUE ");
+ aSql = aSql + ::rtl::OUString::createFromAscii("INDEX ");
+
+
+ if(_rForName.getLength())
+ {
+ aSql = aSql + aQuote + _rForName + aQuote
+ + ::rtl::OUString::createFromAscii(" ON ")
+ + aQuote + m_pTable->getSchema() + aQuote + sDot
+ + aQuote + m_pTable->getTableName() + aQuote
+ + ::rtl::OUString::createFromAscii(" ( ");
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+ aSql = aSql + (getBOOL(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING)))
+ ?
+ ::rtl::OUString::createFromAscii(" ASC")
+ :
+ ::rtl::OUString::createFromAscii(" DESC"))
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else
+ {
+ aSql = aSql + aQuote + m_pTable->getSchema() + aQuote + sDot + aQuote + m_pTable->getTableName() + aQuote;
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+ if(xColumns->getCount() != 1)
+ throw SQLException();
+
+ xColumns->getByIndex(0) >>= xColProp;
+
+ aSql = aSql + sDot + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+ }
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OIndexes::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ if(!m_pTable->isNew())
+ {
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP INDEX ");
+ ::rtl::OUString aQuote = m_pTable->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ if (aSchema.getLength())
+ (((aSql += aQuote) += aSchema) += aQuote) += sDot;
+
+ (((aSql += aQuote) += aName) += aQuote) += ::rtl::OUString::createFromAscii(" ON ");
+
+ (((aSql += aQuote) += m_pTable->getSchema()) += aQuote) += sDot;
+ ((aSql += aQuote) += m_pTable->getTableName()) += aQuote;
+
+ Reference< XStatement > xStmt = m_pTable->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BKeys.cxx b/connectivity/source/drivers/adabas/BKeys.cxx
new file mode 100644
index 000000000000..3226bc61f54a
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BKeys.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BKeys.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <comphelper/types.hxx>
+#include "adabas/BCatalog.hxx"
+#include <comphelper/property.hxx>
+#include <connectivity/TKeys.hxx>
+#include <connectivity/dbtools.hxx>
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef OKeysHelper OCollection_TYPE;
+
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OKeys::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ if ( getTable()->isNew() )
+ {
+ Reference< XPropertySet > xNewDescriptor( cloneDescriptor( descriptor ) );
+ OKeysHelper::cloneDescriptorColumns( descriptor, xNewDescriptor );
+ return xNewDescriptor;
+ }
+
+ sal_Int32 nKeyType = getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString aQuote = getTable()->getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql += composeTableName( getTable()->getConnection()->getMetaData(), getTable(), ::dbtools::eInTableDefinitions, false, false, true );
+
+ if(nKeyType == KeyType::PRIMARY)
+ {
+ aSql = aSql + ::rtl::OUString::createFromAscii(" ALTER PRIMARY KEY (");
+ }
+ else if(nKeyType == KeyType::FOREIGN)
+ {
+ aSql = aSql + ::rtl::OUString::createFromAscii(" FOREIGN KEY (");
+ }
+ else
+ throw SQLException();
+
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ Reference< XPropertySet > xColProp;
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ sal_Int32 nUpdateRule = 0, nDeleteRule = 0;
+ ::rtl::OUString sReferencedName;
+
+ if(nKeyType == KeyType::FOREIGN)
+ {
+ nDeleteRule = getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE)));
+
+ ::rtl::OUString aName,aSchema;
+ sReferencedName = getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
+ sal_Int32 nLen = sReferencedName.indexOf('.');
+ aSchema = sReferencedName.copy(0,nLen);
+ aName = sReferencedName.copy(nLen+1);
+ aSql += ::rtl::OUString::createFromAscii(" REFERENCES ")
+ + aQuote + aSchema + aQuote + sDot + aQuote + aName + aQuote;
+ aSql += ::rtl::OUString::createFromAscii(" (");
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ Reference< XPropertySet > xColProp;
+ xColumns->getByIndex(i) >>= xColProp;
+ aSql = aSql + aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ switch(nDeleteRule)
+ {
+ case KeyRule::CASCADE:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE ");
+ break;
+ case KeyRule::RESTRICT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ");
+ break;
+ case KeyRule::SET_NULL:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL ");
+ break;
+ case KeyRule::SET_DEFAULT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ");
+ break;
+ default:
+ ;
+ }
+ }
+
+ Reference< XStatement > xStmt = getTable()->getConnection()->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ // find the name which the database gave the new key
+ ::rtl::OUString sNewName( _rForName );
+ if(nKeyType == KeyType::FOREIGN)
+ {
+ const ::dbtools::OPropertyMap& rPropMap = OMetaConnection::getPropMap();
+ ::rtl::OUString aSchema,aTable;
+ getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= aSchema;
+ getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_NAME)) >>= aTable;
+ Reference< XResultSet > xResult = getTable()->getMetaData()->getImportedKeys( getTable()->getPropertyValue(rPropMap.getNameByIndex(PROPERTY_ID_CATALOGNAME))
+ ,aSchema
+ ,aTable);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ ::rtl::OUString sName = xRow->getString(12);
+ if ( !m_pElements->exists(sName) ) // this name wasn't inserted yet so it must be te new one
+ {
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sName));
+ sNewName = sName;
+ break;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ }
+
+ getTable()->addKey(sNewName,sdbcx::TKeyProperties(new sdbcx::KeyProperties(sReferencedName,nKeyType,nUpdateRule,nDeleteRule)));
+ return createObject( sNewName );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OKeys::getDropForeignKey() const
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP FOREIGN KEY "));
+}
+
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BPreparedStatement.cxx b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
new file mode 100644
index 000000000000..3c9b323fe71b
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BPreparedStatement.cxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BPreparedStatement.hxx"
+#include "adabas/BResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+OAdabasPreparedStatement::OAdabasPreparedStatement( OAdabasConnection* _pConnection,const ::rtl::OUString& sql)
+: ::connectivity::odbc::OPreparedStatement( _pConnection,sql)
+{
+ m_aSelectColumns = _pConnection->createSelectColumns(sql);
+}
+// -----------------------------------------------------------------------------
+OResultSet* OAdabasPreparedStatement::createResulSet()
+{
+ return new OAdabasResultSet(m_aStatementHandle,this,m_aSelectColumns);
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setUsingBookmarks(sal_Bool /*_bUseBookmark*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "bookmarks", *this );
+ // adabas doesn't support bookmarks
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setResultSetConcurrency(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetConcurrency", *this );
+}
+// -----------------------------------------------------------------------------
+void OAdabasPreparedStatement::setResultSetType(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetType", *this );
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/adabas/BResultSet.cxx b/connectivity/source/drivers/adabas/BResultSet.cxx
new file mode 100644
index 000000000000..ad91515d4fac
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BResultSet.cxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BResultSet.hxx"
+#include "adabas/BResultSetMetaData.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "odbc/OTools.hxx"
+
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+// comment: all this movement methods are needed because adabas doesn't support a SQLGetData call when
+// the cursor was moved with a call of SQLFetchScroll. So when this is fixed by adabas we can remove this damn thing.
+
+
+sal_Bool SAL_CALL OAdabasResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+
+ if(m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO)
+ ++m_nRowPos;
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ // don't ask why !
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
+ if ( bRet )
+ m_nRowPos = 1;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OAdabasResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ m_bEOF = sal_True;
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ // here I know definitely that I stand on the last record
+ return m_bLastRecord = (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet)
+ m_nRowPos = row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet)
+ m_nRowPos += row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(bRet || m_nCurrentFetchState == SQL_NO_DATA)
+ --m_nRowPos;
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdabasResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_OFF,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_RETRIEVE_DATA,(SQLPOINTER)SQL_RD_ON,SQL_IS_UINTEGER);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ }
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL OAdabasResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OAdabasResultSetMetaData(m_pStatement->getOwnConnection(),m_aStatementHandle,m_aSelectColumns);
+ return m_xMetaData;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/adabas/BResultSetMetaData.cxx b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx
new file mode 100644
index 000000000000..f2c56a5cc3d9
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BResultSetMetaData.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_BRESULTSETMETADATA_HXX_
+#include "adabas/BResultSetMetaData.hxx"
+#endif
+#include "adabas/BCatalog.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::uno;
+using namespace connectivity::adabas;
+using namespace connectivity;
+
+OAdabasResultSetMetaData::OAdabasResultSetMetaData(odbc::OConnection* _pConnection, SQLHANDLE _pStmt,const ::vos::ORef<OSQLColumns>& _rSelectColumns )
+: OAdabasResultSetMetaData_BASE(_pConnection,_pStmt)
+,m_aSelectColumns(_rSelectColumns)
+{
+}
+// -------------------------------------------------------------------------
+OAdabasResultSetMetaData::~OAdabasResultSetMetaData()
+{
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = OAdabasResultSetMetaData_BASE::getColumnType( column);
+ // special handling for float values which could be doubles
+ ::rtl::OUString sTypeName;
+ OAdabasCatalog::correctColumnProperties(getPrecision(column),nType,sTypeName);
+
+ return nType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0;
+ sal_Bool bFound = sal_False;
+ if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
+ bFound = (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nValue;
+
+ if ( !bFound )
+ nValue = getNumColAttrib(column,SQL_DESC_NULLABLE);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if ( m_aSelectColumns.isValid() && column > 0 && column <= (sal_Int32)m_aSelectColumns->get().size() )
+ {
+ sal_Bool bAutoIncrement = sal_False;
+ (m_aSelectColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
+ return bAutoIncrement;
+ }
+
+ return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BStatement.cxx b/connectivity/source/drivers/adabas/BStatement.cxx
new file mode 100644
index 000000000000..a9aa44ca91c7
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BStatement.cxx
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BStatement.hxx"
+#include "adabas/BResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbexception.hxx>
+
+
+using namespace connectivity::adabas;
+using namespace connectivity::odbc;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+typedef ::connectivity::odbc::OStatement OAdabasStatement_BASE;
+// -----------------------------------------------------------------------------
+OResultSet* OAdabasStatement::createResulSet()
+{
+ return new OAdabasResultSet(m_aStatementHandle,this,m_aSelectColumns);
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setUsingBookmarks(sal_Bool /*_bUseBookmark*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "bookmarks", *this );
+ // adabas doesn't support bookmarks
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setResultSetConcurrency(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetConcurrency", *this );
+}
+// -----------------------------------------------------------------------------
+void OAdabasStatement::setResultSetType(sal_Int32 /*_par0*/)
+{
+ ::dbtools::throwFeatureNotImplementedException( "PreparedStatement:ResultSetType", *this );
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OAdabasStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ m_aSelectColumns = m_pOwnConnection->createSelectColumns(sql);
+ return OAdabasStatement_BASE::execute(sql);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BTable.cxx b/connectivity/source/drivers/adabas/BTable.cxx
new file mode 100644
index 000000000000..9ce683d3c0df
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BTable.cxx
@@ -0,0 +1,376 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BTable.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BIndexes.hxx"
+#include "adabas/BColumns.hxx"
+#include "adabas/BKeys.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "adabas/BCatalog.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::adabas;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _pConnection)
+ :OTable_TYPEDEF(_pTables,_pConnection,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OAdabasTable::OAdabasTable( sdbcx::OCollection* _pTables,
+ OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OTableHelper( _pTables,
+ _pConnection,
+ sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createColumns(const TStringVector& _rNames)
+{
+ return new OColumns(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createKeys(const TStringVector& _rNames)
+{
+ return new OKeys(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OAdabasTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexes(this,m_aMutex,_rNames);
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdabasTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdabasTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OAdabasTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ if(m_pColumns && !m_pColumns->hasByName(colName))
+ throw NoSuchElementException(colName,*this);
+
+
+ if(!isNew())
+ {
+ beginTransAction();
+
+ try
+ {
+ // first we have to check what should be altered
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByName(colName) >>= xProp;
+ // first check the types
+ sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
+
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nOldType;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nNewType;
+ // and precsions and scale
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nOldPrec;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))>>= nNewPrec;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nOldScale;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nNewScale;
+
+ if(nOldType != nNewType || nOldPrec != nNewPrec || nOldScale != nNewScale)
+ alterColumnType(colName,descriptor);
+
+ // second: check the "is nullable" value
+ sal_Int32 nOldNullable = 0,nNewNullable = 0;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nOldNullable;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNewNullable;
+ if(nNewNullable != nOldNullable)
+ alterNotNullValue(nNewNullable,colName);
+
+ // third: check the default values
+ ::rtl::OUString sNewDefault,sOldDefault;
+ xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sOldDefault;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sNewDefault;
+
+ if(sOldDefault.getLength())
+ {
+ if(sNewDefault.getLength() && sOldDefault != sNewDefault)
+ alterDefaultValue(sNewDefault,colName);
+ else if(!sNewDefault.getLength())
+ dropDefaultValue(colName);
+ }
+ else if(!sOldDefault.getLength() && sNewDefault.getLength())
+ addDefaultValue(sNewDefault,colName);
+
+ // now we should look if the name of the column changed
+ ::rtl::OUString sNewColumnName;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
+ if(!sNewColumnName.equalsIgnoreAsciiCase(colName))
+ {
+ const ::rtl::OUString sQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("RENAME COLUMN ") ;
+ sSql += ::dbtools::quoteName(sQuote,m_SchemaName) + sDot + ::dbtools::quoteName(sQuote,m_Name);
+ sSql += sDot + ::dbtools::quoteName(sQuote,colName);
+ sSql += ::rtl::OUString::createFromAscii(" TO ");
+ sSql += ::dbtools::quoteName(sQuote,sNewColumnName);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ m_pColumns->refresh();
+ }
+ catch(const SQLException&)
+ {
+ rollbackTransAction();
+ throw;
+ }
+ endTransAction();
+ }
+ else
+ {
+ if(m_pColumns)
+ {
+ m_pColumns->dropByName(colName);
+ m_pColumns->appendByDescriptor(descriptor);
+ }
+ }
+
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OAdabasTable::getName() throw(::com::sun::star::uno::RuntimeException)
+{
+ ::rtl::OUString sName = m_SchemaName;
+ if(m_SchemaName.getLength())
+ {
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ sName += sDot;
+ }
+ sName += m_Name;
+ return sName;
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterColumnType(const ::rtl::OUString& _rColName, const Reference<XPropertySet>& _xDescriptor)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ");
+ sSql += OTables::getColumnSqlType(_xDescriptor);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterNotNullValue(sal_Int32 _nNewNullable,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+
+ if(_nNewNullable == ColumnValue::NO_NULLS)
+ {
+ sSql += ::rtl::OUString::createFromAscii(" NOT NULL");
+ }
+ else
+ {
+ sSql += ::rtl::OUString::createFromAscii(" DEFAULT NULL");
+ }
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ALTER ") + _sNewDefault;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::dropDefaultValue(const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" DROP DEFAULT");
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::addDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart(_rColName);
+ sSql += ::rtl::OUString::createFromAscii(" ADD ") + _sNewDefault;
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(sSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::beginTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS BEGIN") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::endTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS END") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void OAdabasTable::rollbackTransAction()
+{
+ try
+ {
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ xStmt->execute(::rtl::OUString::createFromAscii("SUBTRANS ROLLBACK") );
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasTable::getAlterTableColumnPart(const ::rtl::OUString& _rsColumnName )
+{
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString sQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ sSql += ::dbtools::quoteName(sQuote,m_SchemaName) + sDot + ::dbtools::quoteName(sQuote,m_Name)
+ + ::rtl::OUString::createFromAscii(" COLUMN ")
+ + ::dbtools::quoteName(sQuote,_rsColumnName);
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/adabas/BTables.cxx b/connectivity/source/drivers/adabas/BTables.cxx
new file mode 100644
index 000000000000..dd0fe1564ade
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BTables.cxx
@@ -0,0 +1,522 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BTables.hxx"
+#include "adabas/BViews.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _rName.indexOf('.');
+ aSchema = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString::createFromAscii("%");
+ // aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
+ // aTypes[1] = ::rtl::OUString::createFromAscii("SYSTEMTABLE");
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ OAdabasTable* pRet = new OAdabasTable(this, static_cast<OAdabasCatalog&>(m_rParent).getConnection(),
+ aName,xRow->getString(4),xRow->getString(5),aSchema);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OAdabasCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OAdabasTable(this,static_cast<OAdabasCatalog&>(m_rParent).getConnection());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createTable(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+void OTables::setComments(const Reference< XPropertySet >& descriptor ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ aSql = ::rtl::OUString::createFromAscii("COMMENT ON TABLE ");
+ ::rtl::OUString sSchema;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+
+ aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(" '")
+ + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)))
+ + ::rtl::OUString::createFromAscii("'");
+ xStmt->execute(aSql);
+
+ // columns
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+
+ aSql = ::rtl::OUString::createFromAscii("COMMENT ON COLUMN ");
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ aSql += aQuote + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote + sDot
+ + aQuote;
+
+ for(sal_Int32 i=0;i<xColumns->getCount();++i)
+ {
+ ::cppu::extractInterface(xColProp,xColumns->getByIndex(i));
+ if(xColProp.is())
+ {
+ ::rtl::OUString aDescription = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)));
+ if(aDescription.getLength())
+ {
+ ::rtl::OUString aCom = aSql + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(" '")
+ + aDescription
+ + ::rtl::OUString::createFromAscii("'");
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+ }
+ ::comphelper::disposeComponent(xStmt);
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ sal_Bool bIsView;
+ if((bIsView = (xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == ::rtl::OUString::createFromAscii("VIEW")))) // here we have a view
+ aSql += ::rtl::OUString::createFromAscii("VIEW ");
+ else
+ aSql += ::rtl::OUString::createFromAscii("TABLE ");
+
+ aSql += m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( );
+ aSql += sDot;
+ aSql += m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ // if no exception was thrown we must delete it from the views
+ if(bIsView)
+ {
+ OViews* pViews = static_cast<OViews*>(static_cast<OAdabasCatalog&>(m_rParent).getPrivateViews());
+ if(pViews && pViews->hasByName(_sElementName))
+ pViews->dropByNameImpl(_sElementName);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE TABLE ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ ::rtl::OUString sSchema;
+
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ else
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),makeAny(static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getUserName().
+ toAsciiUpperCase()
+ ));
+
+ aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))
+ + ::rtl::OUString::createFromAscii(" (");
+
+ // columns
+ Reference<XColumnsSupplier> xColumnSup(descriptor,UNO_QUERY);
+ Reference<XIndexAccess> xColumns(xColumnSup->getColumns(),UNO_QUERY);
+ Reference< XPropertySet > xColProp;
+
+ Any aTypeName;
+ sal_Int32 nCount = xColumns->getCount();
+ if(!nCount)
+ ::dbtools::throwFunctionSequenceException(static_cast<XTypeProvider*>(this));
+
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(i)) && xColProp.is())
+ {
+
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote;
+
+ aSql += ::rtl::OUString::createFromAscii(" ");
+ aSql += OTables::getColumnSqlType(xColProp);
+ aSql += OTables::getColumnSqlNotNullDefault(xColProp);
+ aSql += ::rtl::OUString::createFromAscii(",");
+ }
+ }
+
+ // keys
+
+ Reference<XKeysSupplier> xKeySup(descriptor,UNO_QUERY);
+
+ Reference<XIndexAccess> xKeys = xKeySup->getKeys();
+ if(xKeys.is())
+ {
+ sal_Bool bPKey = sal_False;
+ for( sal_Int32 key=0; key<xKeys->getCount(); ++key )
+ {
+ if(::cppu::extractInterface(xColProp,xKeys->getByIndex(key)) && xColProp.is())
+ {
+
+ sal_Int32 nKeyType = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+
+ if(nKeyType == KeyType::PRIMARY)
+ {
+ if(bPKey)
+ throw SQLException();
+
+ bPKey = sal_True;
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" PRIMARY KEY (");
+ for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else if(nKeyType == KeyType::UNIQUE)
+ {
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" UNIQUE (");
+ for( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ }
+ else if(nKeyType == KeyType::FOREIGN)
+ {
+ sal_Int32 nDeleteRule = getINT32(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELETERULE)));
+
+ xColumnSup = Reference<XColumnsSupplier>(xColProp,UNO_QUERY);
+ xColumns = Reference<XIndexAccess>(xColumnSup->getColumns(),UNO_QUERY);
+ if(!xColumns->getCount())
+ throw SQLException();
+
+ aSql += ::rtl::OUString::createFromAscii(" FOREIGN KEY ");
+ ::rtl::OUString aName,aSchema,aRefTable = getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REFERENCEDTABLE)));
+ sal_Int32 nLen = aRefTable.indexOf('.');
+ aSchema = aRefTable.copy(0,nLen);
+ aName = aRefTable.copy(nLen+1);
+
+ aSql += aQuote + aSchema + aQuote + sDot
+ + aQuote + aName + aQuote
+ + ::rtl::OUString::createFromAscii(" (");
+
+ for ( sal_Int32 column=0; column<xColumns->getCount(); ++column )
+ {
+ if(::cppu::extractInterface(xColProp,xColumns->getByIndex(column)) && xColProp.is())
+ aSql += aQuote + getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))) + aQuote
+ + ::rtl::OUString::createFromAscii(",");
+ }
+
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ switch(nDeleteRule)
+ {
+ case KeyRule::CASCADE:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE CASCADE ");
+ break;
+ case KeyRule::RESTRICT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE RESTRICT ");
+ break;
+ case KeyRule::SET_NULL:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET NULL ");
+ break;
+ case KeyRule::SET_DEFAULT:
+ aSql += ::rtl::OUString::createFromAscii(" ON DELETE SET DEFAULT ");
+ break;
+ default:
+ ;
+ }
+ }
+ }
+ }
+ }
+
+ if(aSql.lastIndexOf(',') == (aSql.getLength()-1))
+ aSql = aSql.replaceAt(aSql.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+ else
+ aSql += ::rtl::OUString::createFromAscii(")");
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ if(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION))).getLength())
+ setComments(descriptor);
+}
+// -----------------------------------------------------------------------------
+void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
+{
+ insertElement(_rsNewTable,NULL);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getColumnSqlType(const Reference<XPropertySet>& _rxColProp)
+{
+ ::rtl::OUString sSql;
+ sal_Int32 nDataType = 0;
+ _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nDataType;
+ switch(nDataType)
+ {
+ case DataType::VARBINARY:
+ sSql += ::rtl::OUString::createFromAscii("VAR");
+ /* run through*/
+ case DataType::BINARY:
+ sSql += ::rtl::OUString::createFromAscii("CHAR");
+ break;
+ default:
+ {
+ Any aTypeName = _rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ if(aTypeName.hasValue() && getString(aTypeName).getLength())
+ sSql += getString(aTypeName);
+ else
+ sSql += OTables::getTypeString(_rxColProp) + ::rtl::OUString::createFromAscii(" ");
+ }
+ }
+
+ switch(nDataType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::FLOAT:
+ case DataType::REAL:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(")");
+ break;
+
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(",")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))))
+ + ::rtl::OUString::createFromAscii(")");
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ sSql += ::rtl::OUString::createFromAscii("(")
+ + ::rtl::OUString::valueOf(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))))
+ + ::rtl::OUString::createFromAscii(") BYTE");
+ break;
+ }
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getColumnSqlNotNullDefault(const Reference<XPropertySet>& _rxColProp)
+{
+ OSL_ENSURE(_rxColProp.is(),"OTables::getColumnSqlNotNullDefault: Column is null!");
+ ::rtl::OUString sSql;
+ ::rtl::OUString aDefault = getString(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
+ if(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))) == ColumnValue::NO_NULLS)
+ {
+ sSql += ::rtl::OUString::createFromAscii(" NOT NULL");
+ if(aDefault.getLength())
+ sSql += ::rtl::OUString::createFromAscii(" WITH DEFAULT");
+ }
+ else if(aDefault.getLength())
+ {
+ sSql +=::rtl::OUString::createFromAscii(" DEFAULT '") + aDefault;
+ sSql += ::rtl::OUString::createFromAscii("'");
+ }
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getTypeString(const Reference< XPropertySet >& _rxColProp)
+{
+ ::rtl::OUString aValue;
+ switch(getINT32(_rxColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ {
+ case DataType::BIT:
+ aValue = ::rtl::OUString::createFromAscii("BOOLEAN");
+ break;
+ case DataType::TINYINT:
+ aValue = ::rtl::OUString::createFromAscii("SMALLINT");
+ break;
+ case DataType::SMALLINT:
+ aValue = ::rtl::OUString::createFromAscii("SMALLINT");
+ break;
+ case DataType::INTEGER:
+ aValue = ::rtl::OUString::createFromAscii("INT");
+ break;
+ case DataType::FLOAT:
+ aValue = ::rtl::OUString::createFromAscii("FLOAT");
+ break;
+ case DataType::REAL:
+ aValue = ::rtl::OUString::createFromAscii("REAL");
+ break;
+ case DataType::DOUBLE:
+ aValue = ::rtl::OUString::createFromAscii("DOUBLE");
+ break;
+ case DataType::NUMERIC:
+ aValue = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::DECIMAL:
+ aValue = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::CHAR:
+ aValue = ::rtl::OUString::createFromAscii("CHAR");
+ break;
+ case DataType::VARCHAR:
+ aValue = ::rtl::OUString::createFromAscii("VARCHAR");
+ break;
+ case DataType::LONGVARCHAR:
+ aValue = ::rtl::OUString::createFromAscii("LONG VARCHAR");
+ break;
+ case DataType::DATE:
+ aValue = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case DataType::TIME:
+ aValue = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ case DataType::TIMESTAMP:
+ aValue = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ case DataType::BINARY:
+ aValue = ::rtl::OUString::createFromAscii("CHAR () BYTE");
+ break;
+ case DataType::VARBINARY:
+ aValue = ::rtl::OUString::createFromAscii("VARCHAR () BYTE");
+ break;
+ case DataType::LONGVARBINARY:
+ aValue = ::rtl::OUString::createFromAscii("LONG BYTE");
+ break;
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+ ::rtl::OUString sName,sTemp;
+ _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sName;
+ if( sName.getLength() )
+ {
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ sName += sDot;
+ }
+
+ _xObject->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sTemp;
+ sName += sTemp;
+
+ return sName;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BUser.cxx b/connectivity/source/drivers/adabas/BUser.cxx
new file mode 100644
index 000000000000..7f926900f212
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BUser.cxx
@@ -0,0 +1,332 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BUser.hxx"
+#include "adabas/BGroups.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "adabas/BConnection.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "resource/adabas_res.hrc"
+
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection) : connectivity::sdbcx::OUser(sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OAdabasUser::OAdabasUser( OAdabasConnection* _pConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OUser(_Name,sal_True)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OAdabasUser::refreshGroups()
+{
+ if(!m_pConnection)
+ return;
+
+ TStringVector aVector;
+ aVector.reserve(7); // we don't know the excatly count of users but this should fit the normal need
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("SELECT DISTINCT GROUPNAME FROM DOMAIN.USERS WHERE GROUPNAME IS NOT NULL AND GROUPNAME <> ' ' AND USERNAME = '");
+ aSql += getName( );
+ aSql += ::rtl::OUString::createFromAscii("'");
+
+ Reference< XResultSet > xResult = xStmt->executeQuery(aSql);
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(*this,m_aMutex,aVector,m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend( OAdabasConnection* _pConnection) : OAdabasUser(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+void OUserExtend::construct()
+{
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ return 0;
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
+ return nRights;
+}
+// -----------------------------------------------------------------------------
+void OAdabasUser::getAnyTablePrivileges(const ::rtl::OUString& objName, sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("SELECT REFTABLENAME,PRIVILEGES FROM DOMAIN.USR_USES_TAB WHERE REFOBJTYPE <> 'SYSTEM' AND DEFUSERNAME = '");
+ sSql += m_Name;
+ sSql += ::rtl::OUString::createFromAscii("' AND REFTABLENAME = '");
+ sSql += sTable;
+ sSql += ::rtl::OUString::createFromAscii("'");
+ if(xStmt.is())
+ {
+ Reference<XResultSet> xRes = xStmt->executeQuery(sSql);
+ if(xRes.is())
+ {
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if(xRow.is() && xRes->next())
+ {
+ ::rtl::OUString sPrivs = xRow->getString(2);
+
+ struct _priv_nam
+ {
+ const sal_Char* pAsciiName;
+ sal_Int32 nNumericValue;
+ } privileges[] =
+ {
+ { "INS", Privilege::INSERT },
+ { "DEL", Privilege::DELETE },
+ { "UPD", Privilege::UPDATE },
+ { "ALT", Privilege::ALTER },
+ { "SEL", Privilege::SELECT },
+ { "REF", Privilege::REFERENCE }
+ };
+ for ( size_t i = 0; i < sizeof( privileges ) / sizeof( privileges[0] ); ++i )
+ {
+ sal_Int32 nIndex = sPrivs.indexOf( ::rtl::OUString::createFromAscii( privileges[i].pAsciiName ) );
+ if ( nIndex == -1 )
+ continue;
+
+ nRights |= privileges[i].nNumericValue;
+ if ( sPrivs.copy( nIndex + 2, 1 ).equalsAscii( "+" ) )
+ nRightsWithGrant |= privileges[i].nNumericValue;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdabasUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ return 0;
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ getAnyTablePrivileges(objName,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdabasUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_GRANTED,*this);
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("GRANT ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" TO ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdabasUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ m_pConnection->throwGenericSQLException(STR_PRIVILEGE_NOT_REVOKED,*this);
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_pConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" FROM ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+// XUser
+void SAL_CALL OAdabasUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sAlterPwd;
+ sAlterPwd = ::rtl::OUString::createFromAscii("ALTER PASSWORD \"");
+ sAlterPwd += objPassword.toAsciiUpperCase();
+ sAlterPwd += ::rtl::OUString::createFromAscii("\" TO \"") ;
+ sAlterPwd += newPassword.toAsciiUpperCase();
+ sAlterPwd += ::rtl::OUString::createFromAscii("\"") ;
+
+ sal_Bool bDisposeConnection = sal_False;
+ Reference<XConnection> xConnection = m_pConnection;
+ if(m_pConnection->getMetaData()->getUserName() != m_Name)
+ {
+ OAdabasConnection* pNewConnection = new OAdabasConnection(m_pConnection->getDriverHandle(),m_pConnection->getDriver());
+ xConnection = pNewConnection;
+ if(pNewConnection)
+ {
+ Sequence< PropertyValue> aSeq(2);
+ aSeq.getArray()[0].Name = ::rtl::OUString::createFromAscii("user") ;
+ aSeq.getArray()[0].Value <<= m_Name;
+ aSeq.getArray()[1].Name = ::rtl::OUString::createFromAscii("password") ;
+ aSeq.getArray()[1].Value <<= objPassword;
+ pNewConnection->Construct(m_pConnection->getMetaData()->getURL(),aSeq);
+ }
+ bDisposeConnection = sal_True;
+ }
+ if(xConnection.is())
+ {
+ Reference<XStatement> xStmt = xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ if(bDisposeConnection)
+ ::comphelper::disposeComponent(xConnection);
+ }
+ else
+ ::dbtools::throwFunctionSequenceException(*this);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OAdabasUser::getPrivilegeString(sal_Int32 nRights) const
+{
+ ::rtl::OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += ::rtl::OUString::createFromAscii("INSERT");
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("DELETE");
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("ALTER");
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("SELECT");
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
+ }
+
+ return sPrivs;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/adabas/BUsers.cxx b/connectivity/source/drivers/adabas/BUsers.cxx
new file mode 100644
index 000000000000..45b21ff79acb
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BUsers.cxx
@@ -0,0 +1,128 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BUsers.hxx"
+#include "adabas/BUser.hxx"
+#include "adabas/BTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "resource/adabas_res.hrc"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdabasUser(m_pConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OUsers::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshUsers();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ OUserExtend* pNew = new OUserExtend(m_pConnection);
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE USER ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sUserName( _rForName );
+ sUserName = sUserName.toAsciiUpperCase();
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(sUserName));
+ aSql += ::dbtools::quoteName(aQuote,sUserName)
+ + ::rtl::OUString::createFromAscii(" PASSWORD ")
+ + getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)));
+ aSql += ::rtl::OUString::createFromAscii(" RESOURCE NOT EXCLUSIVE");
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ {
+ // first we have to check if this user is live relevaant for the database
+ // which means with out these users the database will miss more than one important system table
+ ::rtl::OUString sUsers = ::rtl::OUString::createFromAscii("SELECT USERMODE,USERNAME FROM DOMAIN.USERS WHERE USERNAME = '");
+ sUsers += _sElementName + ::rtl::OUString::createFromAscii("'");
+ Reference< XStatement > xStmt = m_pConnection->createStatement();
+ if(xStmt.is())
+ {
+ Reference<XResultSet> xRes = xStmt->executeQuery(sUsers);
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if(xRes.is() && xRow.is() && xRes->next()) // there can only be one user with this name
+ {
+ static const ::rtl::OUString sDbaUser = ::rtl::OUString::createFromAscii("DBA");
+ if(xRow->getString(1) == sDbaUser)
+ {
+ ::comphelper::disposeComponent(xStmt);
+ m_pConnection->throwGenericSQLException(STR_USER_NO_DELETE,static_cast< XDrop* >( this ));
+ }
+ }
+ ::comphelper::disposeComponent(xStmt);
+ }
+ }
+
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP USER ");
+ ::rtl::OUString aQuote = m_pConnection->getMetaData()->getIdentifierQuoteString( );
+ aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_pConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/adabas/BViews.cxx b/connectivity/source/drivers/adabas/BViews.cxx
new file mode 100644
index 000000000000..4ba55d1da37d
--- /dev/null
+++ b/connectivity/source/drivers/adabas/BViews.cxx
@@ -0,0 +1,194 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BViews.hxx"
+#include "adabas/BTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/CheckOption.hpp>
+#include "adabas/BCatalog.hxx"
+#include "adabas/BConnection.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include "connectivity/sdbcx/VView.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace connectivity::adabas;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _rName.indexOf('.');
+ aSchema = _rName.copy(0,nLen);
+ aName = _rName.copy(nLen+1);
+
+ ::rtl::OUString sStmt = ::rtl::OUString::createFromAscii("SELECT DISTINCT * FROM DOMAIN.SHOW_VIEW WHERE ");
+ if(aSchema.getLength())
+ {
+ sStmt += ::rtl::OUString::createFromAscii("OWNER = '");
+ sStmt += aSchema;
+ sStmt += ::rtl::OUString::createFromAscii("' AND ");
+ }
+ sStmt += ::rtl::OUString::createFromAscii("VIEWNAME = '");
+ sStmt += aName;
+ sStmt += ::rtl::OUString::createFromAscii("'");
+ Reference<XConnection> xConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ Reference< XResultSet > xResult = xStmt->executeQuery(sStmt);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ connectivity::sdbcx::OView* pRet = new connectivity::sdbcx::OView(sal_True,
+ aName,
+ xConnection->getMetaData(),
+ CheckOption::NONE,
+ xRow->getString(3),
+ aSchema);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OViews::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OAdabasCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OViews::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OViews::createDescriptor()
+{
+ Reference<XConnection> xConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ return new connectivity::sdbcx::OView(sal_True,xConnection->getMetaData());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createView(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OViews::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ if(m_bInDrop)
+ return;
+
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+
+ ::rtl::OUString aName,aSchema;
+ sal_Int32 nLen = _sElementName.indexOf('.');
+ aSchema = _sElementName.copy(0,nLen);
+ aName = _sElementName.copy(nLen+1);
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP VIEW");
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+
+ aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aSchema + m_xMetaData->getIdentifierQuoteString( );
+ aSql = aSql + sDot;
+ aSql = aSql + m_xMetaData->getIdentifierQuoteString( ) + aName + m_xMetaData->getIdentifierQuoteString( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OViews::dropByNameImpl(const ::rtl::OUString& elementName)
+{
+ m_bInDrop = sal_True;
+ OCollection_TYPE::dropByName(elementName);
+ m_bInDrop = sal_False;
+}
+// -----------------------------------------------------------------------------
+void OViews::createView( const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE VIEW ");
+ ::rtl::OUString aQuote = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getIdentifierQuoteString( );
+ const ::rtl::OUString& sDot = OAdabasCatalog::getDot();
+ ::rtl::OUString sSchema,sCommand;
+
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME)) >>= sSchema;
+ if(sSchema.getLength())
+ aSql += ::dbtools::quoteName(aQuote, sSchema) + sDot;
+ else
+ descriptor->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCHEMANAME),makeAny(sSchema = static_cast<OAdabasCatalog&>(m_rParent).getConnection()->getMetaData()->getUserName()));
+
+ aSql += ::dbtools::quoteName(aQuote, getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))))
+ + ::rtl::OUString::createFromAscii(" AS ");
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
+ aSql += sCommand;
+
+ OAdabasConnection* pConnection = static_cast<OAdabasCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = pConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ // insert the new view also in the tables collection
+ OTables* pTables = static_cast<OTables*>(static_cast<OAdabasCatalog&>(m_rParent).getPrivateTables());
+ if(pTables)
+ {
+ ::rtl::OUString sName = sSchema;
+ sName += sDot;
+ sName += getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+ pTables->appendNew(sName);
+ }
+}
diff --git a/connectivity/source/drivers/adabas/Bservices.cxx b/connectivity/source/drivers/adabas/Bservices.cxx
new file mode 100644
index 000000000000..be1d716e8cd0
--- /dev/null
+++ b/connectivity/source/drivers/adabas/Bservices.cxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::adabas;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/adabas/adabas.mxp.map b/connectivity/source/drivers/adabas/adabas.mxp.map
new file mode 100644
index 000000000000..2ce9f111412b
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.mxp.map
@@ -0,0 +1,148 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_vec_delete
+___builtin_vec_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+_terminate__Fv
+dyld_stub_binding_helper
+rest_world
+save_world
+___eh_rtime_match
+__floatdisf
+___builtin_new
+___rtti_ptr
+___tf9bad_alloc
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+_release__Q312connectivity6adabas7ODriver
+_acquire__Q312connectivity6adabas7ODriver
+___Q312connectivity6adabas7ODriver
+_refreshUsers__Q312connectivity6adabas14OAdabasCatalog
+_refreshGroups__Q312connectivity6adabas14OAdabasCatalog
+_refreshViews__Q312connectivity6adabas14OAdabasCatalog
+_refreshTables__Q312connectivity6adabas14OAdabasCatalog
+__._Q312connectivity6adabas12OAdabasGroup
+_refreshUsers__Q312connectivity6adabas12OAdabasGroup
+__._Q312connectivity6adabas11OAdabasUser
+__._Q312connectivity6adabas11OUserExtend
+_construct__Q312connectivity6adabas11OUserExtend
+___Q312connectivity6adabas11OAdabasUserPQ312connectivity6adabas17OAdabasConnection
+__._Q312connectivity6adabas18UStringDescription
+___Q312connectivity6adabas18UStringDescriptionPFv_PCc
+__._Q312connectivity6adabas10OAdabasKey
+_refreshColumns__Q312connectivity6adabas10OAdabasKey
+__._Q312connectivity6adabas12OAdabasIndex
+_refreshColumns__Q312connectivity6adabas12OAdabasIndex
+__._Q312connectivity6adabas12OAdabasTable
+_release__Q312connectivity6adabas12OAdabasTable
+_acquire__Q312connectivity6adabas12OAdabasTable
+_refreshForgeinKeys__Q312connectivity6adabas12OAdabasTableRQ24_STLt6vector2ZQ23rtl8OUStringZQ24_STLt9allocator1ZB2
+_refreshPrimaryKeys__Q312connectivity6adabas12OAdabasTableRQ24_STLt6vector2ZQ23rtl8OUStringZQ24_STLt9allocator1ZB2
+_refreshIndexes__Q312connectivity6adabas12OAdabasTable
+_refreshKeys__Q312connectivity6adabas12OAdabasTable
+_refreshColumns__Q312connectivity6adabas12OAdabasTable
+_setComments__Q312connectivity6adabas7OTablesRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star5beans12XPropertySet
+__._Q312connectivity6adabas23OAdabasDatabaseMetaData
+__._Q312connectivity6adabas24OAdabasPreparedStatement
+__._Q312connectivity6adabas16OAdabasStatement
+__._Q312connectivity6adabas16OAdabasResultSet
+_initBoundParam__Q312connectivity4odbc18OPreparedStatement
+_setStream__Q312connectivity4odbc18OPreparedStatementlRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star2io12XInputStreamln2
+_setBinary__Q312connectivity4odbc18OPreparedStatementllRCQ53com3sun4star3unot8Sequence1ZSc
+_getLengthBuf__Q312connectivity4odbc18OPreparedStatementl
+_allocBindBuf__Q312connectivity4odbc18OPreparedStatementll
+_setChar__Q312connectivity4odbc18OPreparedStatementln2RCQ23rtl8OUString
+_putParamData__Q312connectivity4odbc18OPreparedStatementl
+_FreeParams__Q312connectivity4odbc18OPreparedStatement
+_prepareStatement__Q312connectivity4odbc18OPreparedStatement
+__._Q312connectivity4odbc18UStringDescription
+___Q312connectivity4odbc18UStringDescriptionPFv_PCc
+_disposing__Q312connectivity4odbc15OStatement_Base
+_release__Q312connectivity4odbc15OStatement_Base
+_acquire__Q312connectivity4odbc15OStatement_Base
+__._Q312connectivity4odbc16OStatement_BASE2
+__._Q312connectivity4odbc10OStatement
+_setFetchSize__Q312connectivity4odbc15OStatement_Basel
+_setCursorName__Q312connectivity4odbc15OStatement_BaseRCQ23rtl8OUString
+_setMaxRows__Q312connectivity4odbc15OStatement_Basel
+_setMaxFieldSize__Q312connectivity4odbc15OStatement_Basel
+_setQueryTimeOut__Q312connectivity4odbc15OStatement_Basel
+_isUsingBookmarks__CQ312connectivity4odbc15OStatement_Base
+_getFetchSize__CQ312connectivity4odbc15OStatement_Base
+_getFetchDirection__CQ312connectivity4odbc15OStatement_Base
+_getResultSetType__CQ312connectivity4odbc15OStatement_Base
+_getResultSetConcurrency__CQ312connectivity4odbc15OStatement_Base
+_getCursorName__CQ312connectivity4odbc15OStatement_Base
+_getMaxRows__CQ312connectivity4odbc15OStatement_Base
+_getMaxFieldSize__CQ312connectivity4odbc15OStatement_Base
+_getQueryTimeOut__CQ312connectivity4odbc15OStatement_Base
+_getStmtOption__CQ312connectivity4odbc15OStatement_Bases
+_getRowCount__Q312connectivity4odbc15OStatement_Base
+_lockIfNecessary__Q312connectivity4odbc15OStatement_BaseRCQ23rtl8OUString
+_setWarning__Q312connectivity4odbc15OStatement_BaseRCQ53com3sun4star4sdbc10SQLWarning
+_disposeResultSet__Q312connectivity4odbc15OStatement_Base
+_getCharColAttrib__Q312connectivity4odbc18OResultSetMetaDatall
+_getNumColAttrib__Q312connectivity4odbc18OResultSetMetaDatall
+_getResultSetType__CQ312connectivity4odbc10OResultSet
+_getResultSetConcurrency__CQ312connectivity4odbc10OResultSet
+_getCursorName__CQ312connectivity4odbc10OResultSet
+_isBookmarkable__CQ312connectivity4odbc10OResultSet
+_setFetchSize__Q312connectivity4odbc10OResultSetl
+_setFetchDirection__Q312connectivity4odbc10OResultSetl
+_getFetchSize__CQ312connectivity4odbc10OResultSet
+_getFetchDirection__CQ312connectivity4odbc10OResultSet
+_fillRow__Q312connectivity4odbc10OResultSetl
+_releaseBuffer__Q312connectivity4odbc10OResultSet
+_allocBuffer__Q312connectivity4odbc10OResultSetUc
+_jdbcTypeToOdbc__Q312connectivity4odbc6OToolsl
+_getPropertySetInfo__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_release__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_acquire__Q312connectivity4odbc26ODatabaseMetaDataResultSet
+_openSpecialColumns__Q312connectivity4odbc26ODatabaseMetaDataResultSetUcRCQ53com3sun4star3uno3AnyRCQ23rtl8OUStringn1lUc
+_getResultSetType__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getResultSetConcurrency__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getCursorName__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getFetchSize__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getFetchDirection__CQ312connectivity4odbc26ODatabaseMetaDataResultSet
+_getSupportedServiceNames_Static__Q312connectivity4odbc10ODBCDriver
+_getImplementationName_Static__Q312connectivity4odbc10ODBCDriver
+_LoadFunctions__12connectivityP10_oslModuleUc
+_OpenConnection__Q312connectivity4odbc11OConnectionRCQ23rtl8OUStringlUc
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/adabas/adabas.xcu b/connectivity/source/drivers/adabas/adabas.xcu
new file mode 100755
index 000000000000..b92067235e15
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.xcu
@@ -0,0 +1,130 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:adabas:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbcx.adabas.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Adabas D</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="ShutdownDatabase" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="DataCacheSizeIncrement" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>20</value>
+ </prop>
+ </node>
+ <node oor:name="DataCacheSize" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>20</value>
+ </prop>
+ </node>
+ <node oor:name="ControlUser" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="ControlPassword" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/adabas/adabas.xml b/connectivity/source/drivers/adabas/adabas.xml
new file mode 100644
index 000000000000..ce1b0f84755b
--- /dev/null
+++ b/connectivity/source/drivers/adabas/adabas.xml
@@ -0,0 +1,27 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>adabas</module-name>
+ <component-description>
+ <author>Ocke Janssen</Author>
+ <name>com.sun.star.comp.sdbcx.adabas.ODriver</name>
+ <description>
+ This is the implementation of the sdbc-adabas bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/adabas/exports.dxp b/connectivity/source/drivers/adabas/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/adabas/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/adabas/makefile.mk b/connectivity/source/drivers/adabas/makefile.mk
new file mode 100644
index 000000000000..9268f02a3b42
--- /dev/null
+++ b/connectivity/source/drivers/adabas/makefile.mk
@@ -0,0 +1,106 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=adabas
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(SYSTEM_ODBC_HEADERS)" == "YES"
+CFLAGS+=-DSYSTEM_ODBC_HEADERS
+.ENDIF
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/BFunctions.obj \
+ $(SLO)$/BConnection.obj \
+ $(SLO)$/BDriver.obj \
+ $(SLO)$/BCatalog.obj \
+ $(SLO)$/BGroups.obj \
+ $(SLO)$/BGroup.obj \
+ $(SLO)$/BUser.obj \
+ $(SLO)$/BUsers.obj \
+ $(SLO)$/BKeys.obj \
+ $(SLO)$/BColumns.obj \
+ $(SLO)$/BIndex.obj \
+ $(SLO)$/BIndexColumns.obj \
+ $(SLO)$/BIndexes.obj \
+ $(SLO)$/BTable.obj \
+ $(SLO)$/BTables.obj \
+ $(SLO)$/BViews.obj \
+ $(SLO)$/Bservices.obj \
+ $(SLO)$/BDatabaseMetaData.obj \
+ $(SLO)$/BPreparedStatement.obj \
+ $(SLO)$/BStatement.obj \
+ $(SLO)$/BResultSetMetaData.obj \
+ $(SLO)$/BResultSet.obj
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(TOOLSLIB) \
+ $(ODBCBASELIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(ODBCBASELIB)" == ""
+SHL1STDLIBS+=$(ODBCBASELIB)
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ----------------------------------
+
+
+.INCLUDE : $(PRJ)$/target.pmk
diff --git a/connectivity/source/drivers/ado/ACallableStatement.cxx b/connectivity/source/drivers/ado/ACallableStatement.cxx
new file mode 100644
index 000000000000..f4739f3ab3ea
--- /dev/null
+++ b/connectivity/source/drivers/ado/ACallableStatement.cxx
@@ -0,0 +1,235 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ACallableStatement.hxx"
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+
+IMPLEMENT_SERVICE_INFO(OCallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
+
+#define GET_PARAM() \
+ ADOParameter* pParam = NULL; \
+ m_pParameters->get_Item(OLEVariant(sal_Int32(columnIndex-1)),&pParam); \
+ if(pParam) \
+ pParam->get_Value(&m_aValue);
+//**************************************************************
+//************ Class: java.sql.CallableStatement
+//**************************************************************
+OCallableStatement::OCallableStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql )
+ : OPreparedStatement( _pConnection, _TypeInfo, sql )
+{
+ m_Command.put_CommandType(adCmdStoredProc);
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OCallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPreparedStatement::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< XRow*>(this));
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL OCallableStatement::wasNull( ) throw(SQLException, RuntimeException)
+{
+ return m_aValue.isNull();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OCallableStatement::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL OCallableStatement::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OCallableStatement::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL OCallableStatement::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+double SAL_CALL OCallableStatement::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OCallableStatement::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OCallableStatement::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OCallableStatement::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return (sal_Int64)m_aValue.getCurrency().int64;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OCallableStatement::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getObject", *this );
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OCallableStatement::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OCallableStatement::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+ ::com::sun::star::util::Time SAL_CALL OCallableStatement::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+ ::com::sun::star::util::DateTime SAL_CALL OCallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ GET_PARAM()
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OCallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ ADOParameter* pParam = NULL;
+ m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
+ if(pParam)
+ {
+ pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
+ pParam->put_Direction(adParamOutput);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ ADOParameter* pParam = NULL;
+ m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
+ if(pParam)
+ {
+ pParam->put_Type(ADOS::MapJdbc2ADOType(sqlType,m_pConnection->getEngineType()));
+ pParam->put_Direction(adParamOutput);
+ pParam->put_NumericScale((sal_Int8)scale);
+ }
+}
+// -------------------------------------------------------------------------
+
+
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getBinaryStream", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OCallableStatement::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XArray > SAL_CALL OCallableStatement::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OCallableStatement::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OCallableStatement::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OCallableStatement::getRef( sal_Int32 /*columnIndex*/) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OCallableStatement::acquire() throw()
+{
+ OPreparedStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCallableStatement::release() throw()
+{
+ OPreparedStatement::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/ACatalog.cxx b/connectivity/source/drivers/ado/ACatalog.cxx
new file mode 100644
index 000000000000..d73ac4746fa3
--- /dev/null
+++ b/connectivity/source/drivers/ado/ACatalog.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ACatalog.hxx"
+#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
+#include "ado/AConnection.hxx"
+#endif
+#include "ado/AGroups.hxx"
+#include "ado/AUsers.hxx"
+#include "ado/ATables.hxx"
+#include "ado/AViews.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::ado;
+// -------------------------------------------------------------------------
+OCatalog::OCatalog(_ADOCatalog* _pCatalog,OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_aCatalog(_pCatalog)
+{
+}
+// -----------------------------------------------------------------------------
+OCatalog::~OCatalog()
+{
+ if(m_aCatalog.IsValid())
+ m_aCatalog.putref_ActiveConnection(NULL);
+ m_aCatalog.clear();
+}
+// -----------------------------------------------------------------------------
+void OCatalog::refreshTables()
+{
+ TStringVector aVector;
+
+ WpADOTables aTables(m_aCatalog.get_Tables());
+ if ( aTables.IsValid() )
+ {
+ aTables.Refresh();
+ sal_Int32 nCount = aTables.GetItemCount();
+ aVector.reserve(nCount);
+ for(sal_Int32 i=0;i< nCount;++i)
+ {
+ WpADOTable aElement = aTables.GetItem(i);
+ if ( aElement.IsValid() )
+ {
+ ::rtl::OUString sTypeName = aElement.get_Type();
+ if ( !sTypeName.equalsIgnoreAsciiCaseAscii("SYSTEM TABLE") && !sTypeName.equalsIgnoreAsciiCaseAscii("ACCESS TABLE") )
+ aVector.push_back(aElement.get_Name());
+ }
+ }
+ }
+
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(this,m_aMutex,aVector,aTables,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers());
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshViews()
+{
+ TStringVector aVector;
+
+ WpADOViews aViews = m_aCatalog.get_Views();
+ aViews.fillElementNames(aVector);
+
+ if(m_pViews)
+ m_pViews->reFill(aVector);
+ else
+ m_pViews = new OViews(this,m_aMutex,aVector,aViews,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers());
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshGroups()
+{
+ TStringVector aVector;
+
+ WpADOGroups aGroups = m_aCatalog.get_Groups();
+ aGroups.fillElementNames(aVector);
+
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(this,m_aMutex,aVector,aGroups,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers());
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshUsers()
+{
+ TStringVector aVector;
+
+ WpADOUsers aUsers = m_aCatalog.get_Users();
+ aUsers.fillElementNames(aVector);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(this,m_aMutex,aVector,aUsers,m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers());
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AColumn.cxx b/connectivity/source/drivers/ado/AColumn.cxx
new file mode 100644
index 000000000000..aa287c185b26
--- /dev/null
+++ b/connectivity/source/drivers/ado/AColumn.cxx
@@ -0,0 +1,300 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AColumn.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/Awrapado.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "ado/ACatalog.hxx"
+
+using namespace ::comphelper;
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+void WpADOColumn::Create()
+{
+ HRESULT hr = -1;
+
+ _ADOColumn* pColumn = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOCOLUMN_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOCOLUMN_25,
+ (void**)&pColumn );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pColumn );
+ pColumn->Release( );
+ }
+}
+// -------------------------------------------------------------------------
+OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection,_ADOColumn* _pColumn)
+ : connectivity::sdbcx::OColumn(::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),::rtl::OUString(),0,0,0,0,sal_False,sal_False,sal_False,_bCase)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ OSL_ENSURE(_pColumn,"Column can not be null!");
+ m_aColumn = WpADOColumn(_pColumn);
+ // m_aColumn.put_ParentCatalog(_pConnection->getAdoCatalog()->getCatalog());
+ fillPropertyValues();
+}
+// -------------------------------------------------------------------------
+OAdoColumn::OAdoColumn(sal_Bool _bCase,OConnection* _pConnection)
+ : connectivity::sdbcx::OColumn(_bCase)
+ ,m_pConnection(_pConnection)
+{
+ m_aColumn.Create();
+ m_aColumn.put_ParentCatalog(_pConnection->getAdoCatalog()->getCatalog());
+ construct();
+ fillPropertyValues();
+ m_Type = DataType::OTHER;
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoColumn::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoColumn::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OColumn_ADO::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+void OAdoColumn::construct()
+{
+ sal_Int32 nAttrib = isNew() ? 0 : PropertyAttribute::READONLY;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISASCENDING), PROPERTY_ID_ISASCENDING, nAttrib,&m_IsAscending, ::getBooleanCppuType());
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN), PROPERTY_ID_RELATEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+void OAdoColumn::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aColumn.IsValid())
+ {
+ const sal_Char* pAdoPropertyName = NULL;
+
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISASCENDING:
+ m_aColumn.put_SortOrder(::cppu::any2bool(rValue) ? adSortAscending : adSortDescending);
+ break;
+ case PROPERTY_ID_RELATEDCOLUMN:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aColumn.put_RelatedColumn(aVal);
+ }
+ break;
+ case PROPERTY_ID_NAME:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aColumn.put_Name(aVal);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aColumn.put_Type(ADOS::MapJdbc2ADOType(nVal,m_pConnection->getEngineType()));
+ }
+ break;
+ case PROPERTY_ID_TYPENAME:
+ // rValue <<= m_pTable->getCatalog()->getConnection()->getTypeInfo()->find();
+ break;
+ case PROPERTY_ID_PRECISION:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aColumn.put_Precision(nVal);
+ }
+ break;
+ case PROPERTY_ID_SCALE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aColumn.put_NumericScale((sal_Int8)nVal);
+ }
+ break;
+ case PROPERTY_ID_ISNULLABLE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ if ( nVal == ColumnValue::NULLABLE )
+ m_aColumn.put_Attributes( adColNullable );
+ }
+ break;
+ case PROPERTY_ID_ISROWVERSION:
+ break;
+
+ case PROPERTY_ID_ISAUTOINCREMENT:
+ OTools::putValue( m_aColumn.get_Properties(), ::rtl::OUString::createFromAscii( "Autoincrement" ), getBOOL( rValue ) );
+ break;
+
+ case PROPERTY_ID_IM001:
+ case PROPERTY_ID_DESCRIPTION:
+ pAdoPropertyName = "Description";
+ break;
+
+ case PROPERTY_ID_DEFAULTVALUE:
+ pAdoPropertyName = "Default";
+ break;
+ }
+
+ if ( pAdoPropertyName )
+ OTools::putValue( m_aColumn.get_Properties(), ::rtl::OUString::createFromAscii( pAdoPropertyName ), getString( rValue ) );
+ }
+ OColumn_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+}
+// -----------------------------------------------------------------------------
+void OAdoColumn::fillPropertyValues()
+{
+ if(m_aColumn.IsValid())
+ {
+ m_IsAscending = m_aColumn.get_SortOrder() == adSortAscending;
+ m_ReferencedColumn = m_aColumn.get_RelatedColumn();
+ m_Name = m_aColumn.get_Name();
+ m_Precision = m_aColumn.get_Precision();
+ m_Scale = m_aColumn.get_NumericScale();
+ m_IsNullable = ((m_aColumn.get_Attributes() & adColNullable) == adColNullable) ? ColumnValue::NULLABLE : ColumnValue::NO_NULLS;
+
+ DataTypeEnum eType = m_aColumn.get_Type();
+ m_IsCurrency = (eType == adCurrency);
+ m_Type = ADOS::MapADOType2Jdbc(eType);
+
+ sal_Bool bForceTo = sal_True;
+ const OTypeInfoMap* pTypeInfoMap = m_pConnection->getTypeInfo();
+ const OExtendedTypeInfo* pTypeInfo = OConnection::getTypeInfoFromType(*m_pConnection->getTypeInfo(),eType,::rtl::OUString(),m_Precision,m_Scale,bForceTo);
+ if ( pTypeInfo )
+ m_TypeName = pTypeInfo->aSimpleType.aTypeName;
+ else if ( eType == adVarBinary && ADOS::isJetEngine(m_pConnection->getEngineType()) )
+ {
+ ::comphelper::TStringMixEqualFunctor aCase(sal_False);
+ OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(),
+ pTypeInfoMap->end(),
+ ::std::compose1(
+ ::std::bind2nd(aCase, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VarBinary"))),
+ ::std::compose1(
+ ::std::mem_fun(&OExtendedTypeInfo::getDBName),
+ ::std::select2nd<OTypeInfoMap::value_type>())
+ )
+
+ );
+
+ if ( aFind != pTypeInfoMap->end() ) // change column type if necessary
+ {
+ eType = aFind->first;
+ pTypeInfo = aFind->second;
+ }
+
+ if ( !pTypeInfo )
+ {
+ pTypeInfo = OConnection::getTypeInfoFromType(*m_pConnection->getTypeInfo(),adBinary,::rtl::OUString(),m_Precision,m_Scale,bForceTo);
+ eType = adBinary;
+ }
+
+ if ( pTypeInfo )
+ {
+ m_TypeName = pTypeInfo->aSimpleType.aTypeName;
+ m_Type = ADOS::MapADOType2Jdbc(eType);
+ }
+ }
+
+
+ // fill some specific props
+ {
+ WpADOProperties aProps( m_aColumn.get_Properties() );
+
+ if ( aProps.IsValid() )
+ {
+ m_IsAutoIncrement = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Autoincrement")) );
+
+ m_Description = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")) );
+
+ m_DefaultValue = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Default")) );
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nCount = aProps.GetItemCount();
+ for (sal_Int32 i = 0; i<nCount; ++i)
+ {
+ WpADOProperty aProp = aProps.GetItem(i);
+ ::rtl::OUString sName = aProp.GetName();
+ ::rtl::OUString sVal = aProp.GetValue();
+ }
+#endif
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+WpADOColumn OAdoColumn::getColumnImpl() const
+{
+ return m_aColumn;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoColumn::acquire() throw()
+{
+ OColumn_ADO::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoColumn::release() throw()
+{
+ OColumn_ADO::release();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/AColumns.cxx b/connectivity/source/drivers/ado/AColumns.cxx
new file mode 100644
index 000000000000..b2e383f53e0d
--- /dev/null
+++ b/connectivity/source/drivers/ado/AColumns.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AColumns.hxx"
+#include "ado/AColumn.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/Awrapado.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#ifdef __MINGW32__
+#include <algorithm>
+#endif
+#include "resource/ado_res.hrc"
+
+using namespace connectivity::ado;
+using namespace connectivity;
+using namespace comphelper;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdoColumn(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName));
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OColumns::createDescriptor()
+{
+ return new OAdoColumn(isCaseSensitive(),m_pConnection);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OColumns::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor )
+{
+ OAdoColumn* pColumn = NULL;
+ if ( !getImplementation( pColumn, descriptor ) || pColumn == NULL )
+ m_pConnection->throwGenericSQLException( STR_INVALID_COLUMN_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ WpADOColumn aColumn = pColumn->getColumnImpl();
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nPrecision;
+ sal_Int32 nScale;
+ sal_Int32 nType;
+ nPrecision = aColumn.get_Precision();
+ nScale = aColumn.get_NumericScale();
+ nType = ADOS::MapADOType2Jdbc(aColumn.get_Type());
+#endif
+
+ ::rtl::OUString sTypeName;
+ pColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName;
+
+ const OTypeInfoMap* pTypeInfoMap = m_pConnection->getTypeInfo();
+ ::comphelper::TStringMixEqualFunctor aCase(sal_False);
+ // search for typeinfo where the typename is equal sTypeName
+ OTypeInfoMap::const_iterator aFind = ::std::find_if(pTypeInfoMap->begin(),
+ pTypeInfoMap->end(),
+ ::std::compose1(
+ ::std::bind2nd(aCase, sTypeName),
+ ::std::compose1(
+ ::std::mem_fun(&OExtendedTypeInfo::getDBName),
+ ::std::select2nd<OTypeInfoMap::value_type>())
+ )
+
+ );
+
+ if ( aFind != pTypeInfoMap->end() ) // change column type if necessary
+ aColumn.put_Type(aFind->first);
+
+ if ( SUCCEEDED(((ADOColumns*)m_aCollection)->Append(OLEVariant(aColumn.get_Name()),aColumn.get_Type(),aColumn.get_DefinedSize())) )
+ {
+ WpADOColumn aAddedColumn = m_aCollection.GetItem(OLEVariant(aColumn.get_Name()));
+ if ( aAddedColumn.IsValid() )
+ {
+ sal_Bool bAutoIncrement = sal_False;
+ pColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
+ if ( bAutoIncrement )
+ OTools::putValue( aAddedColumn.get_Properties(), ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Autoincrement")), bAutoIncrement );
+
+ if ( aFind != pTypeInfoMap->end() && aColumn.get_Type() != aAddedColumn.get_Type() ) // change column type if necessary
+ aColumn.put_Type(aFind->first);
+ aAddedColumn.put_Precision(aColumn.get_Precision());
+ aAddedColumn.put_NumericScale(aColumn.get_NumericScale());
+ aAddedColumn.put_Attributes(aColumn.get_Attributes());
+ aAddedColumn.put_SortOrder(aColumn.get_SortOrder());
+ aAddedColumn.put_RelatedColumn(aColumn.get_RelatedColumn());
+ }
+ }
+ ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this));
+
+ return new OAdoColumn(isCaseSensitive(),m_pConnection,pColumn->getColumnImpl());
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OColumns::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ if(!m_aCollection.Delete(_sElementName))
+ ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this));
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/AConnection.cxx b/connectivity/source/drivers/ado/AConnection.cxx
new file mode 100644
index 000000000000..a7e2ec4df490
--- /dev/null
+++ b/connectivity/source/drivers/ado/AConnection.cxx
@@ -0,0 +1,625 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/ADatabaseMetaData.hxx"
+#include "ado/ADriver.hxx"
+#include "ado/AStatement.hxx"
+#include "ado/ACallableStatement.hxx"
+#include "ado/APreparedStatement.hxx"
+#include "ado/ACatalog.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbexception.hxx"
+#include <osl/file.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace dbtools;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection,"com.sun.star.sdbcx.AConnection","com.sun.star.sdbc.Connection");
+// --------------------------------------------------------------------------------
+OConnection::OConnection(ODriver* _pDriver) throw(SQLException, RuntimeException)
+ : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
+ m_bClosed(sal_False),
+ m_xCatalog(NULL),
+ m_pDriver(_pDriver),
+ m_pAdoConnection(NULL),
+ m_bAutocommit(sal_True),
+ m_nEngineType(0),
+ m_pCatalog(NULL)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ IClassFactory2* pIUnknown = NULL;
+ IUnknown *pOuter = NULL;
+ HRESULT hr;
+ hr = CoGetClassObject( ADOS::CLSID_ADOCONNECTION_21,
+ CLSCTX_INPROC_SERVER,
+ NULL,
+ IID_IClassFactory2,
+ (void**)&pIUnknown );
+
+ if( !FAILED( hr ) )
+ {
+ ADOConnection *pCon = NULL;
+ hr = pIUnknown->CreateInstanceLic( pOuter,
+ NULL,
+ ADOS::IID_ADOCONNECTION_21,
+ ADOS::GetKeyStr(),
+ (void**) &pCon);
+
+ if( !FAILED( hr ) )
+ {
+ OSL_ENSURE( pCon, "OConnection::OConnection: invalid ADO object!" );
+
+ m_pAdoConnection = new WpADOConnection( pCon );
+ // CreateInstanceLic returned an object which was already acquired
+ pCon->Release( );
+
+ }
+
+ // Class Factory is no longer needed
+ pIUnknown->Release();
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+}
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ setConnectionInfo(info);
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
+ if ( aDSN.compareToAscii("access:",7) == 0 )
+ aDSN = aDSN.copy(7);
+
+ sal_Int32 nTimeout = 20;
+ sal_Bool bSilent = sal_True;
+ const PropertyValue *pIter = info.getConstArray();
+ const PropertyValue *pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(!pIter->Name.compareToAscii("Timeout"))
+ pIter->Value >>= nTimeout;
+ else if(!pIter->Name.compareToAscii("Silent"))
+ pIter->Value >>= bSilent;
+ else if(!pIter->Name.compareToAscii("user"))
+ pIter->Value >>= aUID;
+ else if(!pIter->Name.compareToAscii("password"))
+ pIter->Value >>= aPWD;
+ }
+ try
+ {
+ if(m_pAdoConnection)
+ {
+ if(m_pAdoConnection->Open(aDSN,aUID,aPWD,adConnectUnspecified))
+ m_pAdoConnection->PutCommandTimeout(nTimeout);
+ else
+ ADOS::ThrowException(*m_pAdoConnection,*this);
+ if(m_pAdoConnection->get_State() != adStateOpen)
+ throwGenericSQLException( STR_NO_CONNECTION,*this );
+
+ WpADOProperties aProps = m_pAdoConnection->get_Properties();
+ if(aProps.IsValid())
+ {
+ OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
+ OLEVariant aVar(OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:Engine Type"))));
+ if(!aVar.isNull() && !aVar.isEmpty())
+ m_nEngineType = aVar;
+ }
+ buildTypeInfo();
+ //bErg = TRUE;
+ }
+ else
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ }
+ catch(const Exception )
+ {
+ osl_decrementInterlockedCount( &m_refCount );
+ throw;
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ OStatement* pStmt = new OStatement(this);
+ Reference< XStatement > xStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OPreparedStatement* pStmt = new OPreparedStatement(this,m_aTypeInfo,sql);
+ Reference< XPreparedStatement > xPStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xPStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OCallableStatement* pStmt = new OCallableStatement(this,m_aTypeInfo,sql);
+ Reference< XPreparedStatement > xPStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xPStmt;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ ::rtl::OUString sql = _sql;
+ WpADOProperties aProps = m_pAdoConnection->get_Properties();
+ if(aProps.IsValid())
+ {
+ OTools::putValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Jet OLEDB:ODBC Parsing")),sal_True);
+ WpADOCommand aCommand;
+ aCommand.Create();
+ aCommand.put_ActiveConnection((IDispatch*)*m_pAdoConnection);
+ aCommand.put_CommandText(sql);
+ sql = aCommand.get_CommandText();
+ }
+
+ return sql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ m_bAutocommit = autoCommit;
+ if(!autoCommit)
+ m_pAdoConnection->BeginTrans();
+ else
+ m_pAdoConnection->RollbackTrans();
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return m_bAutocommit;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ m_pAdoConnection->CommitTrans();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ m_pAdoConnection->RollbackTrans();
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OConnection_BASE::rBHelper.bDisposed && !m_pAdoConnection->get_State();
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+
+ m_pAdoConnection->put_Mode(readOnly ? adModeRead : adModeReadWrite);
+ ADOS::ThrowException(*m_pAdoConnection,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return m_pAdoConnection->get_Mode() == adModeRead;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ m_pAdoConnection->PutDefaultDatabase(catalog);
+ ADOS::ThrowException(*m_pAdoConnection,*this);
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ return m_pAdoConnection->GetDefaultDatabase();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ IsolationLevelEnum eIso;
+ switch(level)
+ {
+ case TransactionIsolation::NONE:
+ eIso = adXactUnspecified;
+ break;
+ case TransactionIsolation::READ_UNCOMMITTED:
+ eIso = adXactReadUncommitted;
+ break;
+ case TransactionIsolation::READ_COMMITTED:
+ eIso = adXactReadCommitted;
+ break;
+ case TransactionIsolation::REPEATABLE_READ:
+ eIso = adXactRepeatableRead;
+ break;
+ case TransactionIsolation::SERIALIZABLE:
+ eIso = adXactSerializable;
+ break;
+ default:
+ OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
+ return;
+ }
+ m_pAdoConnection->put_IsolationLevel(eIso);
+ ADOS::ThrowException(*m_pAdoConnection,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nRet = 0;
+ switch(m_pAdoConnection->get_IsolationLevel())
+ {
+ case adXactUnspecified:
+ nRet = TransactionIsolation::NONE;
+ break;
+ case adXactReadUncommitted:
+ nRet = TransactionIsolation::READ_UNCOMMITTED;
+ break;
+ case adXactReadCommitted:
+ nRet = TransactionIsolation::READ_COMMITTED;
+ break;
+ case adXactRepeatableRead:
+ nRet = TransactionIsolation::REPEATABLE_READ;
+ break;
+ case adXactSerializable:
+ nRet = TransactionIsolation::SERIALIZABLE;
+ break;
+ default:
+ OSL_ENSURE(0,"OConnection::setTransactionIsolation invalid level");
+ }
+ ADOS::ThrowException(*m_pAdoConnection,*this);
+ return nRet;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+//--------------------------------------------------------------------
+void OConnection::buildTypeInfo() throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ADORecordset *pRecordset = m_pAdoConnection->getTypeInfo();
+ if ( pRecordset )
+ {
+ pRecordset->AddRef();
+ VARIANT_BOOL bIsAtBOF;
+ pRecordset->get_BOF(&bIsAtBOF);
+
+ sal_Bool bOk = sal_True;
+ if ( bIsAtBOF == VARIANT_TRUE )
+ bOk = SUCCEEDED(pRecordset->MoveNext());
+
+ if ( bOk )
+ {
+ // HACK for access
+ static const ::rtl::OUString s_sVarChar(RTL_CONSTASCII_USTRINGPARAM("VarChar"));
+ do
+ {
+ sal_Int32 nPos = 1;
+ OExtendedTypeInfo* aInfo = new OExtendedTypeInfo();
+ aInfo->aSimpleType.aTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->eType = (DataTypeEnum)(sal_Int32)ADOS::getField(pRecordset,nPos++).get_Value();
+ if ( aInfo->eType == adWChar && aInfo->aSimpleType.aTypeName == s_sVarChar )
+ aInfo->eType = adVarWChar;
+ aInfo->aSimpleType.nType = (sal_Int16)ADOS::MapADOType2Jdbc(static_cast<DataTypeEnum>(aInfo->eType));
+ aInfo->aSimpleType.nPrecision = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.aLiteralPrefix = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.aLiteralSuffix = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.aCreateParams = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.bNullable = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.bCaseSensitive = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.nSearchType = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.bUnsigned = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.bCurrency = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.bAutoIncrement = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.aLocalTypeName = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.nMinimumScale = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.nMaximumScale = ADOS::getField(pRecordset,nPos++).get_Value();
+ aInfo->aSimpleType.nNumPrecRadix = ADOS::getField(pRecordset,nPos++).get_Value();
+ // Now that we have the type info, save it
+ // in the Hashtable if we don't already have an
+ // entry for this SQL type.
+
+ m_aTypeInfo.insert(OTypeInfoMap::value_type(aInfo->eType,aInfo));
+ }
+ while ( SUCCEEDED(pRecordset->MoveNext()) );
+ }
+ pRecordset->Release();
+ }
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OConnection_BASE::disposing();
+
+ m_bClosed = sal_True;
+ m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
+ m_xCatalog = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbcx::XTablesSupplier>();
+ m_pDriver = NULL;
+
+ m_pAdoConnection->Close();
+
+ OTypeInfoMap::iterator aIter = m_aTypeInfo.begin();
+ for (; aIter != m_aTypeInfo.end(); ++aIter)
+ delete aIter->second;
+
+ m_aTypeInfo.clear();
+
+ delete m_pAdoConnection;
+ m_pAdoConnection = NULL;
+
+ dispose_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OConnection::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ?
+ reinterpret_cast< sal_Int64 >( this )
+ :
+ OConnection_BASE::getSomething(rId);
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -----------------------------------------------------------------------------
+const OExtendedTypeInfo* OConnection::getTypeInfoFromType(const OTypeInfoMap& _rTypeInfo,
+ DataTypeEnum _nType,
+ const ::rtl::OUString& _sTypeName,
+ sal_Int32 _nPrecision,
+ sal_Int32 _nScale,
+ sal_Bool& _brForceToType)
+{
+ const OExtendedTypeInfo* pTypeInfo = NULL;
+ _brForceToType = sal_False;
+ // search for type
+ ::std::pair<OTypeInfoMap::const_iterator, OTypeInfoMap::const_iterator> aPair = _rTypeInfo.equal_range(_nType);
+ OTypeInfoMap::const_iterator aIter = aPair.first;
+ if(aIter != _rTypeInfo.end()) // compare with end is correct here
+ {
+ for(;aIter != aPair.second;++aIter)
+ {
+ // search the best matching type
+ OExtendedTypeInfo* pInfo = aIter->second;
+ #ifdef DBG_UTIL
+ ::rtl::OUString sDBTypeName = pInfo->aSimpleType.aTypeName;
+ sal_Int32 nDBTypePrecision = pInfo->aSimpleType.nPrecision; (void)nDBTypePrecision;
+ sal_Int32 nDBTypeScale = pInfo->aSimpleType.nMaximumScale; (void)nDBTypeScale;
+ sal_Int32 nAdoType = pInfo->eType; (void)nAdoType;
+ #endif
+ if ( ( !_sTypeName.getLength()
+ || (pInfo->aSimpleType.aTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ )
+ && (pInfo->aSimpleType.nPrecision >= _nPrecision)
+ && (pInfo->aSimpleType.nMaximumScale >= _nScale)
+
+ )
+ break;
+ }
+
+ if (aIter == aPair.second)
+ {
+ for(aIter = aPair.first; aIter != aPair.second; ++aIter)
+ {
+ // search the best matching type (now comparing the local names)
+ if ( (aIter->second->aSimpleType.aLocalTypeName.equalsIgnoreAsciiCase(_sTypeName))
+ && (aIter->second->aSimpleType.nPrecision >= _nPrecision)
+ && (aIter->second->aSimpleType.nMaximumScale >= _nScale)
+ )
+ {
+// we can not assert here because we could be in d&d
+/*
+ OSL_ENSURE(sal_False,
+ ( ::rtl::OString("getTypeInfoFromType: assuming column type ")
+ += ::rtl::OString(aIter->second->aTypeName.getStr(), aIter->second->aTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString("\" (expected type name ")
+ += ::rtl::OString(_sTypeName.getStr(), _sTypeName.getLength(), gsl_getSystemTextEncoding())
+ += ::rtl::OString(" matches the type's local name).")).getStr());
+*/
+ break;
+ }
+ }
+ }
+
+ if (aIter == aPair.second)
+ { // no match for the names, no match for the local names
+ // -> drop the precision and the scale restriction, accept any type with the property
+ // type id (nType)
+
+ // we can not assert here because we could be in d&d
+ pTypeInfo = aPair.first->second;
+ _brForceToType = sal_True;
+ }
+ else
+ pTypeInfo = aIter->second;
+ }
+ else if ( _sTypeName.getLength() )
+ {
+ ::comphelper::TStringMixEqualFunctor aCase(sal_False);
+ // search for typeinfo where the typename is equal _sTypeName
+ OTypeInfoMap::const_iterator aFind = ::std::find_if(_rTypeInfo.begin(),
+ _rTypeInfo.end(),
+ ::std::compose1(
+ ::std::bind2nd(aCase, _sTypeName),
+ ::std::compose1(
+ ::std::mem_fun(&OExtendedTypeInfo::getDBName),
+ ::std::select2nd<OTypeInfoMap::value_type>())
+ )
+ );
+ if(aFind != _rTypeInfo.end())
+ pTypeInfo = aFind->second;
+ }
+
+// we can not assert here because we could be in d&d
+// OSL_ENSURE(pTypeInfo, "getTypeInfoFromType: no type info found for this type!");
+ return pTypeInfo;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx
new file mode 100644
index 000000000000..022295710595
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADatabaseMetaData.cxx
@@ -0,0 +1,1093 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ADatabaseMetaData.hxx"
+#include "ado/ADatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include "ado/AConnection.hxx"
+#include "ado/adoimp.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+
+// using namespace connectivity;
+
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
+ : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_pADOConnection(_pCon->getConnection())
+ ,m_pConnection(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::getInt32Property(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties());
+ // ADOS::ThrowException(*m_pADOConnection,*this);
+ OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection");
+ ADO_PROP(_aProperty);
+ sal_Int32 nValue(0);
+ if(!aVar.isNull() && !aVar.isEmpty())
+ nValue = aVar;
+ return nValue;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::getBoolProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties());
+ ADOS::ThrowException(*m_pADOConnection,*this);
+ OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection");
+ ADO_PROP(_aProperty);
+ return (!aVar.isNull() && !aVar.isEmpty() ? aVar.getBool() : sal_False);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::getStringProperty(const ::rtl::OUString& _aProperty) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ connectivity::ado::WpADOProperties aProps(m_pADOConnection->get_Properties());
+ ADOS::ThrowException(*m_pADOConnection,*this);
+ OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection");
+
+ ADO_PROP(_aProperty);
+ ::rtl::OUString aValue;
+ if(!aVar.isNull() && !aVar.isEmpty() && aVar.getType() == VT_BSTR)
+ aValue = aVar;
+
+ return aValue;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ ADORecordset *pRecordset = m_pADOConnection->getTypeInfo();
+ // ADOS::ThrowException(*m_pADOConnection,*this);
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setTypeInfoMap(ADOS::isJetEngine(m_pConnection->getEngineType()));
+ Reference< XResultSet > xRef = pResult;
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ ADORecordset *pRecordset = NULL;
+ m_pADOConnection->OpenSchema(adSchemaCatalogs,vtEmpty,vtEmpty,&pRecordset);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setCatalogsMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ return getLiteral(DBLITERAL_CATALOG_SEPARATOR);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ ADORecordset *pRecordset = NULL;
+ m_pADOConnection->OpenSchema(adSchemaSchemata,vtEmpty,vtEmpty,&pRecordset);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setSchemasMap();
+ xRef = pResult;
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getColumnPrivileges(catalog,schema,table,columnNamePattern);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setColumnPrivilegesMap();
+ xRef = pResult;
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getColumns(catalog,schemaPattern,tableNamePattern,columnNamePattern);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setColumnsMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getTables(catalog,schemaPattern,tableNamePattern,types);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setTablesMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getProcedureColumns(catalog,schemaPattern,procedureNamePattern,columnNamePattern);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setProcedureColumnsMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
+{
+ // Create elements used in the array
+ ADORecordset *pRecordset = m_pADOConnection->getProcedures(catalog,schemaPattern,procedureNamePattern);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setProceduresMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_BINARY_LITERAL);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Maximum Row Size"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_CATALOG_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_CHAR_LITERAL);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_COLUMN_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ // return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Index"));
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_CURSOR_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Active Sessions"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Table"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_TEXT_COMMAND);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_TABLE_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Maximum Tables in SELECT"));
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getExportedKeys(catalog,schema,table);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setCrossReferenceMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getImportedKeys(catalog,schema,table);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setCrossReferenceMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getPrimaryKeys(catalog,schema,table);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setPrimaryKeysMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getIndexInfo(catalog,schema,table,unique,approximate);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setIndexInfoMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ if(!ADOS::isJetEngine(m_pConnection->getEngineType()))
+ { // the jet provider doesn't support this method
+ // Create elements used in the array
+
+ ADORecordset *pRecordset = m_pADOConnection->getTablePrivileges(catalog,schemaPattern,tableNamePattern);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setTablePrivilegesMap();
+ xRef = pResult;
+ }
+ else
+ {
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTablePrivileges);
+ xRef = pResult;
+ ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
+ aRows.reserve(8);
+
+ aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = new ::connectivity::ORowSetValueDecorator(tableNamePattern);
+ aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
+ aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
+ aRows.push_back(aRow);
+ pResult->setRows(aRows);
+ }
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
+ const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = m_pADOConnection->getCrossReference(primaryCatalog,primarySchema,primaryTable,foreignCatalog,foreignSchema,foreignTable);
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ Reference< XResultSet > xRef;
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(pRecordset);
+ pResult->setCrossReferenceMap();
+ xRef = pResult;
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return getBoolProperty(::rtl::OUString::createFromAscii("Maximum Row Size Includes BLOB"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_LOWER) == DBPROPVAL_IC_LOWER ;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_UPPER) == DBPROPVAL_IC_UPPER ;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Maximum Index Size"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NON_NULL;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("Catalog Term"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ return getLiteral(DBLITERAL_QUOTE_PREFIX);
+
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ // return getStringProperty(::rtl::OUString::createFromAscii("Special Characters"));
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return isCapable(DBLITERAL_CORRELATION_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Catalog Location")) == DBPROPVAL_CL_START;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_IGNORE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DDL_COMMIT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_DML;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_ALL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Prepare Abort Behavior")) == DBPROPVAL_CB_PRESERVE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Prepare Commit Behavior")) == DBPROPVAL_CB_PRESERVE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_COMMIT) == DBPROPVAL_TR_COMMIT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Isolation Retention")) & DBPROPVAL_TR_ABORT) == DBPROPVAL_TR_ABORT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bValue(sal_False);
+
+ sal_Int32 nTxn = getInt32Property(::rtl::OUString::createFromAscii("Isolation Levels"));
+ if(level == TransactionIsolation::NONE)
+ bValue = sal_True;
+ else if(level == TransactionIsolation::READ_UNCOMMITTED)
+ bValue = (nTxn & DBPROPVAL_TI_READUNCOMMITTED) == DBPROPVAL_TI_READUNCOMMITTED;
+ else if(level == TransactionIsolation::READ_COMMITTED)
+ bValue = (nTxn & DBPROPVAL_TI_READCOMMITTED) == DBPROPVAL_TI_READCOMMITTED;
+ else if(level == TransactionIsolation::REPEATABLE_READ)
+ bValue = (nTxn & DBPROPVAL_TI_REPEATABLEREAD) == DBPROPVAL_TI_REPEATABLEREAD;
+ else if(level == TransactionIsolation::SERIALIZABLE)
+ bValue = (nTxn & DBPROPVAL_TI_SERIALIZABLE) == DBPROPVAL_TI_SERIALIZABLE;
+
+ return bValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_DML_STATEMENTS) == DBPROPVAL_SU_DML_STATEMENTS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_FULL) == DBPROPVAL_SQL_ANSI92_FULL);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_ENTRY) == DBPROPVAL_SQL_ANSI92_ENTRY);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI89_IEF) == DBPROPVAL_SQL_ANSI89_IEF);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_INDEX_DEFINITION) == DBPROPVAL_SU_INDEX_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_TABLE_DEFINITION) == DBPROPVAL_SU_TABLE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_TABLE_DEFINITION) == DBPROPVAL_CU_TABLE_DEFINITION;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_INDEX_DEFINITION) == DBPROPVAL_CU_INDEX_DEFINITION;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_DML_STATEMENTS) == DBPROPVAL_CU_DML_STATEMENTS;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ if ( ADOS::isJetEngine(m_pConnection->getEngineType()) )
+ return sal_True;
+ return getBoolProperty(::rtl::OUString::createFromAscii("Outer Join Capabilities"));
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ return new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_PROCEDURE_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_SCHEMA_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Transaction DDL")) == DBPROPVAL_TC_NONE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ return getBoolProperty(::rtl::OUString::createFromAscii("Read-Only Data Source"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("NULL Concatenation Behavior")) == DBPROPVAL_CB_NULL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ return isCapable(DBLITERAL_COLUMN_ALIAS);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return isCapable(DBLITERAL_CORRELATION_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ return getBoolProperty(::rtl::OUString::createFromAscii("Rowset Conversions on Command"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_NOT_SUPPORTED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) != DBPROPVAL_GB_CONTAINS_SELECT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("GROUP BY Support")) == DBPROPVAL_GB_NO_RELATION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return isCapable(DBLITERAL_ESCAPE_PERCENT);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return getBoolProperty(::rtl::OUString::createFromAscii("ORDER BY Columns in Select List"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Identifier Case Sensitivity")) & DBPROPVAL_IC_MIXED) == DBPROPVAL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_END) == DBPROPVAL_NC_END;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_START) == DBPROPVAL_NC_START;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_HIGH) == DBPROPVAL_NC_HIGH;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("NULL Collation Order")) & DBPROPVAL_NC_LOW) == DBPROPVAL_NC_LOW;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Schema Usage")) & DBPROPVAL_SU_PRIVILEGE_DEFINITION) == DBPROPVAL_SU_PRIVILEGE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ // return (getInt32Property(::rtl::OUString::createFromAscii("Catalog Usage")) & DBPROPVAL_CU_PRIVILEGE_DEFINITION) == DBPROPVAL_CU_PRIVILEGE_DEFINITION;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_CORRELATEDSUBQUERIES) == DBPROPVAL_SQ_CORRELATEDSUBQUERIES;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_COMPARISON) == DBPROPVAL_SQ_COMPARISON;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_EXISTS) == DBPROPVAL_SQ_EXISTS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_IN) == DBPROPVAL_SQ_IN;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return (getInt32Property(::rtl::OUString::createFromAscii("Subquery Support")) & DBPROPVAL_SQ_QUANTIFIED) == DBPROPVAL_SQ_QUANTIFIED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ANSI92_INTERMEDIATE) == DBPROPVAL_SQL_ANSI92_INTERMEDIATE);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("sdbc:ado:")+ m_pADOConnection->GetConnectionString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("User Name"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("Provider Friendly Name"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("Provider Version"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("DBMS Version"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("DBMS Name"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("Procedure Term"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ return getStringProperty(::rtl::OUString::createFromAscii("Schema Term"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nRet = TransactionIsolation::NONE;
+ switch(m_pADOConnection->get_IsolationLevel())
+ {
+ case adXactReadCommitted:
+ nRet = TransactionIsolation::READ_COMMITTED;
+ break;
+ case adXactRepeatableRead:
+ nRet = TransactionIsolation::REPEATABLE_READ;
+ break;
+ case adXactSerializable:
+ nRet = TransactionIsolation::SERIALIZABLE;
+ break;
+ case adXactReadUncommitted:
+ nRet = TransactionIsolation::READ_UNCOMMITTED;
+ break;
+ default:
+ ;
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ADORecordset *pRecordset = NULL;
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+ m_pADOConnection->OpenSchema(adSchemaDBInfoKeywords,vtEmpty,vtEmpty,&pRecordset);
+ OSL_ENSURE(pRecordset,"getSQLKeywords: no resultset!");
+ ADOS::ThrowException(*m_pADOConnection,*this);
+ if ( pRecordset )
+ {
+ WpADORecordset aRecordset(pRecordset);
+
+ aRecordset.MoveFirst();
+ OLEVariant aValue;
+ ::rtl::OUString aRet,aComma = ::rtl::OUString::createFromAscii(",");
+ while(!aRecordset.IsAtEOF())
+ {
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields());
+ WpADOField aField(aFields.GetItem(0));
+ aField.get_Value(aValue);
+ aRet = aRet + aValue + aComma;
+ aRecordset.MoveNext();
+ }
+ aRecordset.Close();
+ if ( aRet.getLength() )
+ return aRet.copy(0,aRet.lastIndexOf(','));
+ }
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ return getLiteral(DBLITERAL_ESCAPE_PERCENT);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue.copy(0,aValue.lastIndexOf(','));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue.copy(0,aValue.lastIndexOf(','));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_EXTENDED) == DBPROPVAL_SQL_ODBC_EXTENDED);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_CORE) == DBPROPVAL_SQL_ODBC_CORE);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nProp = getInt32Property(::rtl::OUString::createFromAscii("SQL Support"));
+ return (nProp == 512) || ((nProp & DBPROPVAL_SQL_ODBC_MINIMUM) == DBPROPVAL_SQL_ODBC_MINIMUM);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ if ( ADOS::isJetEngine(m_pConnection->getEngineType()) )
+ return sal_True;
+ return (getInt32Property(::rtl::OUString::createFromAscii("Outer Join Capabilities")) & 0x00000004L) == 0x00000004L;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return supportsFullOuterJoins( );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in GROUP BY"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return getInt32Property(::rtl::OUString::createFromAscii("Max Columns in ORDER BY"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ return 0; // getInt32Property(::rtl::OUString::createFromAscii("Max Columns in Select"));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ return getMaxSize(DBLITERAL_USER_NAME);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY != setType;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XDatabaseMetaData::getUDTs", *this );
+ return Reference< XResultSet >();
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx
new file mode 100644
index 000000000000..33ebcc4a9e3a
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADatabaseMetaDataImpl.cxx
@@ -0,0 +1,608 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ADatabaseMetaData.hxx"
+#include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
+#include "ado/Awrapado.hxx"
+#include "ado/AGroup.hxx"
+#include "ado/adoimp.hxx"
+#include "ado/AIndex.hxx"
+#include "ado/AKey.hxx"
+#include "ado/ATable.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ProcedureResult.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#ifdef DELETE
+#undef DELETE
+#endif
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+
+using namespace connectivity::ado;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::uno;
+
+// -------------------------------------------------------------------------
+void ODatabaseMetaData::fillLiterals()
+{
+ ADORecordset *pRecordset = NULL;
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+ m_pADOConnection->OpenSchema(adSchemaDBInfoLiterals,vtEmpty,vtEmpty,&pRecordset);
+
+ ADOS::ThrowException(*m_pADOConnection,*this);
+
+ OSL_ENSURE(pRecordset,"fillLiterals: no resultset!");
+ if ( pRecordset )
+ {
+ WpADORecordset aRecordset(pRecordset);
+
+ aRecordset.MoveFirst();
+ OLEVariant aValue;
+ LiteralInfo aInfo;
+ while(!aRecordset.IsAtEOF())
+ {
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(aRecordset.GetFields());
+ WpADOField aField(aFields.GetItem(1));
+ aInfo.pwszLiteralValue = aField.get_Value();
+ aField = aFields.GetItem(5);
+ aInfo.fSupported = aField.get_Value();
+ aField = aFields.GetItem(6);
+ aInfo.cchMaxLen = aField.get_Value().getUInt32();
+
+ aField = aFields.GetItem(4);
+ sal_uInt32 nId = aField.get_Value().getUInt32();
+ m_aLiteralInfo[nId] = aInfo;
+
+ aRecordset.MoveNext();
+ }
+ aRecordset.Close();
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::getMaxSize(sal_uInt32 _nId)
+{
+ if(!m_aLiteralInfo.size())
+ fillLiterals();
+
+ sal_Int32 nSize = 0;
+ ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
+ if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
+ nSize = ((*aIter).second.cchMaxLen == (-1)) ? 0 : (*aIter).second.cchMaxLen;
+ return nSize;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::isCapable(sal_uInt32 _nId)
+{
+ if(!m_aLiteralInfo.size())
+ fillLiterals();
+ sal_Bool bSupported = sal_False;
+ ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
+ if(aIter != m_aLiteralInfo.end())
+ bSupported = (*aIter).second.fSupported;
+ return bSupported;
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::getLiteral(sal_uInt32 _nId)
+{
+ if(!m_aLiteralInfo.size())
+ fillLiterals();
+ ::rtl::OUString sStr;
+ ::std::map<sal_uInt32,LiteralInfo>::const_iterator aIter = m_aLiteralInfo.find(_nId);
+ if(aIter != m_aLiteralInfo.end() && (*aIter).second.fSupported)
+ sStr = (*aIter).second.pwszLiteralValue;
+ return sStr;
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setColumnPrivilegesMap()
+{
+ m_mColumns[8] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
+ ColumnValue::NULLABLE,
+ 3,3,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setColumnsMap()
+{
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("TYPE_NAME"),
+ ColumnValue::NO_NULLS,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[11] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[13] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("COLUMN_DEF"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[14] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[15] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("CHAR_OCTET_LENGTH"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTablesMap()
+{
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setProcedureColumnsMap()
+{
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setPrimaryKeysMap()
+{
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PK_NAME"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setIndexInfoMap()
+{
+ m_mColumns[4] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NON_UNIQUE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[5] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("INDEX_QUALIFIER"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[10] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("ASC_OR_DESC"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTablePrivilegesMap()
+{
+ m_mColumns[6] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRIVILEGE"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("IS_GRANTABLE"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setCrossReferenceMap()
+{
+ m_mColumns[9] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("KEY_SEQ"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setTypeInfoMap()
+{
+ m_mColumns[3] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("PRECISION"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NULLABLE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[12] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("AUTO_INCREMENT"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::BIT);
+ m_mColumns[16] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATA_TYPE"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[17] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("SQL_DATETIME_SUB"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+ m_mColumns[18] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("NUM_PREC_RADIX"),
+ ColumnValue::NO_NULLS,
+ 1,1,0,
+ DataType::INTEGER);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSetMetaData::setProceduresMap()
+{
+ m_mColumns[7] = OColumn(::rtl::OUString(),::rtl::OUString::createFromAscii("REMARKS"),
+ ColumnValue::NULLABLE,
+ 0,0,0,
+ DataType::VARCHAR);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isSearchable();
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isAutoIncrement();
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnServiceName();
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getTableName();
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getCatalogName();
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnTypeName();
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isCaseSensitive();
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getSchemaName();
+ return ::rtl::OUString();
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+ObjectTypeEnum OAdoGroup::MapObjectType(sal_Int32 _ObjType)
+{
+ ObjectTypeEnum eNumType= adPermObjTable;
+ switch(_ObjType)
+ {
+ case PrivilegeObject::TABLE:
+ break;
+ case PrivilegeObject::VIEW:
+ eNumType = adPermObjView;
+ break;
+ case PrivilegeObject::COLUMN:
+ eNumType = adPermObjColumn;
+ break;
+ }
+ return eNumType;
+}
+// -------------------------------------------------------------------------
+sal_Int32 OAdoGroup::MapRight(RightsEnum _eNum)
+{
+ sal_Int32 nRight = 0;
+ if(_eNum & adRightRead)
+ nRight |= Privilege::SELECT;
+ if(_eNum & adRightInsert)
+ nRight |= Privilege::INSERT;
+ if(_eNum & adRightUpdate)
+ nRight |= Privilege::UPDATE;
+ if(_eNum & adRightDelete)
+ nRight |= Privilege::DELETE;
+ if(_eNum & adRightReadDesign)
+ nRight |= Privilege::READ;
+ if(_eNum & adRightCreate)
+ nRight |= Privilege::CREATE;
+ if(_eNum & adRightWriteDesign)
+ nRight |= Privilege::ALTER;
+ if(_eNum & adRightReference)
+ nRight |= Privilege::REFERENCE;
+ if(_eNum & adRightDrop)
+ nRight |= Privilege::DROP;
+
+ return nRight;
+}
+// -------------------------------------------------------------------------
+RightsEnum OAdoGroup::Map2Right(sal_Int32 _eNum)
+{
+ sal_Int32 nRight = adRightNone;
+ if(_eNum & Privilege::SELECT)
+ nRight |= adRightRead;
+
+ if(_eNum & Privilege::INSERT)
+ nRight |= adRightInsert;
+
+ if(_eNum & Privilege::UPDATE)
+ nRight |= adRightUpdate;
+
+ if(_eNum & Privilege::DELETE)
+ nRight |= adRightDelete;
+
+ if(_eNum & Privilege::READ)
+ nRight |= adRightReadDesign;
+
+ if(_eNum & Privilege::CREATE)
+ nRight |= adRightCreate;
+
+ if(_eNum & Privilege::ALTER)
+ nRight |= adRightWriteDesign;
+
+ if(_eNum & Privilege::REFERENCE)
+ nRight |= adRightReference;
+
+ if(_eNum & Privilege::DROP)
+ nRight |= adRightDrop;
+
+ return (RightsEnum)nRight;
+}
+// -------------------------------------------------------------------------
+void WpADOIndex::Create()
+{
+ HRESULT hr = -1;
+
+ _ADOIndex* pIndex = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOINDEX_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOINDEX_25,
+ (void**)&pIndex );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pIndex );
+ pIndex->Release();
+ }
+}
+// -------------------------------------------------------------------------
+void OAdoIndex::fillPropertyValues()
+{
+ if(m_aIndex.IsValid())
+ {
+ m_Name = m_aIndex.get_Name();
+ m_IsUnique = m_aIndex.get_Unique();
+ m_IsPrimaryKeyIndex = m_aIndex.get_PrimaryKey();
+ m_IsClustered = m_aIndex.get_Clustered();
+ }
+}
+// -----------------------------------------------------------------------------
+void WpADOKey::Create()
+{
+ HRESULT hr = -1;
+ _ADOKey* pKey = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOKEY_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOKEY_25,
+ (void**)&pKey );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pKey );
+ pKey->Release();
+ }
+}
+// -------------------------------------------------------------------------
+void OAdoKey::fillPropertyValues()
+{
+ if(m_aKey.IsValid())
+ {
+ m_aProps->m_Type = MapKeyRule(m_aKey.get_Type());
+ m_Name = m_aKey.get_Name();
+ m_aProps->m_ReferencedTable = m_aKey.get_RelatedTable();
+ m_aProps->m_UpdateRule = MapRule(m_aKey.get_UpdateRule());
+ m_aProps->m_DeleteRule = MapRule(m_aKey.get_DeleteRule());
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 OAdoKey::MapRule(const RuleEnum& _eNum)
+{
+ sal_Int32 eNum = KeyRule::NO_ACTION;
+ switch(_eNum)
+ {
+ case adRICascade:
+ eNum = KeyRule::CASCADE;
+ break;
+ case adRISetNull:
+ eNum = KeyRule::SET_NULL;
+ break;
+ case adRINone:
+ eNum = KeyRule::NO_ACTION;
+ break;
+ case adRISetDefault:
+ eNum = KeyRule::SET_DEFAULT;
+ break;
+ }
+ return eNum;
+}
+// -------------------------------------------------------------------------
+RuleEnum OAdoKey::Map2Rule(const sal_Int32& _eNum)
+{
+ RuleEnum eNum = adRINone;
+ switch(_eNum)
+ {
+ case KeyRule::CASCADE:
+ eNum = adRICascade;
+ break;
+ case KeyRule::SET_NULL:
+ eNum = adRISetNull;
+ break;
+ case KeyRule::NO_ACTION:
+ eNum = adRINone;
+ break;
+ case KeyRule::SET_DEFAULT:
+ eNum = adRISetDefault;
+ break;
+ }
+ return eNum;
+}
+// -------------------------------------------------------------------------
+sal_Int32 OAdoKey::MapKeyRule(const KeyTypeEnum& _eNum)
+{
+ sal_Int32 nKeyType = KeyType::PRIMARY;
+ switch(_eNum)
+ {
+ case adKeyPrimary:
+ nKeyType = KeyType::PRIMARY;
+ break;
+ case adKeyForeign:
+ nKeyType = KeyType::FOREIGN;
+ break;
+ case adKeyUnique:
+ nKeyType = KeyType::UNIQUE;
+ break;
+ }
+ return nKeyType;
+}
+// -------------------------------------------------------------------------
+KeyTypeEnum OAdoKey::Map2KeyRule(const sal_Int32& _eNum)
+{
+ KeyTypeEnum eNum( adKeyPrimary );
+ switch(_eNum)
+ {
+ case KeyType::PRIMARY:
+ eNum = adKeyPrimary;
+ break;
+ case KeyType::FOREIGN:
+ eNum = adKeyForeign;
+ break;
+ case KeyType::UNIQUE:
+ eNum = adKeyUnique;
+ break;
+ default:
+ OSL_ENSURE( false, "OAdoKey::Map2KeyRule: invalid key type!" );
+ }
+ return eNum;
+}
+// -----------------------------------------------------------------------------
+void WpADOTable::Create()
+{
+ HRESULT hr = -1;
+ _ADOTable* pTable = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOTABLE_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOTABLE_25,
+ (void**)&pTable );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pTable );
+ pTable->Release();
+ }
+}
+// -------------------------------------------------------------------------
+::rtl::OUString WpADOCatalog::GetObjectOwner(const ::rtl::OUString& _rName, ObjectTypeEnum _eNum)
+{
+ OLEVariant _rVar;
+ _rVar.setNoArg();
+ OLEString aBSTR;
+ OLEString sStr1(_rName);
+ pInterface->GetObjectOwner(sStr1,_eNum,_rVar,&aBSTR);
+ return aBSTR;
+}
+// -----------------------------------------------------------------------------
+void OAdoTable::fillPropertyValues()
+{
+ if(m_aTable.IsValid())
+ {
+ m_Name = m_aTable.get_Name();
+ m_Type = m_aTable.get_Type();
+ {
+ WpADOCatalog aCat(m_aTable.get_ParentCatalog());
+ if(aCat.IsValid())
+ m_CatalogName = aCat.GetObjectOwner(m_aTable.get_Name(),adPermObjTable);
+ }
+ {
+ WpADOProperties aProps = m_aTable.get_Properties();
+ if(aProps.IsValid())
+ m_Description = OTools::getValue(aProps,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")));
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void WpADOUser::Create()
+{
+ HRESULT hr = -1;
+ _ADOUser* pUser = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOUSER_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOUSER_25,
+ (void**)&pUser );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pUser );
+ pUser->Release();
+ }
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx
new file mode 100644
index 000000000000..f35ba90d84f7
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSet.cxx
@@ -0,0 +1,1218 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <comphelper/sequence.hxx>
+#include "ado/ADatabaseMetaDataResultSet.hxx"
+#include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbc/ProcedureResult.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/seqstream.hxx>
+#include "connectivity/dbexception.hxx"
+
+
+#include <oledb.h>
+
+using namespace dbtools;
+using namespace connectivity::ado;
+using namespace cppu;
+using namespace ::comphelper;
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(ADORecordset* _pRecordSet)
+ :ODatabaseMetaDataResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
+ ,m_aStatement(NULL)
+ ,m_xMetaData(NULL)
+ ,m_pRecordSet(_pRecordSet)
+ ,m_bEOF(sal_False)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ m_aColMapping.push_back(-1);
+ if(_pRecordSet)
+ {
+ m_pRecordSet->AddRef();
+ VARIANT_BOOL bIsAtBOF;
+ m_pRecordSet->get_BOF(&bIsAtBOF);
+ m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE;
+ }
+ else
+ m_bOnFirstAfterOpen = sal_False;
+ osl_decrementInterlockedCount( &m_refCount );
+ // allocBuffer();
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
+{
+ if(m_pRecordSet)
+ m_pRecordSet->Release();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if(m_pRecordSet)
+ m_pRecordSet->Close();
+ m_aStatement = NULL;
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
+}
+// -----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::checkRecordSet() throw(SQLException)
+{
+ if(!m_pRecordSet)
+ throwFunctionSequenceException(*this);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+#define BLOCK_SIZE 256
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ columnIndex = mapColumn(columnIndex);
+ WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
+ if((aField.GetAttributes() & adFldLong) == adFldLong)
+ {
+ //Copy the data only upto the Actual Size of Field.
+ sal_Int32 nSize = aField.GetActualSize();
+ Sequence<sal_Int8> aData(nSize);
+ long index = 0;
+ while(index < nSize)
+ {
+ m_aValue = aField.GetChunk(BLOCK_SIZE);
+ if(m_aValue.isNull())
+ break;
+ UCHAR chData;
+ for(long index2 = 0;index2 < BLOCK_SIZE;++index2)
+ {
+ HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData);
+ if(SUCCEEDED(hr))
+ {
+ //Take BYTE by BYTE and advance Memory Location
+ aData.getArray()[index++] = chData;
+ }
+ else
+ break;
+ }
+ }
+ return index ? Reference< ::com::sun::star::io::XInputStream >(new SequenceInputStream(aData)) : Reference< ::com::sun::star::io::XInputStream >();
+ }
+ // else we ask for a bytesequence
+ aField.get_Value(m_aValue);
+ if(m_aValue.isNull())
+ return NULL;
+ return new SequenceInputStream(m_aValue);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if ( !m_aValueRange.empty() && columnIndex == 11 && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end() )
+ {
+ getValue(2);
+ if ( static_cast<sal_Int16>(m_aValue) != adCurrency )
+ return sal_False;
+ }
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ getValue(columnIndex);
+
+ columnIndex = mapColumn(columnIndex);
+
+ if(m_aValue.isNull())
+ return 0;
+ if ( !m_aValueRange.empty() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return (sal_Int8)(*m_aValueRangeIter).second[(sal_Int32)m_aValue];
+ else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
+ return (sal_Int8)(*m_aStrValueRangeIter).second[m_aValue];
+
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ getValue(columnIndex);
+
+ columnIndex = mapColumn(columnIndex);
+ if(m_aValue.isNull())
+ return 0;
+
+ if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return (*m_aValueRangeIter).second[(sal_Int32)m_aValue];
+ else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
+ return (*m_aStrValueRangeIter).second[m_aValue];
+
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XResultSet::getRow", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this );
+ return sal_Int64(0);
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRow", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ columnIndex = mapColumn(columnIndex);
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ getValue(columnIndex);
+
+ columnIndex = mapColumn(columnIndex);
+ if(m_aValue.isNull())
+ return 0;
+
+ if(m_aValueRange.size() && (m_aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return (sal_Int16)(*m_aValueRangeIter).second[(sal_Int32)m_aValue];
+ else if(m_aStrValueRange.size() && (m_aStrValueRangeIter = m_aStrValueRange.find(columnIndex)) != m_aStrValueRange.end())
+ return (sal_Int16)(*m_aStrValueRangeIter).second[m_aValue];
+
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ getValue(columnIndex);
+
+
+ columnIndex = mapColumn(columnIndex);
+ if(m_aValue.isNull())
+ return ::rtl::OUString();
+ if(m_aIntValueRange.size() && (m_aIntValueRangeIter = m_aIntValueRange.find(columnIndex)) != m_aIntValueRange.end())
+ return (*m_aIntValueRangeIter).second[m_aValue];
+
+ return m_aValue;
+}
+
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ VARIANT_BOOL bIsAtEOF;
+ m_pRecordSet->get_EOF(&bIsAtEOF);
+ return bIsAtEOF == VARIANT_TRUE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ if(first())
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pRecordSet)
+ return sal_False;
+
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveFirst());
+ if ( bRet )
+ m_nRowPos = 1;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+
+
+ return m_pRecordSet && SUCCEEDED(m_pRecordSet->MoveLast()) ? sal_True : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(first())
+ {
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
+ if(bRet)
+ m_nRowPos = row;
+ return bRet;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pRecordSet)
+ return sal_False;
+
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
+ if(bRet)
+ m_nRowPos += row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pRecordSet)
+ return sal_False;
+
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious());
+ if(bRet)
+ --m_nRowPos;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ return m_aStatement.get();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ return (eRec & adRecDeleted) == adRecDeleted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ return (eRec & adRecNew) == adRecNew;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ return (eRec & adRecModified) == adRecModified;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pRecordSet)
+ return sal_True;
+
+ VARIANT_BOOL bIsAtBOF;
+ m_pRecordSet->get_BOF(&bIsAtBOF);
+ return bIsAtBOF == VARIANT_TRUE;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pRecordSet)
+ return sal_False;
+
+ if(m_bOnFirstAfterOpen)
+ {
+ m_bOnFirstAfterOpen = sal_False;
+ return sal_True;
+ }
+ else
+ return SUCCEEDED(m_pRecordSet->MoveNext());
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ return m_aValue.isNull();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+
+ m_pRecordSet->Cancel();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return ResultSetConcurrency::READ_ONLY;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return FetchDirection::FORWARD;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nValue=-1;
+ if(m_pRecordSet)
+ m_pRecordSet->get_CacheSize(&nValue);
+ return nValue;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setFetchDirection(sal_Int32 /*_par0*/)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this );
+}
+//------------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setFetchSize(sal_Int32 _par0)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if(m_pRecordSet)
+ m_pRecordSet->put_CacheSize(_par0);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
+{
+
+ Sequence< com::sun::star::beans::Property > aProps(5);
+ com::sun::star::beans::Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE, sal_Int32);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
+{
+ return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ case PROPERTY_ID_FETCHSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& /*rValue*/
+ )
+ throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ throw Exception();
+ break;
+ default:
+ OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!");
+ }
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setProceduresMap()
+{
+
+ for(sal_Int32 i=1;i<4;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(5);
+ m_aColMapping.push_back(7);
+ m_aColMapping.push_back(8);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(4);
+
+ TInt2IntMap aMap;
+ aMap[DB_PT_UNKNOWN] = ProcedureResult::UNKNOWN;
+ aMap[DB_PT_PROCEDURE] = ProcedureResult::NONE;
+ aMap[DB_PT_FUNCTION] = ProcedureResult::RETURN;
+ m_aValueRange[4] = aMap;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setProceduresMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setCatalogsMap()
+{
+ m_aColMapping.push_back(1);
+
+ m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setSchemasMap()
+{
+ m_aColMapping.push_back(2);
+
+ m_xMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setColumnPrivilegesMap()
+{
+
+ m_aColMapping.push_back(3);
+ m_aColMapping.push_back(4);
+ m_aColMapping.push_back(5);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(2);
+ m_aColMapping.push_back(9);
+ m_aColMapping.push_back(10);
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setColumnPrivilegesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setColumnsMap()
+{
+
+ for(sal_Int32 i=1;i<5;++i)
+ m_aColMapping.push_back(i);
+
+ m_aColMapping.push_back(12);
+ m_aColMapping.push_back(12); // is used as TYPE_NAME
+
+ m_aColMapping.push_back(14);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(17);
+ m_aColMapping.push_back(18);
+
+ m_aColMapping.push_back(11);
+ m_aColMapping.push_back(29);
+ m_aColMapping.push_back(9);
+ m_aColMapping.push_back(18);
+ m_aColMapping.push_back(18);
+
+ m_aColMapping.push_back(15);
+ m_aColMapping.push_back(7);
+ m_aColMapping.push_back(11);
+
+ TInt2IntMap aMap;
+ aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty);
+ aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt);
+ aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt);
+ aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger);
+ aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt);
+ aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt);
+ aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt);
+ aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt);
+ aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt);
+ aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle);
+ aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble);
+ aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency);
+ aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal);
+ aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric);
+ aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean);
+ aMap[adError] = ADOS::MapADOType2Jdbc(adError);
+ aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined);
+ aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant);
+ aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch);
+ aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown);
+ aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID);
+ aMap[adDate] = ADOS::MapADOType2Jdbc(adDate);
+ aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate);
+ aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime);
+ aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp);
+ aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR);
+ aMap[adChar] = ADOS::MapADOType2Jdbc(adChar);
+ aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar);
+ aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar);
+ aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar);
+ aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar);
+ aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar);
+ aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary);
+ aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary);
+ aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary);
+ aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter);
+ aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime);
+ aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant);
+ aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric);
+// aMap[adArray] = ADOS::MapADOType2Jdbc(adArray);
+
+ m_aValueRange[12] = aMap;
+
+ ::std::map< sal_Int32,::rtl::OUString> aMap2;
+ aMap2[0] = ::rtl::OUString::createFromAscii("YES");
+ aMap2[1] = ::rtl::OUString::createFromAscii("NO");
+ m_aIntValueRange[18] = aMap2;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTablesMap()
+{
+
+ for(sal_Int32 i=1;i<5;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(6);
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setTablesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setProcedureColumnsMap()
+{
+
+ for(sal_Int32 i=1;i<5;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(10);
+ m_aColMapping.push_back(16);
+ m_aColMapping.push_back(13);
+ m_aColMapping.push_back(11);
+ m_aColMapping.push_back(12);
+
+ m_aColMapping.push_back(9);
+ m_aColMapping.push_back(14);
+
+ TInt2IntMap aMap;
+ aMap[DBTYPE_EMPTY] = DataType::SQLNULL;
+ aMap[DBTYPE_NULL] = DataType::SQLNULL;
+ aMap[DBTYPE_I2] = DataType::SMALLINT;
+ aMap[DBTYPE_I4] = DataType::INTEGER;
+ aMap[DBTYPE_R4] = DataType::FLOAT;
+ aMap[DBTYPE_R8] = DataType::DOUBLE;
+ aMap[DBTYPE_CY] = DataType::BIGINT;
+ aMap[DBTYPE_DATE] = DataType::DATE;
+ aMap[DBTYPE_BSTR] = DataType::VARCHAR;
+ aMap[DBTYPE_IDISPATCH] = DataType::OBJECT;
+ aMap[DBTYPE_ERROR] = DataType::OTHER;
+ aMap[DBTYPE_BOOL] = DataType::BIT;
+ aMap[DBTYPE_VARIANT] = DataType::STRUCT;
+ aMap[DBTYPE_IUNKNOWN] = DataType::OTHER;
+ aMap[DBTYPE_DECIMAL] = DataType::DECIMAL;
+ aMap[DBTYPE_UI1] = DataType::TINYINT;
+ aMap[DBTYPE_ARRAY] = DataType::ARRAY;
+ aMap[DBTYPE_BYREF] = DataType::REF;
+ aMap[DBTYPE_I1] = DataType::CHAR;
+ aMap[DBTYPE_UI2] = DataType::SMALLINT;
+ aMap[DBTYPE_UI4] = DataType::INTEGER;
+
+ // aMap[The] = ;
+ // aMap[in] = ;
+ aMap[DBTYPE_I8] = DataType::BIGINT;
+ aMap[DBTYPE_UI8] = DataType::BIGINT;
+ aMap[DBTYPE_GUID] = DataType::OTHER;
+ aMap[DBTYPE_VECTOR] = DataType::OTHER;
+ aMap[DBTYPE_FILETIME] = DataType::OTHER;
+ aMap[DBTYPE_RESERVED] = DataType::OTHER;
+
+ // aMap[The] = ;
+ aMap[DBTYPE_BYTES] = DataType::VARBINARY;
+ aMap[DBTYPE_STR] = DataType::LONGVARCHAR;
+ aMap[DBTYPE_WSTR] = DataType::LONGVARCHAR;
+ aMap[DBTYPE_NUMERIC] = DataType::NUMERIC;
+ aMap[DBTYPE_UDT] = DataType::OTHER;
+ aMap[DBTYPE_DBDATE] = DataType::DATE;
+ aMap[DBTYPE_DBTIME] = DataType::TIME;
+ aMap[DBTYPE_DBTIMESTAMP] = DataType::TIMESTAMP;
+ aMap[DBTYPE_HCHAPTER] = DataType::OTHER;
+ aMap[DBTYPE_PROPVARIANT] = DataType::OTHER;
+ aMap[DBTYPE_VARNUMERIC] = DataType::NUMERIC;
+
+ m_aValueRange[10] = aMap;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setProcedureColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setPrimaryKeysMap()
+{
+
+ sal_Int32 i=1;
+ for(;i<5;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(7);
+ m_aColMapping.push_back(8);
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setProcedureColumnsMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setIndexInfoMap()
+{
+
+ sal_Int32 i=1;
+ for(;i<4;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(8);
+ m_aColMapping.push_back(4);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(10);
+ m_aColMapping.push_back(17);
+ m_aColMapping.push_back(18);
+ m_aColMapping.push_back(21);
+ m_aColMapping.push_back(22);
+ m_aColMapping.push_back(23);
+ m_aColMapping.push_back(24);
+
+ TInt2IntMap aMap;
+ aMap[DBPROPVAL_IT_HASH] = IndexType::HASHED;
+ aMap[DBPROPVAL_IT_CONTENT] = IndexType::OTHER;
+ aMap[DBPROPVAL_IT_OTHER] = IndexType::OTHER;
+ aMap[DBPROPVAL_IT_BTREE] = IndexType::OTHER;
+
+ m_aValueRange[10] = aMap;
+
+ TInt2IntMap aMap2;
+ aMap[0] = 1;
+ aMap[1] = 0;
+ m_aValueRange[8] = aMap2;
+
+ ::std::map< sal_Int32,::rtl::OUString> aMap3;
+ aMap3[0] = ::rtl::OUString();
+ aMap3[DB_COLLATION_ASC] = ::rtl::OUString::createFromAscii("A");
+ aMap3[DB_COLLATION_DESC] = ::rtl::OUString::createFromAscii("D");
+
+ m_aIntValueRange[21] = aMap3;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setIndexInfoMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTablePrivilegesMap()
+{
+
+ sal_Int32 i=3;
+ for(;i<6;i++)
+ m_aColMapping.push_back(i);
+ m_aColMapping.push_back(1);
+ m_aColMapping.push_back(2);
+ m_aColMapping.push_back(6);
+ m_aColMapping.push_back(7);
+
+ ::std::map< sal_Int32,::rtl::OUString> aMap;
+ aMap[0] = ::rtl::OUString::createFromAscii("YES");
+ aMap[1] = ::rtl::OUString::createFromAscii("NO");
+ m_aIntValueRange[7] = aMap;
+
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setTablePrivilegesMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setCrossReferenceMap()
+{
+
+ sal_Int32 i=1;
+ for(;i<5;i++)
+ m_aColMapping.push_back(i);
+ for(i=7;i<11;i++)
+ m_aColMapping.push_back(i);
+
+ m_aColMapping.push_back(13);
+ m_aColMapping.push_back(14);
+ m_aColMapping.push_back(15);
+ m_aColMapping.push_back(17);
+ m_aColMapping.push_back(16);
+ m_aColMapping.push_back(18);
+
+ ::std::map< ::rtl::OUString,sal_Int32> aMap;
+ aMap[ ::rtl::OUString::createFromAscii("CASCADE")] = KeyRule::CASCADE;
+ aMap[ ::rtl::OUString::createFromAscii("RESTRICT")] = KeyRule::RESTRICT;
+ aMap[ ::rtl::OUString::createFromAscii("SET NULL")] = KeyRule::SET_NULL;
+ aMap[ ::rtl::OUString::createFromAscii("SET DEFAULT")] = KeyRule::SET_DEFAULT;
+ aMap[ ::rtl::OUString::createFromAscii("NO ACTION")] = KeyRule::NO_ACTION;
+
+ m_aStrValueRange[14] = aMap;
+ m_aStrValueRange[15] = aMap;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setCrossReferenceMap();
+ m_xMetaData = pMetaData;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setTypeInfoMap(sal_Bool _bJetEngine)
+{
+ sal_Int32 i=1;
+ for(;i<19;i++)
+ m_aColMapping.push_back(i);
+
+ ::std::map< ::rtl::OUString,sal_Int32> aMap1;
+ aMap1[ ::rtl::OUString()] = 10;
+
+ m_aStrValueRange[18] = aMap1;
+
+ TInt2IntMap aMap;
+ aMap[adEmpty] = ADOS::MapADOType2Jdbc(adEmpty);
+ aMap[adTinyInt] = ADOS::MapADOType2Jdbc(adTinyInt);
+ aMap[adSmallInt] = ADOS::MapADOType2Jdbc(adSmallInt);
+ aMap[adInteger] = ADOS::MapADOType2Jdbc(adInteger);
+ aMap[adBigInt] = ADOS::MapADOType2Jdbc(adBigInt);
+ aMap[adUnsignedTinyInt] = ADOS::MapADOType2Jdbc(adUnsignedTinyInt);
+ aMap[adUnsignedSmallInt]= ADOS::MapADOType2Jdbc(adUnsignedSmallInt);
+ aMap[adUnsignedInt] = ADOS::MapADOType2Jdbc(adUnsignedInt);
+ aMap[adUnsignedBigInt] = ADOS::MapADOType2Jdbc(adUnsignedBigInt);
+ aMap[adSingle] = ADOS::MapADOType2Jdbc(adSingle);
+ aMap[adDouble] = ADOS::MapADOType2Jdbc(adDouble);
+ aMap[adCurrency] = ADOS::MapADOType2Jdbc(adCurrency);
+ aMap[adDecimal] = ADOS::MapADOType2Jdbc(adDecimal);
+ aMap[adNumeric] = ADOS::MapADOType2Jdbc(adNumeric);
+ aMap[adBoolean] = ADOS::MapADOType2Jdbc(adBoolean);
+ aMap[adError] = ADOS::MapADOType2Jdbc(adError);
+ aMap[adUserDefined] = ADOS::MapADOType2Jdbc(adUserDefined);
+ aMap[adVariant] = ADOS::MapADOType2Jdbc(adVariant);
+ aMap[adIDispatch] = ADOS::MapADOType2Jdbc(adIDispatch);
+ aMap[adIUnknown] = ADOS::MapADOType2Jdbc(adIUnknown);
+ aMap[adGUID] = ADOS::MapADOType2Jdbc(adGUID);
+ aMap[adDate] = _bJetEngine ? ADOS::MapADOType2Jdbc(adDBTimeStamp) : ADOS::MapADOType2Jdbc(adDate);
+ aMap[adDBDate] = ADOS::MapADOType2Jdbc(adDBDate);
+ aMap[adDBTime] = ADOS::MapADOType2Jdbc(adDBTime);
+ aMap[adDBTimeStamp] = ADOS::MapADOType2Jdbc(adDBTimeStamp);
+ aMap[adBSTR] = ADOS::MapADOType2Jdbc(adBSTR);
+ aMap[adChar] = ADOS::MapADOType2Jdbc(adChar);
+ aMap[adVarChar] = ADOS::MapADOType2Jdbc(adVarChar);
+ aMap[adLongVarChar] = ADOS::MapADOType2Jdbc(adLongVarChar);
+ aMap[adWChar] = ADOS::MapADOType2Jdbc(adWChar);
+ aMap[adVarWChar] = ADOS::MapADOType2Jdbc(adVarWChar);
+ aMap[adLongVarWChar] = ADOS::MapADOType2Jdbc(adLongVarWChar);
+ aMap[adBinary] = ADOS::MapADOType2Jdbc(adBinary);
+ aMap[adVarBinary] = ADOS::MapADOType2Jdbc(adVarBinary);
+ aMap[adLongVarBinary] = ADOS::MapADOType2Jdbc(adLongVarBinary);
+ aMap[adChapter] = ADOS::MapADOType2Jdbc(adChapter);
+ aMap[adFileTime] = ADOS::MapADOType2Jdbc(adFileTime);
+ aMap[adPropVariant] = ADOS::MapADOType2Jdbc(adPropVariant);
+ aMap[adVarNumeric] = ADOS::MapADOType2Jdbc(adVarNumeric);
+// aMap[adArray] = ADOS::MapADOType2Jdbc(adArray);
+
+ m_aValueRange[2] = aMap;
+
+ TInt2IntMap aColumnValueMapping;
+ aColumnValueMapping[VARIANT_FALSE] = ColumnValue::NO_NULLS;
+ aColumnValueMapping[VARIANT_TRUE] = ColumnValue::NULLABLE;
+ m_aValueRange[7] = aColumnValueMapping;
+
+ // now adjust the column mapping
+ // OJ 24.01.2002 96860
+ TInt2IntMap aSerachMapping;
+ aSerachMapping[DB_UNSEARCHABLE] = ColumnSearch::NONE;
+ aSerachMapping[DB_LIKE_ONLY] = ColumnSearch::CHAR;
+ aSerachMapping[DB_ALL_EXCEPT_LIKE] = ColumnSearch::BASIC;
+ aSerachMapping[DB_SEARCHABLE] = ColumnSearch::FULL;
+
+ m_aValueRange[9] = aSerachMapping;
+
+ TInt2IntMap aCurrencyMapping;
+ m_aValueRange[11] = aCurrencyMapping;
+
+ ODatabaseMetaDataResultSetMetaData* pMetaData = new ODatabaseMetaDataResultSetMetaData(m_pRecordSet,this);
+ pMetaData->setTypeInfoMap();
+ m_xMetaData = pMetaData;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+OLEVariant ODatabaseMetaDataResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+
+ checkRecordSet();
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
+ aField.get_Value(m_aValue);
+ return m_aValue;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
new file mode 100644
index 000000000000..a204ec477564
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADatabaseMetaDataResultSetMetaData.cxx
@@ -0,0 +1,233 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ADatabaseMetaDataResultSetMetaData.hxx"
+#include "ado/Awrapado.hxx"
+#include "connectivity/dbexception.hxx"
+
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSetMetaData::~ODatabaseMetaDataResultSetMetaData()
+{
+ if(m_pRecordSet)
+ m_pRecordSet->Release();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nSize = 0;
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ nSize = (*m_mColumnsIter).second.getColumnDisplaySize();
+ else if(m_pRecordSet)
+ {
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ nSize = aField.GetActualSize();
+ }
+ return nSize;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = 0;
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ nType = (*m_mColumnsIter).second.getColumnType();
+ else if(m_pRecordSet)
+ {
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ nType = ADOS::MapADOType2Jdbc(aField.GetADOType());
+ }
+ return nType;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ if(!m_pRecordSet)
+ return 0;
+ if(m_nColCount != -1)
+ return m_nColCount;
+
+ if(m_vMapping.size())
+ return m_mColumns.size();
+
+ ADOFields* pFields = NULL;
+ m_pRecordSet->get_Fields(&pFields);
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields);
+ m_nColCount = aFields.GetItemCount();
+ return m_nColCount;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnName();
+ if(!m_pRecordSet)
+ return ::rtl::OUString();
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetName();
+
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getColumnLabel();
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isCurrency();
+ if(!m_pRecordSet)
+ return 0;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldFixed) == adFldFixed;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isSigned();
+ if(!m_pRecordSet)
+ return 0;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldNegativeScale) == adFldNegativeScale;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getPrecision();
+ if(!m_pRecordSet)
+ return 0;
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetPrecision();
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.getScale();
+
+ if(!m_pRecordSet)
+ return 0;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ return aField.GetNumericScale();
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isNullable();
+
+ if(!m_pRecordSet)
+ return 0;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isReadOnly();
+
+ if(!m_pRecordSet)
+ return 0;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isDefinitelyWritable();
+
+ if(!m_pRecordSet)
+ return 0;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,m_vMapping[column]);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable;
+ }
+ return sal_False;
+;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ if(m_mColumns.size() && (m_mColumnsIter = m_mColumns.find(column)) != m_mColumns.end())
+ return (*m_mColumnsIter).second.isWritable();
+ return isDefinitelyWritable(column);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/ADriver.cxx b/connectivity/source/drivers/ado/ADriver.cxx
new file mode 100644
index 000000000000..20eb6910f849
--- /dev/null
+++ b/connectivity/source/drivers/ado/ADriver.cxx
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ADriver.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/Awrapadox.hxx"
+#include "ado/ACatalog.hxx"
+#include "ado/Awrapado.hxx"
+#include "ado/adoimp.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "resource/ado_res.hrc"
+#include <Objbase.h>
+
+
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::lang;
+
+// --------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------
+ODriver::ODriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
+ : ODriver_BASE(m_aMutex)
+ ,m_xORB(_xORB)
+{
+ if ( FAILED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED)) )
+ {
+ CoUninitialize();
+ int h = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ (void)h;
+ ++h;
+ }
+}
+// -------------------------------------------------------------------------
+ODriver::~ODriver()
+{
+ CoUninitialize();
+ CoInitialize(NULL);
+}
+//------------------------------------------------------------------------------
+void ODriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ ODriver_BASE::disposing();
+}
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.ado.ODriver");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > ODriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver");
+ return aSNS;
+}
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::ado::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// --------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OConnection* pCon = new OConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:ado:"),9));
+}
+// -----------------------------------------------------------------------------
+void ODriver::impl_checkURL_throw(const ::rtl::OUString& _sUrl)
+{
+ if ( !acceptsURL(_sUrl) )
+ {
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( !acceptsURL(_sUrl) )
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ impl_checkURL_throw(url);
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// --------------------------------------------------------------------------------
+// XDataDefinitionSupplier
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ OConnection* pConnection = NULL;
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelImplementationId()) );
+
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection)
+ {
+ pConnection = pSearchConnection;
+ break;
+ }
+ }
+
+ }
+
+ Reference< XTablesSupplier > xTab = NULL;
+ if(pConnection)
+ {
+ WpADOCatalog aCatalog;
+ aCatalog.Create();
+ if(aCatalog.IsValid())
+ {
+ aCatalog.putref_ActiveConnection(*pConnection->getConnection());
+ OCatalog* pCatalog = new OCatalog(aCatalog,pConnection);
+ xTab = pCatalog;
+ pConnection->setCatalog(xTab);
+ pConnection->setCatalog(pCatalog);
+ }
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL ODriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ impl_checkURL_throw(url);
+ return getDataDefinitionByConnection(connect(url,info));
+}
+
+// -----------------------------------------------------------------------------
+void ADOS::ThrowException(ADOConnection* _pAdoCon,const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ ADOErrors *pErrors = NULL;
+ _pAdoCon->get_Errors(&pErrors);
+ if(!pErrors)
+ return; // no error found
+
+ pErrors->AddRef( );
+
+ // alle aufgelaufenen Fehler auslesen und ausgeben
+ sal_Int32 nLen;
+ pErrors->get_Count(&nLen);
+ if (nLen)
+ {
+ ::rtl::OUString sError;
+ ::rtl::OUString aSQLState;
+ SQLException aException;
+ aException.ErrorCode = 1000;
+ for (sal_Int32 i = nLen-1; i>=0; --i)
+ {
+ ADOError *pError = NULL;
+ pErrors->get_Item(OLEVariant(i),&pError);
+ WpADOError aErr(pError);
+ OSL_ENSURE(pError,"No error in collection found! BAD!");
+ if(pError)
+ {
+ if(i==nLen-1)
+ aException = SQLException(aErr.GetDescription(),_xInterface,aErr.GetSQLState(),aErr.GetNumber(),Any());
+ else
+ {
+ SQLException aTemp = SQLException(aErr.GetDescription(),
+ _xInterface,aErr.GetSQLState(),aErr.GetNumber(),makeAny(aException));
+ aTemp.NextException <<= aException;
+ aException = aTemp;
+ }
+ }
+ }
+ pErrors->Clear();
+ pErrors->Release();
+ throw aException;
+ }
+ pErrors->Release();
+}
+
+
diff --git a/connectivity/source/drivers/ado/AGroup.cxx b/connectivity/source/drivers/ado/AGroup.cxx
new file mode 100644
index 000000000000..2058469d44da
--- /dev/null
+++ b/connectivity/source/drivers/ado/AGroup.cxx
@@ -0,0 +1,192 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADO_GROUP_HXX_
+#include "ado/AGroup.hxx"
+#endif
+#include "ado/AUsers.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
+#include "ado/AConnection.hxx"
+#endif
+#include "TConnection.hxx"
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+// -------------------------------------------------------------------------
+void WpADOGroup::Create()
+{
+ HRESULT hr = -1;
+ ADOGroup* pGroup = NULL;
+ hr = CoCreateInstance(ADOS::CLSID_ADOGROUP_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOGROUP_25,
+ (void**)&pGroup );
+
+
+ if( !FAILED( hr ) )
+ {
+ operator=( pGroup );
+ pGroup->Release();
+ }
+}
+// -------------------------------------------------------------------------
+OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, ADOGroup* _pGroup) : OGroup_ADO(_bCase),m_pCatalog(_pParent)
+{
+ construct();
+ if(_pGroup)
+ m_aGroup = WpADOGroup(_pGroup);
+ else
+ m_aGroup.Create();
+
+}
+// -------------------------------------------------------------------------
+OAdoGroup::OAdoGroup(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name) : OGroup_ADO(_Name,_bCase),m_pCatalog(_pParent)
+{
+ construct();
+ m_aGroup.Create();
+ m_aGroup.put_Name(_Name);
+}
+// -------------------------------------------------------------------------
+void OAdoGroup::refreshUsers()
+{
+ TStringVector aVector;
+
+ WpADOUsers aUsers = m_aGroup.get_Users();
+ aUsers.fillElementNames(aVector);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(m_pCatalog,m_aMutex,aVector,aUsers,isCaseSensitive());
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoGroup::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoGroup::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OGroup_ADO::getSomething(rId);
+}
+
+// -------------------------------------------------------------------------
+void OAdoGroup::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aGroup.IsValid())
+ {
+
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aGroup.put_Name(aVal);
+ }
+ break;
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OAdoGroup::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ if(m_aGroup.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ rValue <<= m_aGroup.get_Name();
+ break;
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OAdoGroup::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ return MapRight(m_aGroup.GetPermissions(objName,MapObjectType(objType)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdoGroup::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RightsEnum eNum = m_aGroup.GetPermissions(objName,MapObjectType(objType));
+ if(eNum & adRightWithGrant)
+ return MapRight(eNum);
+ return 0;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoGroup::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessGrant,Map2Right(objPrivileges));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoGroup::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ m_aGroup.SetPermissions(objName,MapObjectType(objType),adAccessDeny,Map2Right(objPrivileges));
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoGroup::acquire() throw()
+{
+ OGroup_ADO::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoGroup::release() throw()
+{
+ OGroup_ADO::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AGroups.cxx b/connectivity/source/drivers/ado/AGroups.cxx
new file mode 100644
index 000000000000..f5732ca16c91
--- /dev/null
+++ b/connectivity/source/drivers/ado/AGroups.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AGroups.hxx"
+#include "ado/AGroup.hxx"
+#include "ado/ATable.hxx"
+#include "ado/AConnection.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace comphelper;
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OGroups::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdoGroup(m_pCatalog,isCaseSensitive(),_rName);
+}
+// -------------------------------------------------------------------------
+void OGroups::impl_refresh() throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OGroups::createDescriptor()
+{
+ return new OAdoGroup(m_pCatalog,isCaseSensitive());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OGroups::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ OAdoGroup* pGroup = NULL;
+ if ( !getImplementation(pGroup,descriptor) || pGroup == NULL )
+ m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_GROUP_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ m_aCollection.Append( pGroup->getImpl() );
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OGroups::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ m_aCollection.Delete(_sElementName);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/ado/AIndex.cxx b/connectivity/source/drivers/ado/AIndex.cxx
new file mode 100644
index 000000000000..a55498494e87
--- /dev/null
+++ b/connectivity/source/drivers/ado/AIndex.cxx
@@ -0,0 +1,157 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AIndex.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "ado/AColumns.hxx"
+#include <comphelper/extract.hxx>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+// -------------------------------------------------------------------------
+OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection,ADOIndex* _pIndex)
+ : OIndex_ADO(::rtl::OUString(),::rtl::OUString(),sal_False,sal_False,sal_False,_bCase)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ m_aIndex = WpADOIndex(_pIndex);
+ fillPropertyValues();
+}
+// -------------------------------------------------------------------------
+OAdoIndex::OAdoIndex(sal_Bool _bCase,OConnection* _pConnection)
+ : OIndex_ADO(_bCase)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ m_aIndex.Create();
+}
+
+// -------------------------------------------------------------------------
+
+void OAdoIndex::refreshColumns()
+{
+ TStringVector aVector;
+
+ WpADOColumns aColumns;
+ if ( m_aIndex.IsValid() )
+ {
+ aColumns = m_aIndex.get_Columns();
+ aColumns.fillElementNames(aVector);
+ }
+
+ if ( m_pColumns )
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
+}
+
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoIndex::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OIndex_ADO::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoIndex::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aIndex.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aIndex.put_Name(aVal);
+ }
+ break;
+ case PROPERTY_ID_CATALOG:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aIndex.put_Name(aVal);
+ }
+ break;
+ case PROPERTY_ID_ISUNIQUE:
+ m_aIndex.put_Unique(getBOOL(rValue));
+ break;
+ case PROPERTY_ID_ISPRIMARYKEYINDEX:
+ m_aIndex.put_PrimaryKey(getBOOL(rValue));
+ break;
+ case PROPERTY_ID_ISCLUSTERED:
+ m_aIndex.put_Clustered(getBOOL(rValue));
+ break;
+ }
+ }
+ OIndex_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoIndex::acquire() throw()
+{
+ OIndex_ADO::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoIndex::release() throw()
+{
+ OIndex_ADO::release();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/ado/AIndexes.cxx b/connectivity/source/drivers/ado/AIndexes.cxx
new file mode 100644
index 000000000000..c6f6311d07ee
--- /dev/null
+++ b/connectivity/source/drivers/ado/AIndexes.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AIndexes.hxx"
+#include "ado/AIndex.hxx"
+#include "ado/AConnection.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+using namespace ::comphelper;
+
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+
+sdbcx::ObjectType OIndexes::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdoIndex(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName));
+}
+// -------------------------------------------------------------------------
+void OIndexes::impl_refresh() throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OIndexes::createDescriptor()
+{
+ return new OAdoIndex(isCaseSensitive(),m_pConnection);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ OAdoIndex* pIndex = NULL;
+ if ( !getImplementation(pIndex,descriptor) || pIndex == NULL )
+ m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ ADOIndexes* pIndexes = m_aCollection;
+ if ( FAILED( pIndexes->Append( OLEVariant( _rForName ), OLEVariant( pIndex->getImpl() ) ) ) )
+ {
+ ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this));
+ m_pConnection->throwGenericSQLException( STR_INVALID_INDEX_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+ }
+
+ return new OAdoIndex(isCaseSensitive(),m_pConnection,pIndex->getImpl());
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OIndexes::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ m_aCollection.Delete(_sElementName);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AKey.cxx b/connectivity/source/drivers/ado/AKey.cxx
new file mode 100644
index 000000000000..f053b4a83f6c
--- /dev/null
+++ b/connectivity/source/drivers/ado/AKey.cxx
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AKey.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "ado/AColumns.hxx"
+#include "ado/AConnection.hxx"
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+// -------------------------------------------------------------------------
+OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection, ADOKey* _pKey)
+ : OKey_ADO(_bCase)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ m_aKey = WpADOKey(_pKey);
+ fillPropertyValues();
+}
+// -------------------------------------------------------------------------
+OAdoKey::OAdoKey(sal_Bool _bCase,OConnection* _pConnection)
+ : OKey_ADO(_bCase)
+ ,m_pConnection(_pConnection)
+{
+ construct();
+ m_aKey.Create();
+}
+// -------------------------------------------------------------------------
+void OAdoKey::refreshColumns()
+{
+ TStringVector aVector;
+
+ WpADOColumns aColumns;
+ if ( m_aKey.IsValid() )
+ {
+ aColumns = m_aKey.get_Columns();
+ aColumns.fillElementNames(aVector);
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pConnection);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoKey::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoKey::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OKey_ADO::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+void OAdoKey::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aKey.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aKey.put_Name(aVal);
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ }
+ break;
+ case PROPERTY_ID_TYPE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aKey.put_Type(Map2KeyRule(nVal));
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ }
+ break;
+ case PROPERTY_ID_REFERENCEDTABLE:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aKey.put_RelatedTable(aVal);
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ }
+ break;
+ case PROPERTY_ID_UPDATERULE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aKey.put_UpdateRule(Map2Rule(nVal));
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ }
+ break;
+ case PROPERTY_ID_DELETERULE:
+ {
+ sal_Int32 nVal=0;
+ rValue >>= nVal;
+ m_aKey.put_DeleteRule(Map2Rule(nVal));
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ }
+ break;
+ }
+ }
+ OKey_ADO::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+}
+// -------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoKey::acquire() throw()
+{
+ OKey_ADO::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoKey::release() throw()
+{
+ OKey_ADO::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AKeyColumn.cxx b/connectivity/source/drivers/ado/AKeyColumn.cxx
new file mode 100644
index 000000000000..16870dc9edb4
--- /dev/null
+++ b/connectivity/source/drivers/ado/AKeyColumn.cxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_
+#include "adabas/BKeyColumn.hxx"
+#endif
+
+using namespace connectivity::adabas;
+namespace starbeans = ::com::sun::star::beans;
+// -------------------------------------------------------------------------
+OKeyColumn::OKeyColumn() : OColumn()
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OKeyColumn::OKeyColumn( const ::rtl::OUString& _ReferencedColumn,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _TypeName,
+ const ::rtl::OUString& _DefaultValue,
+ sal_Int32 _IsNullable,
+ sal_Int32 _Precision,
+ sal_Int32 _Scale,
+ sal_Int32 _Type,
+ sal_Bool _IsAutoIncrement
+ ) : OColumn(_Name,
+ _TypeName,
+ _DefaultValue,
+ _IsNullable,
+ _Precision,
+ _Scale,
+ _Type,
+ _IsAutoIncrement)
+ , m_ReferencedColumn(_ReferencedColumn)
+{
+ construct();
+}
+
+// -------------------------------------------------------------------------
+void OKeyColumn::construct()
+{
+ sal_Int32 nAttrib = isNew() ? 0 : starbeans::PropertyAttribute::READONLY;
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RELATEDCOLUMN), PROPERTY_ID_RELATEDCOLUMN, nAttrib,&m_ReferencedColumn, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+
diff --git a/connectivity/source/drivers/ado/AKeyColumns.cxx b/connectivity/source/drivers/ado/AKeyColumns.cxx
new file mode 100644
index 000000000000..37d8e77031e9
--- /dev/null
+++ b/connectivity/source/drivers/ado/AKeyColumns.cxx
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "adabas/BKeyColumns.hxx"
+#ifndef _CONNECTIVITY_ADABAS_KEYCOLUMN_HXX_
+#include "adabas/BKeyColumn.hxx"
+#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "adabas/BTable.hxx"
+
+using namespace connectivity::adabas;
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OKeyColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ Reference< starsdbc::XResultSet >
+ xResult = m_pTable->getConnection()->getMetaData()->getImportedKeys(Any(),
+ m_pTable->getSchema(),m_pTable->getName());
+
+ ::rtl::OUString aRefColumnName;
+ if(xResult.is())
+ {
+ Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(8) == _rName)
+ {
+ aRefColumnName = xRow->getString(4);
+ break;
+ }
+ }
+ }
+
+ xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< starsdbc::XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ OKeyColumn* pRet = new OKeyColumn(aRefColumnName,
+ _rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False);
+ xRet = pRet;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OKeyColumns::createDescriptor()
+{
+ OKeyColumn* pNew = new OKeyColumn();
+ return pNew;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/ado/AKeys.cxx b/connectivity/source/drivers/ado/AKeys.cxx
new file mode 100644
index 000000000000..dccf4b5a4cf5
--- /dev/null
+++ b/connectivity/source/drivers/ado/AKeys.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AKeys.hxx"
+#ifndef _CONNECTIVITY_ADO_INDEX_HXX_
+#include "ado/AKey.hxx"
+#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include "ado/AConnection.hxx"
+#include <comphelper/types.hxx>
+#include "ado/Awrapado.hxx"
+#include <comphelper/property.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+
+sdbcx::ObjectType OKeys::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdoKey(isCaseSensitive(),m_pConnection,m_aCollection.GetItem(_rName));
+}
+// -------------------------------------------------------------------------
+void OKeys::impl_refresh() throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OKeys::createDescriptor()
+{
+ return new OAdoKey(isCaseSensitive(),m_pConnection);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OKeys::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor )
+{
+ OAdoKey* pKey = NULL;
+ if ( !getImplementation( pKey, descriptor ) || pKey == NULL)
+ m_pConnection->throwGenericSQLException( STR_INVALID_KEY_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ // To pass as column parameter to Key's Apppend method
+ OLEVariant vOptional;
+ vOptional.setNoArg();
+
+#if OSL_DEBUG_LEVEL > 0
+ KeyTypeEnum eKey =
+#endif
+ OAdoKey::Map2KeyRule(getINT32(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+#if OSL_DEBUG_LEVEL > 0
+ (void)eKey;
+#endif
+
+ WpADOKey aKey = pKey->getImpl();
+ ::rtl::OUString sName = aKey.get_Name();
+ if(!sName.getLength())
+ aKey.put_Name(::rtl::OUString::createFromAscii("PrimaryKey") );
+
+ ADOKeys* pKeys = m_aCollection;
+ if ( FAILED(pKeys->Append(OLEVariant((ADOKey*)aKey),
+ adKeyPrimary, // must be every time adKeyPrimary
+ vOptional)) )
+ {
+ ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this));
+ // just make sure that an SQLExceptionis thrown here
+ m_pConnection->throwGenericSQLException( STR_INVALID_KEY_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+ }
+
+ return new OAdoKey(isCaseSensitive(),m_pConnection,pKey->getImpl());
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OKeys::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ if(!m_aCollection.Delete(OLEVariant(_sElementName)))
+ ADOS::ThrowException(*m_pConnection->getConnection(),static_cast<XTypeProvider*>(this));
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/APreparedStatement.cxx b/connectivity/source/drivers/ado/APreparedStatement.cxx
new file mode 100644
index 000000000000..077ab0d974c8
--- /dev/null
+++ b/connectivity/source/drivers/ado/APreparedStatement.cxx
@@ -0,0 +1,564 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "connectivity/sqlparse.hxx"
+#include "ado/APreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "ado/AResultSetMetaData.hxx"
+#include "ado/AResultSet.hxx"
+#include "ado/ADriver.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "resource/ado_res.hrc"
+
+#include <limits>
+
+#define CHECK_RETURN(x) \
+ if(!x) \
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+
+#ifdef max
+# undef max
+#endif
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+using namespace connectivity::ado;
+using namespace connectivity;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.APreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const OTypeInfoMap& _TypeInfo,const ::rtl::OUString& sql)
+ : OStatement_Base( _pConnection )
+ ,m_aTypeInfo(_TypeInfo)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ OSQLParser aParser(_pConnection->getDriver()->getORB());
+ ::rtl::OUString sErrorMessage;
+ ::rtl::OUString sNewSql;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,sql);
+ if(pNode)
+ { // special handling for parameters
+ /* we recusive replace all occurences of ? in the statement and replace them with name like "æ¬å" */
+ sal_Int32 nParameterCount = 0;
+ ::rtl::OUString sDefaultName = ::rtl::OUString::createFromAscii("parame");
+ replaceParameterNodeName(pNode,sDefaultName,nParameterCount);
+ pNode->parseNodeToStr( sNewSql, _pConnection );
+ delete pNode;
+ }
+ else
+ sNewSql = sql;
+ CHECK_RETURN(m_Command.put_CommandText(sNewSql))
+ CHECK_RETURN(m_Command.put_Prepared(VARIANT_TRUE))
+ m_pParameters = m_Command.get_Parameters();
+ m_pParameters->AddRef();
+ m_pParameters->Refresh();
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+// -------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+ if (m_pParameters)
+ {
+ OSL_ENSURE( sal_False, "OPreparedStatement::~OPreparedStatement: not disposed!" );
+ m_pParameters->Release();
+ m_pParameters = NULL;
+ }
+}
+
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_Base::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
+ static_cast< XPreparedStatement*>(this),
+ static_cast< XParameters*>(this),
+ static_cast< XPreparedBatchExecution*>(this),
+ static_cast< XResultSetMetaDataSupplier*>(this));
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_Base::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ if(!m_xMetaData.is() && m_RecordSet.IsValid())
+ m_xMetaData = new OResultSetMetaData(m_RecordSet);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::disposing()
+{
+m_xMetaData.clear();
+ if (m_pParameters)
+ {
+ m_pParameters->Release();
+ m_pParameters = NULL;
+ }
+ OStatement_Base::disposing();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException)
+{
+
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ SQLWarning warning;
+
+ // Reset warnings
+
+ clearWarnings ();
+
+ // Reset the statement handle, warning and saved Resultset
+
+ // reset();
+
+ // Call SQLExecute
+
+ try {
+ ADORecordset* pSet=NULL;
+ CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet))
+ m_RecordSet = WpADORecordset(pSet);
+ }
+ catch (SQLWarning& ex)
+ {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ warning = ex;
+ }
+ return m_RecordSet.IsValid();
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ ADORecordset* pSet=NULL;
+ CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdUnknown,&pSet))
+ if ( VT_ERROR == m_RecordsAffected.getType() )
+ {
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+ // to be sure that we get the error really thrown
+ throw SQLException();
+ }
+ m_RecordSet = WpADORecordset(pSet);
+ return static_cast<sal_Int32>(m_RecordsAffected);
+}
+
+// -------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const DataTypeEnum& _eType,
+ const sal_Int32& _nSize,const OLEVariant& _Val) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nCount = 0;
+ m_pParameters->get_Count(&nCount);
+ if(nCount < (parameterIndex-1))
+ {
+ ::rtl::OUString sDefaultName = ::rtl::OUString::createFromAscii("parame");
+ sDefaultName += ::rtl::OUString::valueOf(parameterIndex);
+ ADOParameter* pParam = m_Command.CreateParameter(sDefaultName,_eType,adParamInput,_nSize,_Val);
+ if(pParam)
+ {
+ m_pParameters->Append(pParam);
+#if OSL_DEBUG_LEVEL > 0
+ ADOParameter* pParam = NULL;
+ m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
+ WpADOParameter aParam(pParam);
+ if(pParam)
+ {
+ DataTypeEnum eType = aParam.GetADOType();
+ (void)eType;
+ }
+#endif
+ }
+ }
+ else
+ {
+ ADOParameter* pParam = NULL;
+ m_pParameters->get_Item(OLEVariant(sal_Int32(parameterIndex-1)),&pParam);
+ WpADOParameter aParam(pParam);
+ if(pParam)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sParam = aParam.GetName();
+
+#endif // OSL_DEBUG_LEVEL
+
+ DataTypeEnum eType = aParam.GetADOType();
+ if ( _eType != eType && _eType != adDBTimeStamp )
+ {
+ aParam.put_Type(_eType);
+ eType = _eType;
+ aParam.put_Size(_nSize);
+ }
+
+ if ( adVarBinary == eType && aParam.GetAttributes() == adParamLong )
+ {
+ aParam.AppendChunk(_Val);
+ }
+ else
+ CHECK_RETURN(aParam.PutValue(_Val));
+ }
+ }
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ setParameter( parameterIndex, adLongVarWChar, ::std::numeric_limits< sal_Int32 >::max(), x );
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ // first clear the old things
+m_xMetaData.clear();
+ disposeResultSet();
+ if(m_RecordSet.IsValid())
+ m_RecordSet.Close();
+ m_RecordSet.clear();
+
+
+ // the create the new onces
+ m_RecordSet.Create();
+ OLEVariant aCmd;
+ aCmd.setIDispatch(m_Command);
+ OLEVariant aCon;
+ aCon.setNoArg();
+ CHECK_RETURN(m_RecordSet.put_CacheSize(m_nFetchSize))
+ CHECK_RETURN(m_RecordSet.put_MaxRecords(m_nMaxRows))
+ CHECK_RETURN(m_RecordSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
+ CHECK_RETURN(m_RecordSet.get_CacheSize(m_nFetchSize))
+ CHECK_RETURN(m_RecordSet.get_MaxRecords(m_nMaxRows))
+ CHECK_RETURN(m_RecordSet.get_CursorType(m_eCursorType))
+ CHECK_RETURN(m_RecordSet.get_LockType(m_eLockType))
+
+ OResultSet* pSet = new OResultSet(m_RecordSet,this);
+ Reference< XResultSet > xRs = pSet;
+ pSet->construct();
+ pSet->setMetaData(getMetaData());
+ m_xResultSet = WeakReference<XResultSet>(xRs);
+
+ return xRs;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adBoolean,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adTinyInt,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adDBDate,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adDBTime,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adDBTimeStamp,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adDouble,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adSingle,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adInteger,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adBigInt,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ OLEVariant aVal;
+ aVal.setNull();
+ setParameter(parameterIndex,adEmpty,0,aVal);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ switch(sqlType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ setString(parameterIndex,::comphelper::getString(x));
+ break;
+ default:
+ ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale);
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ // setObject (parameterIndex, x, sqlType, 0);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adSmallInt,sizeof(x),x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,adVarBinary,sizeof(sal_Int8)*x.getLength(),x);
+}
+
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setCharacterStream", *this );
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ if(x.is())
+ {
+ Sequence< sal_Int8 > aData;
+ x->readBytes(aData,length);
+ setBytes(parameterIndex,aData);
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ if(m_pParameters)
+ {
+ sal_Int32 nCount = 0;
+ m_pParameters->get_Count(&nCount);
+ OLEVariant aVal;
+ aVal.setEmpty();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ ADOParameter* pParam = NULL;
+ m_pParameters->get_Item(OLEVariant(i),&pParam);
+ WpADOParameter aParam(pParam);
+ if(pParam)
+ {
+ ::rtl::OUString sParam = aParam.GetName();
+ CHECK_RETURN(aParam.PutValue(aVal));
+ }
+ }
+ // m_pParameters->Delete(OLEVariant(i));
+
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+ // clearParameters( );
+ // m_aBatchList.erase();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ return Sequence< sal_Int32 > ();
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OStatement_Base::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OStatement_Base::release();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::replaceParameterNodeName(OSQLParseNode* _pNode,
+ const ::rtl::OUString& _sDefaultName,
+ sal_Int32& _rParameterCount)
+{
+ sal_Int32 nCount = _pNode->count();
+ for(sal_Int32 i=0;i < nCount;++i)
+ {
+ OSQLParseNode* pChildNode = _pNode->getChild(i);
+ if(SQL_ISRULE(pChildNode,parameter) && pChildNode->count() == 1)
+ {
+ OSQLParseNode* pNewNode = new OSQLParseNode(::rtl::OUString::createFromAscii(":") ,SQL_NODE_PUNCTUATION,0);
+ delete pChildNode->replace(pChildNode->getChild(0),pNewNode);
+ ::rtl::OUString sParameterName = _sDefaultName;
+ sParameterName += ::rtl::OUString::valueOf(++_rParameterCount);
+ pChildNode->append(new OSQLParseNode( sParameterName,SQL_NODE_NAME,0));
+ }
+ else
+ replaceParameterNodeName(pChildNode,_sDefaultName,_rParameterCount);
+
+ }
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/AResultSet.cxx b/connectivity/source/drivers/ado/AResultSet.cxx
new file mode 100644
index 000000000000..c71d620d527c
--- /dev/null
+++ b/connectivity/source/drivers/ado/AResultSet.cxx
@@ -0,0 +1,1169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AResultSet.hxx"
+#include "ado/AResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <comphelper/seqstream.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+
+#include <oledb.h>
+
+#define CHECK_RETURN(x) \
+ if(!SUCCEEDED(x)) \
+ ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this);
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+//------------------------------------------------------------------------------
+// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.AResultSet","com.sun.star.sdbc.ResultSet");
+::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) \
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ado.ResultSet");
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw(::com::sun::star::uno::RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(ADORecordset* _pRecordSet,OStatement_Base* pStmt) : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_xStatement(*pStmt)
+ ,m_pStmt(pStmt)
+ ,m_nRowPos(0)
+ ,m_xMetaData(NULL)
+ ,m_pRecordSet(_pRecordSet)
+ ,m_bEOF(sal_False)
+{
+}
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(ADORecordset* _pRecordSet) : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_xStatement(NULL)
+ ,m_xMetaData(NULL)
+ ,m_pRecordSet(_pRecordSet)
+ ,m_bEOF(sal_False)
+{
+}
+// -----------------------------------------------------------------------------
+void OResultSet::construct()
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ if (!m_pRecordSet)
+ {
+ OSL_ENSURE( sal_False, "OResultSet::construct: no RecordSet!" );
+ Reference< XInterface > xInt( *this );
+ osl_decrementInterlockedCount( &m_refCount );
+ ::dbtools::throwFunctionSequenceException( xInt );
+ }
+ m_pRecordSet->AddRef();
+ VARIANT_BOOL bIsAtBOF;
+ CHECK_RETURN(m_pRecordSet->get_BOF(&bIsAtBOF))
+ m_bOnFirstAfterOpen = bIsAtBOF != VARIANT_TRUE;
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+ if(m_pRecordSet)
+ m_pRecordSet->Release();
+}
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if(m_pRecordSet)
+ m_pRecordSet->Close();
+m_xStatement.clear();
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+#define BLOCK_SIZE 256
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
+
+ if((aField.GetAttributes() & adFldLong) == adFldLong)
+ {
+ //Copy the data only upto the Actual Size of Field.
+ sal_Int32 nSize = aField.GetActualSize();
+ Sequence<sal_Int8> aData(nSize);
+ long index = 0;
+ while(index < nSize)
+ {
+ m_aValue = aField.GetChunk(BLOCK_SIZE);
+ if(m_aValue.isNull())
+ break;
+ UCHAR chData;
+ for(long index2 = 0;index2 < BLOCK_SIZE;++index2)
+ {
+ HRESULT hr = ::SafeArrayGetElement(m_aValue.parray,&index2,&chData);
+ if(SUCCEEDED(hr))
+ {
+ //Take BYTE by BYTE and advance Memory Location
+ aData.getArray()[index++] = chData;
+ }
+ else
+ break;
+ }
+ }
+
+ return new ::comphelper::SequenceInputStream(aData);
+ }
+ // else we ask for a bytesequence
+ aField.get_Value(m_aValue);
+
+ return m_aValue.isNull() ? NULL : new ::comphelper::SequenceInputStream(m_aValue);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getCharacterStream", *this );
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+OLEVariant OResultSet::getValue(sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
+ aField.get_Value(m_aValue);
+ return m_aValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ PositionEnum aPos;
+ m_pRecordSet->get_AbsolutePosition(&aPos);
+ return (aPos > 0) ? aPos : m_nRowPos;
+ // return the rowcount from driver if the driver doesn't support this return our count
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getLong", *this );
+ return sal_Int64(0);
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_pRecordSet);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getArray", *this );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getClob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getBlob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRow::getRef", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ VARIANT_BOOL bIsAtEOF;
+ CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF))
+ return bIsAtEOF == VARIANT_TRUE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(first())
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(SUCCEEDED(m_pRecordSet->MoveFirst()))
+ {
+ m_nRowPos = 1;
+ m_bOnFirstAfterOpen = sal_False;
+ return sal_True;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->MoveLast());
+ if(bRet)
+ {
+ m_pRecordSet->get_RecordCount(&m_nRowPos);
+ m_bOnFirstAfterOpen = sal_False;
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!row) // absolute with zero not allowed
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ sal_Bool bCheck = sal_True;
+ if(row < 0)
+ {
+ bCheck = SUCCEEDED(m_pRecordSet->MoveLast());
+ if ( bCheck )
+ {
+ while(++row < 0 && bCheck)
+ bCheck = SUCCEEDED(m_pRecordSet->MovePrevious());
+ }
+ }
+ else
+ {
+ first();
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ bCheck = SUCCEEDED(m_pRecordSet->Move(row-1,aEmpty)); // move to row -1 because we stand already on the first
+ if(bCheck)
+ m_nRowPos = row;
+ }
+ if(bCheck)
+ m_bOnFirstAfterOpen = sal_False;
+ return bCheck;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ sal_Int32 nNewPos = row;
+ if ( m_bOnFirstAfterOpen && nNewPos > 0 )
+ --nNewPos;
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->Move(row,aEmpty));
+ if(bRet)
+ {
+ m_nRowPos += row;
+ m_bOnFirstAfterOpen = sal_False;
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Bool bRet = SUCCEEDED(m_pRecordSet->MovePrevious());
+ if(bRet)
+ {
+ --m_nRowPos;
+ m_bOnFirstAfterOpen = sal_False;
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ sal_Bool bRet = (eRec & adRecDeleted) == adRecDeleted;
+ if(bRet)
+ --m_nRowPos;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ sal_Bool bRet = (eRec & adRecNew) == adRecNew;
+ if(bRet)
+ ++m_nRowPos;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ RecordStatusEnum eRec;
+ m_pRecordSet->get_Status((sal_Int32*)&eRec);
+ return (eRec & adRecModified) == adRecModified;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!");
+ VARIANT_BOOL bIsAtBOF = VARIANT_TRUE;
+ if(!m_bOnFirstAfterOpen)
+ {
+ OSL_ENSURE(!m_nRowPos,"OResultSet::isBeforeFirst: Error in setting m_nRowPos!");
+ m_pRecordSet->get_BOF(&bIsAtBOF);
+ }
+ return bIsAtBOF == VARIANT_TRUE;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Bool bRet = sal_True;
+ if(m_bOnFirstAfterOpen)
+ {
+ m_bOnFirstAfterOpen = sal_False;
+ ++m_nRowPos;
+ }
+ else
+ {
+ bRet = SUCCEEDED(m_pRecordSet->MoveNext());
+
+ if(bRet)
+ {
+ VARIANT_BOOL bIsAtEOF;
+ CHECK_RETURN(m_pRecordSet->get_EOF(&bIsAtEOF))
+ bRet = bIsAtEOF != VARIANT_TRUE;
+ ++m_nRowPos;
+ }
+ else
+ ADOS::ThrowException(*m_pStmt->m_pConnection->getConnection(),*this);
+ }
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_aValue.isNull();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_pRecordSet->Cancel();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ m_pRecordSet->AddNew(aEmpty,aEmpty);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+ m_pRecordSet->Update(aEmpty,aEmpty);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_pRecordSet->Delete(adAffectCurrent);
+ m_pRecordSet->UpdateBatch(adAffectCurrent);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_pRecordSet->CancelUpdate();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+void OResultSet::updateValue(sal_Int32 columnIndex,const OLEVariant& x)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,columnIndex);
+ aField.PutValue(x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ OLEVariant x;
+ x.setNull();
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateBytes(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateBytes(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_pRecordSet->Resync(adAffectCurrent,adResyncAllValues);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+//------------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OResultSet::getBookmark( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(m_nRowPos < (sal_Int32)m_aBookmarks.size()) // this bookmark was already fetched
+ return makeAny(sal_Int32(m_nRowPos-1));
+
+ OLEVariant aVar;
+ m_pRecordSet->get_Bookmark(&aVar);
+ m_aBookmarks.push_back(aVar);
+ return makeAny((sal_Int32)(m_aBookmarks.size()-1));
+
+}
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nPos;
+ bookmark >>= nPos;
+ OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector");
+ if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ return SUCCEEDED(m_pRecordSet->Move(0,m_aBookmarks[nPos]));
+}
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nPos;
+ bookmark >>= nPos;
+ nPos += rows;
+ OSL_ENSURE(nPos >= 0 && nPos < (sal_Int32)m_aBookmarks.size(),"Invalid Index for vector");
+ if(nPos < 0 || nPos >= (sal_Int32)m_aBookmarks.size())
+ ::dbtools::throwFunctionSequenceException(*this);
+ return SUCCEEDED(m_pRecordSet->Move(rows,m_aBookmarks[nPos]));
+}
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& first, const Any& second ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nPos1;
+ first >>= nPos1;
+ sal_Int32 nPos2;
+ second >>= nPos2;
+ if(nPos1 == nPos2) // they should be equal
+ return sal_True;
+
+ OSL_ENSURE((nPos1 >= 0 && nPos1 < (sal_Int32)m_aBookmarks.size()) || (nPos1 >= 0 && nPos2 < (sal_Int32)m_aBookmarks.size()),"Invalid Index for vector");
+
+ CompareEnum eNum;
+ m_pRecordSet->CompareBookmarks(m_aBookmarks[nPos1],m_aBookmarks[nPos2],&eNum);
+ return ((sal_Int32)eNum) +1;
+}
+//------------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ADOProperties* pProps = NULL;
+ m_pRecordSet->get_Properties(&pProps);
+ WpADOProperties aProps;
+ aProps.setWithOutAddRef(pProps);
+ ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this);
+ OSL_ENSURE(aProps.IsValid(),"There are no properties at the connection");
+
+ WpADOProperty aProp(aProps.GetItem(::rtl::OUString::createFromAscii("Bookmarks Ordered")));
+ OLEVariant aVar;
+ if(aProp.IsValid())
+ aVar = aProp.GetValue();
+ else
+ ADOS::ThrowException(*((OConnection*)m_pStmt->getConnection().get())->getConnection(),*this);
+
+ sal_Bool bValue(sal_False);
+ if(!aVar.isNull() && !aVar.isEmpty())
+ bValue = aVar;
+ return bValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& bookmark ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nPos;
+ bookmark >>= nPos;
+ return nPos;
+}
+//------------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OLEVariant aVar;
+ sal_Int32 nPos;
+
+ // Create SafeArray Bounds and initialize the array
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = rows.getLength();
+ SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ const Any* pBegin = rows.getConstArray();
+ const Any* pEnd = pBegin + rows.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd ;++pBegin,++i)
+ {
+ *pBegin >>= nPos;
+ SafeArrayPutElement(psa,&i,&m_aBookmarks[nPos]);
+ }
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ m_pRecordSet->put_Filter(vsa);
+ m_pRecordSet->Delete(adAffectGroup);
+ m_pRecordSet->UpdateBatch(adAffectGroup);
+
+ Sequence< sal_Int32 > aSeq(rows.getLength());
+ if(first())
+ {
+ sal_Int32* pSeq = aSeq.getArray();
+ sal_Int32 i=0;
+ do
+ {
+ OSL_ENSURE(i<aSeq.getLength(),"Index greater than length of sequence");
+ m_pRecordSet->get_Status(&pSeq[i]);
+ if(pSeq[i++] == adRecDeleted)
+ --m_nRowPos;
+ }
+ while(next());
+ }
+ return aSeq;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getResultSetConcurrency() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nValue=0;
+ LockTypeEnum eRet;
+ if(!SUCCEEDED(m_pRecordSet->get_LockType(&eRet)))
+ {
+ switch(eRet)
+ {
+ case adLockReadOnly:
+ nValue = ResultSetConcurrency::READ_ONLY;
+ break;
+ default:
+ nValue = ResultSetConcurrency::UPDATABLE;
+ break;
+ }
+ }
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getResultSetType() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nValue=0;
+ CursorTypeEnum eRet;
+ if(!SUCCEEDED(m_pRecordSet->get_CursorType(&eRet)))
+ {
+ switch(eRet)
+ {
+ case adOpenUnspecified:
+ case adOpenForwardOnly:
+ nValue = ResultSetType::FORWARD_ONLY;
+ break;
+ case adOpenStatic:
+ case adOpenKeyset:
+ nValue = ResultSetType::SCROLL_INSENSITIVE;
+ break;
+ case adOpenDynamic:
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ break;
+ }
+ }
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getFetchDirection() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return FetchDirection::FORWARD;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getFetchSize() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ sal_Int32 nValue=-1;
+ m_pRecordSet->get_CacheSize(&nValue);
+ return nValue;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString OResultSet::getCursorName() const
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return ::rtl::OUString();
+}
+
+//------------------------------------------------------------------------------
+void OResultSet::setFetchDirection(sal_Int32 /*_par0*/)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "ResultSet::FetchDirection", *this );
+}
+//------------------------------------------------------------------------------
+void OResultSet::setFetchSize(sal_Int32 _par0)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_pRecordSet->put_CacheSize(_par0);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ Sequence< com::sun::star::beans::Property > aProps(5);
+ com::sun::star::beans::Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+
+ // DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ case PROPERTY_ID_FETCHSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(getINT32(rValue));
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OResultSet::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ {
+ VARIANT_BOOL bBool;
+ m_pRecordSet->Supports(adBookmark,&bBool);
+ sal_Bool bRet = bBool == VARIANT_TRUE;
+ rValue.setValue(&bRet, ::getCppuBooleanType() );
+ }
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/AResultSetMetaData.cxx b/connectivity/source/drivers/ado/AResultSetMetaData.cxx
new file mode 100644
index 000000000000..41f8b6f45b75
--- /dev/null
+++ b/connectivity/source/drivers/ado/AResultSetMetaData.cxx
@@ -0,0 +1,262 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "ado/Awrapado.hxx"
+#include "connectivity/dbexception.hxx"
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+OResultSetMetaData::OResultSetMetaData( ADORecordset* _pRecordSet)
+ : m_pRecordSet(_pRecordSet),
+ m_nColCount(-1)
+{
+ if ( m_pRecordSet )
+ m_pRecordSet->AddRef();
+}
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+ if ( m_pRecordSet )
+ m_pRecordSet->Release();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid() && aField.GetActualSize() != -1)
+ return aField.GetActualSize();
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ return ADOS::MapADOType2Jdbc(aField.GetADOType());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ if(m_nColCount != -1 )
+ return m_nColCount;
+
+ if ( !m_pRecordSet )
+ return 0;
+
+ ADOFields* pFields = NULL;
+ m_pRecordSet->get_Fields(&pFields);
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields);
+ m_nColCount = aFields.GetItemCount();
+ return m_nColCount;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bRet = sal_False;
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if ( aField.IsValid() )
+ {
+ WpADOProperties aProps( aField.get_Properties() );
+ if ( aProps.IsValid() )
+ bRet = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ISCASESENSITIVE")) );
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ return aField.GetName();
+
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString sTableName;
+
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if ( aField.IsValid() )
+ {
+ WpADOProperties aProps( aField.get_Properties() );
+ if ( aProps.IsValid() )
+ sTableName = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BASETABLENAME")) );
+ }
+ return sTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ {
+ return ((aField.GetAttributes() & adFldFixed) == adFldFixed) && (aField.GetADOType() == adCurrency);
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bRet = sal_False;
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if ( aField.IsValid() )
+ {
+ WpADOProperties aProps( aField.get_Properties() );
+ if ( aProps.IsValid() )
+ {
+ bRet = OTools::getValue( aProps, ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ISAUTOINCREMENT")) );
+#if OSL_DEBUG_LEVEL > 0
+ sal_Int32 nCount = aProps.GetItemCount();
+ for (sal_Int32 i = 0; i<nCount; ++i)
+ {
+ WpADOProperty aProp = aProps.GetItem(i);
+ ::rtl::OUString sName = aProp.GetName();
+ ::rtl::OUString sVal = aProp.GetValue();
+ }
+#endif
+ }
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ {
+ DataTypeEnum eType = aField.GetADOType();
+ return !(eType == adUnsignedBigInt || eType == adUnsignedInt || eType == adUnsignedSmallInt || eType == adUnsignedTinyInt);
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ return aField.GetPrecision();
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ return aField.GetNumericScale();
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldIsNullable) == adFldIsNullable;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ {
+ // return (aField.GetStatus() & adFieldReadOnly) == adFieldReadOnly;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ WpADOField aField = ADOS::getField(m_pRecordSet,column);
+ if(aField.IsValid())
+ {
+ return (aField.GetAttributes() & adFldUpdatable) == adFldUpdatable;
+ }
+ return sal_False;
+;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return isDefinitelyWritable(column);
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/ado/AStatement.cxx b/connectivity/source/drivers/ado/AStatement.cxx
new file mode 100644
index 000000000000..27491954ad41
--- /dev/null
+++ b/connectivity/source/drivers/ado/AStatement.cxx
@@ -0,0 +1,841 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AStatement.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/AResultSet.hxx"
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/types.hxx>
+
+#undef max
+
+#include <algorithm>
+
+using namespace ::comphelper;
+
+#define CHECK_RETURN(x) \
+ if(!x) \
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+
+
+
+using namespace connectivity::ado;
+
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace ::std;
+//------------------------------------------------------------------------------
+OStatement_Base::OStatement_Base(OConnection* _pConnection ) : OStatement_BASE(m_aMutex)
+ ,OPropertySetHelper(OStatement_BASE::rBHelper)
+ ,OSubComponent<OStatement_Base, OStatement_BASE>((::cppu::OWeakObject*)_pConnection, this)
+ ,m_pConnection(_pConnection)
+ ,m_nFetchSize(1)
+ ,m_nMaxRows(0)
+ ,m_eLockType(adLockReadOnly)
+ ,m_eCursorType(adOpenForwardOnly)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ m_Command.Create();
+ if(m_Command.IsValid())
+ m_Command.putref_ActiveConnection(m_pConnection->getConnection());
+ else
+ ADOS::ThrowException(*m_pConnection->getConnection(),*this);
+
+ m_RecordsAffected.setNoArg();
+ m_Parameters.setNoArg();
+
+ m_pConnection->acquire();
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::disposeResultSet()
+{
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet = Reference< XResultSet>();
+}
+
+//------------------------------------------------------------------------------
+void OStatement_Base::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ disposeResultSet();
+
+ if ( m_Command.IsValid() )
+ m_Command.putref_ActiveConnection( NULL );
+ m_Command.clear();
+
+ if ( m_RecordSet.IsValid() )
+ m_RecordSet.PutRefDataSource( NULL );
+ m_RecordSet.clear();
+
+ if (m_pConnection)
+ m_pConnection->release();
+
+ dispose_ChildImpl();
+ OStatement_BASE::disposing();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::release() throw()
+{
+ relase_ChildImpl();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OStatement_Base::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ CHECK_RETURN(m_Command.Cancel())
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+
+}
+// -------------------------------------------------------------------------
+
+void OStatement_Base::reset() throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearWarnings ();
+
+ if (m_xResultSet.get().is())
+ clearMyResultSet();
+}
+//--------------------------------------------------------------------
+// clearMyResultSet
+// If a ResultSet was created for this Statement, close it
+//--------------------------------------------------------------------
+
+void OStatement_Base::clearMyResultSet () throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ Reference<XCloseable> xCloseable;
+ if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+
+ m_xResultSet = Reference< XResultSet >();
+}
+//--------------------------------------------------------------------
+sal_Int32 OStatement_Base::getRowCount () throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return m_RecordsAffected;
+}
+//--------------------------------------------------------------------
+// getPrecision
+// Given a SQL type, return the maximum precision for the column.
+// Returns -1 if not known
+//--------------------------------------------------------------------
+
+sal_Int32 OStatement_Base::getPrecision ( sal_Int32 sqlType)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 prec = -1;
+ OTypeInfo aInfo;
+ aInfo.nType = (sal_Int16)sqlType;
+ if (!m_aTypeInfo.empty())
+ {
+ ::std::vector<OTypeInfo>::const_iterator aIter = ::std::find(m_aTypeInfo.begin(),m_aTypeInfo.end(),aInfo);
+ for(;aIter != m_aTypeInfo.end();++aIter)
+ {
+ prec = ::std::max(prec,(*aIter).nPrecision);
+ }
+ }
+
+ return prec;
+}
+//--------------------------------------------------------------------
+// setWarning
+// Sets the warning
+//--------------------------------------------------------------------
+
+void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = ex;
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::assignRecordSet( ADORecordset* _pRS )
+{
+ WpADORecordset aOldRS( m_RecordSet );
+ m_RecordSet = WpADORecordset( _pRS );
+
+ if ( aOldRS.IsValid() )
+ aOldRS.PutRefDataSource( NULL );
+
+ if ( m_RecordSet.IsValid() )
+ m_RecordSet.PutRefDataSource( (IDispatch*)m_Command );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ // Reset the statement handle and warning
+
+ reset();
+
+ try
+ {
+ ADORecordset* pSet = NULL;
+ CHECK_RETURN(m_Command.put_CommandText(sql))
+ CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText,&pSet))
+
+ assignRecordSet( pSet );
+ }
+ catch (SQLWarning& ex)
+ {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ m_aLastWarning = ex;
+ }
+
+ return m_RecordSet.IsValid();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ reset();
+
+ m_xResultSet = WeakReference<XResultSet>(NULL);
+
+ WpADORecordset aSet;
+ aSet.Create();
+ CHECK_RETURN(m_Command.put_CommandText(sql))
+ OLEVariant aCmd;
+ aCmd.setIDispatch(m_Command);
+ OLEVariant aCon;
+ aCon.setNoArg();
+ CHECK_RETURN(aSet.put_CacheSize(m_nFetchSize))
+ CHECK_RETURN(aSet.put_MaxRecords(m_nMaxRows))
+ CHECK_RETURN(aSet.Open(aCmd,aCon,m_eCursorType,m_eLockType,adOpenUnspecified))
+
+
+ CHECK_RETURN(aSet.get_CacheSize(m_nFetchSize))
+ CHECK_RETURN(aSet.get_MaxRecords(m_nMaxRows))
+ CHECK_RETURN(aSet.get_CursorType(m_eCursorType))
+ CHECK_RETURN(aSet.get_LockType(m_eLockType))
+
+ OResultSet* pSet = new OResultSet(aSet,this);
+ Reference< XResultSet > xRs = pSet;
+ pSet->construct();
+
+ m_xResultSet = WeakReference<XResultSet>(xRs);
+
+ return xRs;
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
+ return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aBatchList.push_back(sql);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ reset();
+
+ ::rtl::OUString aBatchSql;
+ sal_Int32 nLen = 0;
+ for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
+ aBatchSql = aBatchSql + *i + ::rtl::OUString::createFromAscii(";");
+
+
+ if ( m_RecordSet.IsValid() )
+ m_RecordSet.PutRefDataSource( NULL );
+ m_RecordSet.clear();
+ m_RecordSet.Create();
+
+ CHECK_RETURN(m_Command.put_CommandText(aBatchSql))
+ if ( m_RecordSet.IsValid() )
+ m_RecordSet.PutRefDataSource((IDispatch*)m_Command);
+
+ CHECK_RETURN(m_RecordSet.UpdateBatch(adAffectAll))
+
+ ADORecordset* pSet=NULL;
+ Sequence< sal_Int32 > aRet(nLen);
+ sal_Int32* pArray = aRet.getArray();
+ for(sal_Int32 j=0;j<nLen;++j)
+ {
+ pSet = NULL;
+ OLEVariant aRecordsAffected;
+ if(m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
+ {
+ assignRecordSet( pSet );
+
+ sal_Int32 nValue;
+ if(m_RecordSet.get_RecordCount(nValue))
+ pArray[j] = nValue;
+ }
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ reset();
+
+ try {
+ ADORecordset* pSet = NULL;
+ CHECK_RETURN(m_Command.put_CommandText(sql))
+ CHECK_RETURN(m_Command.Execute(m_RecordsAffected,m_Parameters,adCmdText|adExecuteNoRecords,&pSet))
+ }
+ catch (SQLWarning& ex) {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ m_aLastWarning = ex;
+ }
+ if(!m_RecordsAffected.isEmpty() && !m_RecordsAffected.isNull() && m_RecordsAffected.getType() != VT_ERROR)
+ return m_RecordsAffected;
+
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return m_xResultSet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nRet;
+ if(m_RecordSet.IsValid() && m_RecordSet.get_RecordCount(nRet))
+ return nRet;
+ return -1;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ SQLWarning warning;
+
+ // clear previous warnings
+
+ clearWarnings ();
+
+ // Call SQLMoreResults
+
+ try
+ {
+ ADORecordset* pSet=NULL;
+ OLEVariant aRecordsAffected;
+ if(m_RecordSet.IsValid() && m_RecordSet.NextRecordset(aRecordsAffected,&pSet) && pSet)
+ assignRecordSet( pSet );
+ }
+ catch (SQLWarning &ex)
+ {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ warning = ex;
+ }
+ return m_RecordSet.IsValid();
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getQueryTimeOut() const throw(SQLException, RuntimeException)
+{
+ return m_Command.get_CommandTimeout();
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getMaxRows() const throw(SQLException, RuntimeException)
+{
+ sal_Int32 nRet=-1;
+ if(!(m_RecordSet.IsValid() && m_RecordSet.get_MaxRecords(nRet)))
+ ::dbtools::throwFunctionSequenceException(NULL);
+ return nRet;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getResultSetConcurrency() const throw(SQLException, RuntimeException)
+{
+ return m_eLockType;
+ sal_Int32 nValue=0;
+ switch(m_eLockType)
+ {
+ case adLockReadOnly:
+ nValue = ResultSetConcurrency::READ_ONLY;
+ break;
+ default:
+ nValue = ResultSetConcurrency::UPDATABLE;
+ break;
+ }
+
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getResultSetType() const throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue=0;
+ switch(m_eCursorType)
+ {
+ case adOpenUnspecified:
+ case adOpenForwardOnly:
+ nValue = ResultSetType::FORWARD_ONLY;
+ break;
+ case adOpenStatic:
+ case adOpenKeyset:
+ nValue = ResultSetType::SCROLL_INSENSITIVE;
+ break;
+ case adOpenDynamic:
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ break;
+ }
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getFetchDirection() const throw(SQLException, RuntimeException)
+{
+ return FetchDirection::FORWARD;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getFetchSize() const throw(SQLException, RuntimeException)
+{
+ return m_nFetchSize;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getMaxFieldSize() const throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString OStatement_Base::getCursorName() const throw(SQLException, RuntimeException)
+{
+ return m_Command.GetName();
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setQueryTimeOut(sal_Int32 seconds) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_Command.put_CommandTimeout(seconds);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_nMaxRows = _par0;
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ switch(_par0)
+ {
+ case ResultSetConcurrency::READ_ONLY:
+ m_eLockType = adLockReadOnly;
+ break;
+ default:
+ m_eLockType = adLockOptimistic;
+ break;
+ }
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ switch(_par0)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ m_eCursorType = adOpenForwardOnly;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ m_eCursorType = adOpenKeyset;
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ m_eCursorType = adOpenDynamic;
+ break;
+ }
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setFetchDirection(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "Statement::FetchDirection", *this );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_nFetchSize = _par0;
+ // m_RecordSet.put_CacheSize(_par0);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setMaxFieldSize(sal_Int32 /*_par0*/) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "Statement::MaxFieldSize", *this );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_Command.put_Name(_par0);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
+{
+ Sequence< com::sun::star::beans::Property > aProps(10);
+ com::sun::star::beans::Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
+{
+ return *const_cast<OStatement_Base*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OStatement_Base::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bModified = sal_False;
+
+ sal_Bool bValidAdoRS = m_RecordSet.IsValid();
+ // some of the properties below, when set, are remembered in a member, and applied in the next execute
+ // For these properties, the record set does not need to be valid to allow setting them.
+ // For all others (where the values are forwarded to the ADO RS directly), the recordset must be valid.
+
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_MAXROWS:
+ bModified = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, bValidAdoRS ? getMaxRows() : m_nMaxRows );
+ break;
+
+ case PROPERTY_ID_RESULTSETTYPE:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
+ break;
+ case PROPERTY_ID_QUERYTIMEOUT:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ bModified = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ break;
+ }
+ }
+ catch( const Exception& e )
+ {
+ bModified = sal_True; // will ensure that the property is set
+ OSL_ENSURE( sal_False, "OStatement_Base::convertFastPropertyValue: caught something strange!" );
+ (void)e;
+ }
+ return bModified;
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ setQueryTimeOut(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ setMaxFieldSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXROWS:
+ setMaxRows(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ setCursorName(comphelper::getString(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ setResultSetConcurrency(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ setResultSetType(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
+ case PROPERTY_ID_USEBOOKMARKS:
+ // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ rValue <<= getQueryTimeOut();
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ rValue <<= getMaxFieldSize();
+ break;
+ case PROPERTY_ID_MAXROWS:
+ rValue <<= getMaxRows();
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ rValue <<= sal_True;
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+OStatement::~OStatement()
+{
+}
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.AStatement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::acquire() throw()
+{
+ OStatement_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OStatement_Base::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OStatement_Base::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/ado/ATable.cxx b/connectivity/source/drivers/ado/ATable.cxx
new file mode 100644
index 000000000000..2450ec6f969d
--- /dev/null
+++ b/connectivity/source/drivers/ado/ATable.cxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ATable.hxx"
+#include "ado/AIndexes.hxx"
+#include "ado/AColumns.hxx"
+#include "ado/AColumn.hxx"
+#include "ado/AKeys.hxx"
+#include "ado/AConnection.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "ado/Awrapado.hxx"
+#include <comphelper/sequence.hxx>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog,_ADOTable* _pTable)
+ : OTable_TYPEDEF(_pTables,_bCase,::rtl::OUString(),::rtl::OUString())
+ ,m_pCatalog(_pCatalog)
+{
+ construct();
+ m_aTable = WpADOTable(_pTable);
+ // m_aTable.putref_ParentCatalog(_pCatalog->getCatalog());
+ fillPropertyValues();
+
+}
+// -----------------------------------------------------------------------------
+OAdoTable::OAdoTable(sdbcx::OCollection* _pTables,sal_Bool _bCase,OCatalog* _pCatalog)
+ : OTable_TYPEDEF(_pTables,_bCase)
+ ,m_pCatalog(_pCatalog)
+{
+ construct();
+ m_aTable.Create();
+ m_aTable.putref_ParentCatalog(_pCatalog->getCatalog());
+
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoTable::disposing(void)
+{
+ OTable_TYPEDEF::disposing();
+ m_aTable.clear();
+}
+// -------------------------------------------------------------------------
+void OAdoTable::refreshColumns()
+{
+ TStringVector aVector;
+
+ WpADOColumns aColumns;
+ if ( m_aTable.IsValid() )
+ {
+ aColumns = m_aTable.get_Columns();
+ aColumns.fillElementNames(aVector);
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OColumns(*this,m_aMutex,aVector,aColumns,isCaseSensitive(),m_pCatalog->getConnection());
+}
+// -------------------------------------------------------------------------
+void OAdoTable::refreshKeys()
+{
+ TStringVector aVector;
+
+ WpADOKeys aKeys;
+ if(m_aTable.IsValid())
+ {
+ aKeys = m_aTable.get_Keys();
+ aKeys.fillElementNames(aVector);
+ }
+
+ if(m_pKeys)
+ m_pKeys->reFill(aVector);
+ else
+ m_pKeys = new OKeys(*this,m_aMutex,aVector,aKeys,isCaseSensitive(),m_pCatalog->getConnection());
+}
+// -------------------------------------------------------------------------
+void OAdoTable::refreshIndexes()
+{
+ TStringVector aVector;
+
+ WpADOIndexes aIndexes;
+ if(m_aTable.IsValid())
+ {
+ aIndexes = m_aTable.get_Indexes();
+ aIndexes.fillElementNames(aVector);
+ }
+
+ if(m_pIndexes)
+ m_pIndexes->reFill(aVector);
+ else
+ m_pIndexes = new OIndexes(*this,m_aMutex,aVector,aIndexes,isCaseSensitive(),m_pCatalog->getConnection());
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+// XRename
+void SAL_CALL OAdoTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed);
+
+ m_aTable.put_Name(newName);
+ ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this);
+
+ OTable_TYPEDEF::rename(newName);
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> OAdoTable::getMetaData() const
+{
+ return m_pCatalog->getConnection()->getMetaData();
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OAdoTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed);
+
+ sal_Bool bError = sal_True;
+ OAdoColumn* pColumn = NULL;
+ if(::comphelper::getImplementation(pColumn,descriptor) && pColumn != NULL)
+ {
+ WpADOColumns aColumns = m_aTable.get_Columns();
+ bError = !aColumns.Delete(colName);
+ bError = bError || !aColumns.Append(pColumn->getColumnImpl());
+ }
+ if(bError)
+ ADOS::ThrowException(*(m_pCatalog->getConnection()->getConnection()),*this);
+
+ m_pColumns->refresh();
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE_TYPEDEF::rBHelper.bDisposed);
+
+ Reference< XPropertySet > xOld;
+ m_pColumns->getByIndex(index) >>= xOld;
+ if(xOld.is())
+ alterColumnByName(getString(xOld->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),descriptor);
+}
+// -------------------------------------------------------------------------
+void OAdoTable::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aTable.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ m_aTable.put_Name(getString(rValue));
+ break;
+
+ case PROPERTY_ID_TYPE:
+ OTools::putValue( m_aTable.get_Properties(),
+ OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),
+ getString(rValue));
+ break;
+
+ case PROPERTY_ID_DESCRIPTION:
+ OTools::putValue( m_aTable.get_Properties(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Description")),
+ getString(rValue));
+ break;
+
+ case PROPERTY_ID_SCHEMANAME:
+ break;
+
+ default:
+ throw Exception();
+ }
+ }
+ OTable_TYPEDEF::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoTable::acquire() throw()
+{
+ OTable_TYPEDEF::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoTable::release() throw()
+{
+ OTable_TYPEDEF::release();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OAdoTable::getName() throw(::com::sun::star::uno::RuntimeException)
+{
+ return m_aTable.get_Name();
+}
+
diff --git a/connectivity/source/drivers/ado/ATables.cxx b/connectivity/source/drivers/ado/ATables.cxx
new file mode 100644
index 000000000000..d64fcb94057b
--- /dev/null
+++ b/connectivity/source/drivers/ado/ATables.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ATables.hxx"
+#include "ado/ATable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "ado/ACatalog.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/Awrapado.hxx"
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <cppuhelper/interfacecontainer.h>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace comphelper;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::lang;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ return new OAdoTable(this,isCaseSensitive(),m_pCatalog,m_aCollection.GetItem(_rName));
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ m_aCollection.Refresh();
+ m_pCatalog->refreshTables();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OAdoTable(this,isCaseSensitive(),m_pCatalog);
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString&, const Reference< XPropertySet >& descriptor )
+{
+ OAdoTable* pTable = NULL;
+ if ( !getImplementation( pTable, descriptor ) || pTable == NULL )
+ m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_TABLE_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ if(!m_aCollection.Append(pTable->getImpl()))
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
+ m_aCollection.Refresh();
+
+ return new OAdoTable(this,isCaseSensitive(),m_pCatalog,pTable->getImpl());
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTables::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ if ( !m_aCollection.Delete(_sElementName) )
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
+}
+// -----------------------------------------------------------------------------
+void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
+{
+ OSL_ENSURE(m_aCollection.IsValid(),"Collection isn't valid");
+ m_aCollection.Refresh();
+
+ insertElement(_rsNewTable,NULL);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AUser.cxx b/connectivity/source/drivers/ado/AUser.cxx
new file mode 100644
index 000000000000..99733d1f79e5
--- /dev/null
+++ b/connectivity/source/drivers/ado/AUser.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AUser.hxx"
+#include "ado/ACatalog.hxx"
+#include "ado/AGroups.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#ifndef _CONNECTIVITY_ADO_BCONNECTION_HXX_
+#include "ado/AConnection.hxx"
+#endif
+#include "ado/Awrapado.hxx"
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+// -------------------------------------------------------------------------
+OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser)
+ : OUser_TYPEDEF(_bCase)
+ ,m_pCatalog(_pParent)
+{
+ construct();
+
+ if(_pUser)
+ m_aUser = WpADOUser(_pUser);
+ else
+ m_aUser.Create();
+}
+// -------------------------------------------------------------------------
+OAdoUser::OAdoUser(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name)
+ : OUser_TYPEDEF(_Name,_bCase)
+ , m_pCatalog(_pParent)
+{
+ construct();
+ m_aUser.Create();
+ m_aUser.put_Name(_Name);
+}
+// -------------------------------------------------------------------------
+void OAdoUser::refreshGroups()
+{
+ TStringVector aVector;
+ WpADOGroups aGroups(m_aUser.get_Groups());
+ aGroups.fillElementNames(aVector);
+ if(m_pGroups)
+ m_pGroups->reFill(aVector);
+ else
+ m_pGroups = new OGroups(m_pCatalog,m_aMutex,aVector,aGroups,isCaseSensitive());
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoUser::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoUser::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OUser_TYPEDEF::getSomething(rId);
+}
+
+// -------------------------------------------------------------------------
+void OAdoUser::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue)throw (Exception)
+{
+ if(m_aUser.IsValid())
+ {
+
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ {
+ ::rtl::OUString aVal;
+ rValue >>= aVal;
+ m_aUser.put_Name(aVal);
+ }
+ break;
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OAdoUser::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ if(m_aUser.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ rValue <<= m_aUser.get_Name();
+ break;
+ }
+ }
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, ADOUser* _pUser)
+ : OAdoUser(_pParent,_bCase,_pUser)
+{
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend(OCatalog* _pParent,sal_Bool _bCase, const ::rtl::OUString& _Name)
+ : OAdoUser(_pParent,_bCase,_Name)
+{
+}
+
+// -------------------------------------------------------------------------
+void OUserExtend::construct()
+{
+ OUser_TYPEDEF::construct();
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< com::sun::star::beans::Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoUser::acquire() throw()
+{
+ OUser_TYPEDEF::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoUser::release() throw()
+{
+ OUser_TYPEDEF::release();
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdoUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
+
+ return ADOS::mapAdoRights2Sdbc(m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OAdoUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
+
+ sal_Int32 nRights = 0;
+ RightsEnum eRights = m_aUser.GetPermissions(objName, ADOS::mapObjectType2Ado(objType));
+ if((eRights & adRightWithGrant) == adRightWithGrant)
+ nRights = ADOS::mapAdoRights2Sdbc(eRights);
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this);
+ return nRights;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
+ m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessGrant,RightsEnum(ADOS::mapRights2Ado(objPrivileges)));
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OAdoUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
+ m_aUser.SetPermissions(objName,ADOS::mapObjectType2Ado(objType),adAccessRevoke,RightsEnum(ADOS::mapRights2Ado(objPrivileges)));
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this);
+}
+// -----------------------------------------------------------------------------
+// XUser
+void SAL_CALL OAdoUser::changePassword( const ::rtl::OUString& objPassword, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_TYPEDEF::rBHelper.bDisposed);
+ m_aUser.ChangePassword(objPassword,newPassword);
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),*this);
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/connectivity/source/drivers/ado/AUsers.cxx b/connectivity/source/drivers/ado/AUsers.cxx
new file mode 100644
index 000000000000..f3877af922e2
--- /dev/null
+++ b/connectivity/source/drivers/ado/AUsers.cxx
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AUsers.hxx"
+#include "ado/AUser.hxx"
+#include "ado/ATable.hxx"
+#include "ado/AConnection.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace comphelper;
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
+{
+ return new OAdoUser(m_pCatalog,isCaseSensitive(),_rName);
+}
+// -------------------------------------------------------------------------
+void OUsers::impl_refresh() throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ return new OUserExtend(m_pCatalog,isCaseSensitive());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ OUserExtend* pUser = NULL;
+ if ( !getImplementation( pUser, descriptor ) || pUser == NULL )
+ m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_USER_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ ADOUsers* pUsers = (ADOUsers*)m_aCollection;
+ pUsers->Append(OLEVariant(pUser->getImpl()),OLEString(pUser->getPassword()));
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ m_aCollection.Delete(_sElementName);
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AView.cxx b/connectivity/source/drivers/ado/AView.cxx
new file mode 100644
index 000000000000..a6f9f419d091
--- /dev/null
+++ b/connectivity/source/drivers/ado/AView.cxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AView.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "ado/adoimp.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "ado/Awrapado.hxx"
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include "TConnection.hxx"
+
+// -------------------------------------------------------------------------
+using namespace comphelper;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+// IMPLEMENT_SERVICE_INFO(OAdoView,"com.sun.star.sdbcx.AView","com.sun.star.sdbcx.View");
+// -------------------------------------------------------------------------
+OAdoView::OAdoView(sal_Bool _bCase,ADOView* _pView) : OView_ADO(_bCase,NULL)
+,m_aView(_pView)
+{
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OAdoView::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OAdoView::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OView_ADO::getSomething(rId);
+}
+
+// -------------------------------------------------------------------------
+void OAdoView::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ if(m_aView.IsValid())
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_NAME:
+ rValue <<= m_aView.get_Name();
+ break;
+ case PROPERTY_ID_CATALOGNAME:
+ break;
+ case PROPERTY_ID_SCHEMANAME:
+ // rValue <<= m_aView.get_Type();
+ break;
+ case PROPERTY_ID_COMMAND:
+ {
+ OLEVariant aVar;
+ m_aView.get_Command(aVar);
+ if(!aVar.isNull() && !aVar.isEmpty())
+ {
+ ADOCommand* pCom = (ADOCommand*)aVar.getIDispatch();
+ OLEString aBSTR;
+ pCom->get_CommandText(&aBSTR);
+ rValue <<= (::rtl::OUString) aBSTR;
+ }
+ }
+ break;
+ }
+ }
+ else
+ OView_ADO::getFastPropertyValue(rValue,nHandle);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoView::acquire() throw()
+{
+ OView_ADO::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OAdoView::release() throw()
+{
+ OView_ADO::release();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/ado/AViews.cxx b/connectivity/source/drivers/ado/AViews.cxx
new file mode 100644
index 000000000000..350daef0cb71
--- /dev/null
+++ b/connectivity/source/drivers/ado/AViews.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/AViews.hxx"
+#include "ado/AView.hxx"
+#include "ado/ATables.hxx"
+#include "ado/ACatalog.hxx"
+#include "ado/AConnection.hxx"
+#include "ado/Awrapado.hxx"
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/ado_res.hrc"
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+
+sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName)
+{
+ OAdoView* pView = new OAdoView(isCaseSensitive(),m_aCollection.GetItem(_rName));
+ pView->setNew(sal_False);
+ return pView;
+}
+// -------------------------------------------------------------------------
+void OViews::impl_refresh( ) throw(RuntimeException)
+{
+ m_aCollection.Refresh();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OViews::createDescriptor()
+{
+ return new OAdoView(isCaseSensitive());
+}
+
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ OAdoView* pView = NULL;
+ if ( !getImplementation( pView, descriptor ) || pView == NULL )
+ m_pCatalog->getConnection()->throwGenericSQLException( STR_INVALID_VIEW_DESCRIPTOR_ERROR,static_cast<XTypeProvider*>(this) );
+
+ WpADOCommand aCommand;
+ aCommand.Create();
+ if ( !aCommand.IsValid() )
+ m_pCatalog->getConnection()->throwGenericSQLException( STR_VIEW_NO_COMMAND_ERROR,static_cast<XTypeProvider*>(this) );
+
+ ::rtl::OUString sName( _rForName );
+ aCommand.put_Name(sName);
+ aCommand.put_CommandText(getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND))));
+ ADOViews* pViews = (ADOViews*)m_aCollection;
+ if(FAILED(pViews->Append(OLEString(sName),aCommand)))
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
+
+ OTables* pTables = static_cast<OTables*>(static_cast<OCatalog&>(m_rParent).getPrivateTables());
+ if ( pTables )
+ pTables->appendNew(sName);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OViews::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ if(!m_aCollection.Delete(_sElementName))
+ ADOS::ThrowException(*m_pCatalog->getConnection()->getConnection(),static_cast<XTypeProvider*>(this));
+}
+// -------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/ado/Aolevariant.cxx b/connectivity/source/drivers/ado/Aolevariant.cxx
new file mode 100644
index 000000000000..3f04d359cba0
--- /dev/null
+++ b/connectivity/source/drivers/ado/Aolevariant.cxx
@@ -0,0 +1,791 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/Aolevariant.hxx"
+#include "connectivity/dbconversion.hxx"
+#include <com/sun/star/sdbc/SQLException.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include "diagnose_ex.h"
+#include "resource/sharedresources.hxx"
+#include "resource/ado_res.hrc"
+#include "com/sun/star/bridge/oleautomation/Date.hpp"
+#include "com/sun/star/bridge/oleautomation/Currency.hpp"
+#include "com/sun/star/bridge/oleautomation/SCode.hpp"
+#include "com/sun/star/bridge/oleautomation/Decimal.hpp"
+
+using namespace com::sun::star::beans;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::bridge::oleautomation;
+using namespace connectivity::ado;
+using ::rtl::OUString;
+
+OLEString::OLEString()
+ :m_sStr(NULL)
+{
+}
+OLEString::OLEString(const BSTR& _sBStr)
+ :m_sStr(_sBStr)
+{
+}
+OLEString::OLEString(const ::rtl::OUString& _sBStr)
+{
+ m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_sBStr.getStr()));
+}
+OLEString::~OLEString()
+{
+ if(m_sStr)
+ ::SysFreeString(m_sStr);
+}
+OLEString& OLEString::operator=(const ::rtl::OUString& _rSrc)
+{
+ if(m_sStr)
+ ::SysFreeString(m_sStr);
+ m_sStr = ::SysAllocString(reinterpret_cast<LPCOLESTR>(_rSrc.getStr()));
+ return *this;
+}
+OLEString& OLEString::operator=(const OLEString& _rSrc)
+{
+ if(this != &_rSrc)
+ {
+ if(m_sStr)
+ ::SysFreeString(m_sStr);
+ m_sStr = ::SysAllocString(_rSrc.m_sStr);
+ }
+ return *this;
+}
+OLEString& OLEString::operator=(const BSTR& _rSrc)
+{
+ if(m_sStr)
+ ::SysFreeString(m_sStr);
+ m_sStr = _rSrc;
+ return *this;
+}
+OLEString::operator ::rtl::OUString() const
+{
+ return (m_sStr != NULL) ? ::rtl::OUString(reinterpret_cast<const sal_Unicode*>(LPCOLESTR(m_sStr)),::SysStringLen(m_sStr)) : ::rtl::OUString();
+}
+OLEString::operator BSTR() const
+{
+ return m_sStr;
+}
+BSTR* OLEString::operator &()
+{
+ return &m_sStr;
+}
+sal_Int32 OLEString::length() const
+{
+ return (m_sStr != NULL) ? ::SysStringLen(m_sStr) : 0;
+}
+
+OLEVariant::OLEVariant()
+{
+ VariantInit(this);
+}
+OLEVariant::OLEVariant(const VARIANT& varSrc)
+{
+ ::VariantInit(this);
+ HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc));
+ OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
+ OSL_UNUSED(eRet);
+}
+OLEVariant::OLEVariant(const OLEVariant& varSrc)
+{
+ ::VariantInit(this);
+ HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc)));
+ OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
+ OSL_UNUSED(eRet);
+}
+
+OLEVariant::OLEVariant(sal_Bool x) { VariantInit(this); vt = VT_BOOL; boolVal = (x ? VARIANT_TRUE : VARIANT_FALSE);}
+OLEVariant::OLEVariant(sal_Int8 n) { VariantInit(this); vt = VT_I1; bVal = n;}
+OLEVariant::OLEVariant(sal_Int16 n) { VariantInit(this); vt = VT_I2; intVal = n;}
+OLEVariant::OLEVariant(sal_Int32 n) { VariantInit(this); vt = VT_I4; lVal = n;}
+OLEVariant::OLEVariant(sal_Int64 x) { VariantInit(this); vt = VT_I4; lVal = (LONG)x;}
+
+OLEVariant::OLEVariant(const rtl::OUString& us)
+{
+ ::VariantInit(this);
+ vt = VT_BSTR;
+ bstrVal = SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr()));
+}
+OLEVariant::~OLEVariant()
+{
+ HRESULT eRet = ::VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+} // clears all the memory that was allocated before
+
+OLEVariant::OLEVariant(const ::com::sun::star::util::Date& x )
+{
+ VariantInit(this);
+ vt = VT_DATE;
+ dblVal = ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899));
+}
+OLEVariant::OLEVariant(const ::com::sun::star::util::Time& x )
+{
+ VariantInit(this);
+ vt = VT_DATE;
+ dblVal = ::dbtools::DBTypeConversion::toDouble(x);
+}
+OLEVariant::OLEVariant(const ::com::sun::star::util::DateTime& x )
+{
+ VariantInit(this);
+ vt = VT_DATE;
+ dblVal = ::dbtools::DBTypeConversion::toDouble(x,::com::sun::star::util::Date(30,12,1899));
+}
+OLEVariant::OLEVariant(const float &x)
+{
+ VariantInit(this);
+ vt = VT_R4;
+ fltVal = x;
+}
+OLEVariant::OLEVariant(const double &x)
+{
+ VariantInit(this);
+ vt = VT_R8;
+ dblVal = x;
+}
+
+
+OLEVariant::OLEVariant(IDispatch* pDispInterface)
+{
+ VariantInit(this);
+ setIDispatch( pDispInterface );
+}
+
+OLEVariant::OLEVariant(const ::com::sun::star::uno::Sequence< sal_Int8 >& x)
+{
+ VariantInit(this);
+
+ vt = VT_ARRAY|VT_UI1;
+
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = x.getLength();
+ // parray = SafeArrayCreate(VT_UI1,1,rgsabound);
+ parray = SafeArrayCreateVector(VT_UI1, 0, x.getLength());
+ const sal_Int8* pBegin = x.getConstArray();
+ const sal_Int8* pEnd = pBegin + x.getLength();
+
+ for(sal_Int32 i=0;pBegin != pEnd;++i,++pBegin)
+ {
+ sal_Int32 nData = *pBegin;
+ HRESULT rs = SafeArrayPutElement(parray,&i,&nData);
+ OSL_ENSURE(S_OK == rs,"Error while copy byte data");
+ OSL_UNUSED(rs);
+ }
+}
+//
+OLEVariant& OLEVariant::operator=(const OLEVariant& varSrc)
+{
+ HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(static_cast<const VARIANT*>(&varSrc)));
+ OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
+ OSL_UNUSED(eRet);
+ return *this;
+}
+// Assign a const VARIANT& (::VariantCopy handles everything)
+//
+OLEVariant& OLEVariant::operator=(const tagVARIANT& varSrc)
+{
+ HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(&varSrc));
+ OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
+ OSL_UNUSED(eRet);
+
+ return *this;
+}
+
+// Assign a const VARIANT* (::VariantCopy handles everything)
+//
+OLEVariant& OLEVariant::operator=(const VARIANT* pSrc)
+{
+ HRESULT eRet = ::VariantCopy(this, const_cast<VARIANT*>(pSrc));
+ OSL_ENSURE(eRet == S_OK,"Error while copying an ado variant!");
+ OSL_UNUSED(eRet);
+
+ return *this;
+}
+
+void OLEVariant::setByte(sal_uInt8 n)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_UI1;
+ bVal = n;
+}
+void OLEVariant::setInt16(sal_Int16 n)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_I2;
+ iVal = n;
+}
+void OLEVariant::setInt32(sal_Int32 n)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_I4;
+ lVal = n;
+}
+void OLEVariant::setFloat(float f)
+{ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_R4;
+ fltVal = f;
+}
+void OLEVariant::setDouble(double d)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_R8;
+ dblVal = d;
+}
+void OLEVariant::setDate(DATE d)
+{ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_DATE;
+ date = d;
+}
+void OLEVariant::setChar(unsigned char a)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_UI1;
+ bVal = a;
+}
+void OLEVariant::setCurrency(double aCur)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_CY;
+ set(aCur*10000);
+}
+void OLEVariant::setBool(sal_Bool b)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_BOOL;
+ boolVal = b ? VARIANT_TRUE : VARIANT_FALSE;
+}
+void OLEVariant::setString(const rtl::OUString& us)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_BSTR;
+ bstrVal = ::SysAllocString(reinterpret_cast<LPCOLESTR>(us.getStr()));
+}
+void OLEVariant::setNoArg()
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_ERROR;
+ scode = DISP_E_PARAMNOTFOUND;
+}
+
+void OLEVariant::setNull()
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_NULL;
+}
+void OLEVariant::setEmpty()
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_EMPTY;
+}
+
+void OLEVariant::setUI1SAFEARRAYPtr(SAFEARRAY* pSafeAr)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = VT_ARRAY|VT_UI1; parray = pSafeAr;
+}
+
+void OLEVariant::setArray(SAFEARRAY* pSafeArray, VARTYPE vtType)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+ vt = (VARTYPE)(VT_ARRAY|vtType);
+ parray = pSafeArray;
+}
+
+void OLEVariant::setIDispatch(IDispatch* pDispInterface)
+{
+ HRESULT eRet = VariantClear(this);
+ OSL_ENSURE(eRet == S_OK,"Error while clearing an ado variant!");
+ OSL_UNUSED(eRet);
+
+ vt = VT_DISPATCH;
+ pdispVal = pDispInterface;
+
+ if ( pDispInterface )
+ pDispInterface->AddRef();
+}
+
+
+sal_Bool OLEVariant::isNull() const { return (vt == VT_NULL); }
+sal_Bool OLEVariant::isEmpty() const { return (vt == VT_EMPTY); }
+
+VARTYPE OLEVariant::getType() const { return vt; }
+
+OLEVariant::operator ::com::sun::star::util::Date() const
+{
+ return isNull() ? ::com::sun::star::util::Date(30,12,1899) : ::dbtools::DBTypeConversion::toDate(getDate(),::com::sun::star::util::Date(30,12,1899));
+}
+OLEVariant::operator ::com::sun::star::util::Time() const
+{
+ return isNull() ? ::com::sun::star::util::Time() : ::dbtools::DBTypeConversion::toTime(getDate());
+}
+OLEVariant::operator ::com::sun::star::util::DateTime()const
+{
+ return isNull() ? ::com::sun::star::util::DateTime() : ::dbtools::DBTypeConversion::toDateTime(getDate(),::com::sun::star::util::Date(30,12,1899));
+}
+
+VARIANT_BOOL OLEVariant::VariantBool(sal_Bool bEinBoolean)
+{
+ return (bEinBoolean ? VARIANT_TRUE : VARIANT_FALSE);
+}
+
+void OLEVariant::CHS()
+{
+ cyVal.Lo ^= (sal_uInt32)-1;
+ cyVal.Hi ^= -1;
+ cyVal.Lo++;
+ if( !cyVal.Lo )
+ cyVal.Hi++;
+}
+
+void OLEVariant::set(double n)
+{
+ if( n >= 0 )
+ {
+ cyVal.Hi = (sal_Int32)(n / (double)4294967296.0);
+ cyVal.Lo = (sal_uInt32)(n - ((double)cyVal.Hi * (double)4294967296.0));
+ }
+ else {
+ cyVal.Hi = (sal_Int32)(-n / (double)4294967296.0);
+ cyVal.Lo = (sal_uInt32)(-n - ((double)cyVal.Hi * (double)4294967296.0));
+ CHS();
+ }
+}
+
+OLEVariant::operator rtl::OUString() const
+{
+ if (V_VT(this) == VT_BSTR)
+ return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(this)));
+
+ if(isNull())
+ return ::rtl::OUString();
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_BSTR, this);
+
+ return reinterpret_cast<const sal_Unicode*>(LPCOLESTR(V_BSTR(&varDest)));
+}
+
+// -----------------------------------------------------------------------------
+void OLEVariant::ChangeType(VARTYPE vartype, const OLEVariant* pSrc)
+{
+ //
+ // If pDest is NULL, convert type in place
+ //
+ if (pSrc == NULL)
+ pSrc = this;
+
+ if ( ( this != pSrc )
+ || ( vartype != V_VT( this ) )
+ )
+ {
+ if ( FAILED( ::VariantChangeType( static_cast< VARIANT* >( this ),
+ const_cast< VARIANT* >( static_cast< const VARIANT* >( pSrc ) ),
+ 0,
+ vartype ) ) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_TYPE_NOT_CONVERT));
+ throw ::com::sun::star::sdbc::SQLException(
+ sError,
+ NULL,
+ ::rtl::OUString::createFromAscii( "S1000" ),
+ 1000,
+ ::com::sun::star::uno::Any()
+ );
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+OLEVariant::operator ::com::sun::star::uno::Sequence< sal_Int8 >() const
+{
+ ::com::sun::star::uno::Sequence< sal_Int8 > aRet;
+ if(V_VT(this) == VT_BSTR)
+ {
+ OLEString sStr(V_BSTR(this));
+ aRet = ::com::sun::star::uno::Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>((const wchar_t*)sStr),sizeof(sal_Unicode)*sStr.length());
+ }
+ else if(!isNull())
+ {
+ SAFEARRAY* pArray = getUI1SAFEARRAYPtr();
+
+ if(pArray)
+ {
+ HRESULT hresult1,hresult2;
+ long lBound,uBound;
+ // Verify that the SafeArray is the proper shape.
+ hresult1 = ::SafeArrayGetLBound(pArray, 1, &lBound);
+ hresult2 = ::SafeArrayGetUBound(pArray, 1, &uBound);
+ if ( SUCCEEDED(hresult1) && SUCCEEDED(hresult2) )
+ {
+ long nCount = uBound-lBound+1;
+ aRet.realloc(nCount);
+ sal_Int8* pData = aRet.getArray();
+ for(long i=0; SUCCEEDED(hresult1) && lBound <= uBound ;++i,++lBound)
+ {
+ sal_Int32 nData = 0;
+ hresult1 = ::SafeArrayGetElement(pArray,&lBound,&nData);
+ if ( SUCCEEDED(hresult1) )
+ {
+ *pData = static_cast<sal_Int8>(nData);
+ ++pData;
+ }
+ }
+ }
+ }
+ }
+
+ return aRet;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OLEVariant::getString() const
+{
+ if(isNull())
+ return ::rtl::OUString();
+ else
+ return *this;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OLEVariant::getBool() const
+{
+ if (V_VT(this) == VT_BOOL)
+ return V_BOOL(this) == VARIANT_TRUE ? sal_True : sal_False;
+ if(isNull())
+ return sal_False;
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_BOOL, this);
+
+ return V_BOOL(&varDest) == VARIANT_TRUE ? sal_True : sal_False;
+}
+// -----------------------------------------------------------------------------
+IUnknown* OLEVariant::getIUnknown() const
+{
+ if (V_VT(this) == VT_UNKNOWN)
+ {
+ return V_UNKNOWN(this);
+ }
+ if(isNull())
+ return NULL;
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_UNKNOWN, this);
+
+ V_UNKNOWN(&varDest)->AddRef();
+ return V_UNKNOWN(&varDest);
+}
+// -----------------------------------------------------------------------------
+IDispatch* OLEVariant::getIDispatch() const
+{
+ if (V_VT(this) == VT_DISPATCH)
+ {
+ return V_DISPATCH(this);
+ }
+
+ if(isNull())
+ return NULL;
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_DISPATCH, this);
+
+ V_DISPATCH(&varDest)->AddRef();
+ return V_DISPATCH(&varDest);
+}
+// -----------------------------------------------------------------------------
+sal_uInt8 OLEVariant::getByte() const
+{
+ if (V_VT(this) == VT_UI1)
+ return V_UI1(this);
+
+ if(isNull())
+ return sal_Int8(0);
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_UI1, this);
+
+ return V_UI1(&varDest);
+}
+// -----------------------------------------------------------------------------
+sal_Int16 OLEVariant::getInt16() const
+{
+ if (V_VT(this) == VT_I2)
+ return V_I2(this);
+
+ if(isNull())
+ return sal_Int16(0);
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_I2, this);
+
+ return V_I2(&varDest);
+}
+// -----------------------------------------------------------------------------
+sal_Int8 OLEVariant::getInt8() const
+{
+ if (V_VT(this) == VT_I1)
+ return V_I1(this);
+
+ if(isNull())
+ return sal_Int8(0);
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_I1, this);
+
+ return V_I1(&varDest);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OLEVariant::getInt32() const
+{
+ if (V_VT(this) == VT_I4)
+ return V_I4(this);
+
+ if(isNull())
+ return sal_Int32(0);
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_I4, this);
+
+ return V_I4(&varDest);
+}
+// -----------------------------------------------------------------------------
+sal_uInt32 OLEVariant::getUInt32() const
+{
+ if (V_VT(this) == VT_UI4)
+ return V_UI4(this);
+
+ if(isNull())
+ return sal_uInt32(0);
+
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_UI4, this);
+
+ return V_UI4(&varDest);
+}
+// -----------------------------------------------------------------------------
+float OLEVariant::getFloat() const
+{
+ if (V_VT(this) == VT_R4)
+ return V_R4(this);
+
+ if(isNull())
+ return float(0);
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_R4, this);
+
+ return V_R4(&varDest);
+}
+// -----------------------------------------------------------------------------
+double OLEVariant::getDouble() const
+{
+ if (V_VT(this) == VT_R8)
+ return V_R8(this);
+
+ if(isNull())
+ return double(0);
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_R8, this);
+
+ return V_R8(&varDest);
+}
+// -----------------------------------------------------------------------------
+double OLEVariant::getDate() const
+{
+ if (V_VT(this) == VT_DATE)
+ return V_DATE(this);
+
+ if(isNull())
+ return double(0);
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_DATE, this);
+
+ return V_DATE(&varDest);
+}
+// -----------------------------------------------------------------------------
+CY OLEVariant::getCurrency() const
+{
+ if (V_VT(this) == VT_CY)
+ return V_CY(this);
+
+ if(isNull())
+ {
+ CY aVar;
+ aVar.int64 = sal_Int64(0);
+ return aVar;
+ }
+ OLEVariant varDest;
+
+ varDest.ChangeType(VT_CY, this);
+
+ return V_CY(&varDest);
+}
+// -----------------------------------------------------------------------------
+SAFEARRAY* OLEVariant::getUI1SAFEARRAYPtr() const
+{
+ if (V_VT(this) == (VT_ARRAY|VT_UI1))
+ return V_ARRAY(this);
+
+ if(isNull())
+ return (0);
+ OLEVariant varDest;
+
+ varDest.ChangeType((VT_ARRAY|VT_UI1), this);
+
+ return V_ARRAY(&varDest);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Any OLEVariant::makeAny() const
+{
+ ::com::sun::star::uno::Any aValue;
+ switch (V_VT(this))
+ {
+ case VT_EMPTY:
+ case VT_NULL:
+ aValue.setValue(NULL, Type());
+ break;
+ case VT_I2:
+ aValue.setValue( & iVal, getCppuType( (sal_Int16*)0));
+ break;
+ case VT_I4:
+ aValue.setValue( & lVal, getCppuType( (sal_Int32*)0));
+ break;
+ case VT_R4:
+ aValue.setValue( & fltVal, getCppuType( (float*)0));
+ break;
+ case VT_R8:
+ aValue.setValue(& dblVal, getCppuType( (double*)0));
+ break;
+ case VT_CY:
+ {
+ Currency cy(cyVal.int64);
+ aValue <<= cy;
+ break;
+ }
+ case VT_DATE:
+ {
+ aValue <<= (::com::sun::star::util::Date)*this;
+ break;
+ }
+ case VT_BSTR:
+ {
+ OUString b(reinterpret_cast<const sal_Unicode*>(bstrVal));
+ aValue.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_BOOL:
+ {
+ sal_Bool b= boolVal == VARIANT_TRUE;
+ aValue.setValue( &b, getCppuType( &b));
+ break;
+ }
+ case VT_I1:
+ aValue.setValue( & cVal, getCppuType((sal_Int8*)0));
+ break;
+ case VT_UI1: // there is no unsigned char in UNO
+ aValue.setValue( & bVal, getCppuType( (sal_Int8*)0));
+ break;
+ case VT_UI2:
+ aValue.setValue( & uiVal, getCppuType( (sal_uInt16*)0));
+ break;
+ case VT_UI4:
+ aValue.setValue( & ulVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_INT:
+ aValue.setValue( & intVal, getCppuType( (sal_Int32*)0));
+ break;
+ case VT_UINT:
+ aValue.setValue( & uintVal, getCppuType( (sal_uInt32*)0));
+ break;
+ case VT_VOID:
+ aValue.setValue( NULL, Type());
+ break;
+ case VT_DECIMAL:
+ {
+ Decimal dec;
+ dec.Scale = decVal.scale;
+ dec.Sign = decVal.sign;
+ dec.LowValue = decVal.Lo32;
+ dec.MiddleValue = decVal.Mid32;
+ dec.HighValue = decVal.Hi32;
+ aValue <<= dec;
+ break;
+ }
+
+ default:
+ break;
+ }
+ return aValue;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/ado/Aservices.cxx b/connectivity/source/drivers/ado/Aservices.cxx
new file mode 100644
index 000000000000..05ebd274be84
--- /dev/null
+++ b/connectivity/source/drivers/ado/Aservices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/ADriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::ado;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames ,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ADO::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME ":affine";
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ADO::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/ado/Awrapado.cxx b/connectivity/source/drivers/ado/Awrapado.cxx
new file mode 100644
index 000000000000..442c1bdde439
--- /dev/null
+++ b/connectivity/source/drivers/ado/Awrapado.cxx
@@ -0,0 +1,2201 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ado/Awrapado.hxx"
+#include "ado/Awrapadox.hxx"
+#include <comphelper/types.hxx>
+#include <rtl/ustrbuf.hxx>
+#include "diagnose_ex.h"
+
+namespace connectivity
+{
+ namespace ado
+ {
+ sal_Int32 nAdoObjectCounter = 0;
+ }
+}
+
+using namespace connectivity::ado;
+
+void WpADOCatalog::Create()
+{
+ HRESULT hr = -1;
+ _ADOCatalog* pCommand;
+ hr = CoCreateInstance(ADOS::CLSID_ADOCATALOG_25,
+ NULL,
+ CLSCTX_INPROC_SERVER,
+ ADOS::IID_ADOCATALOG_25,
+ (void**)&pCommand );
+
+
+ if( !FAILED( hr ) )
+ setWithOutAddRef(pCommand);
+}
+
+
+WpADOProperties WpADOConnection::get_Properties() const
+{
+ ADOProperties* pProps=NULL;
+ pInterface->get_Properties(&pProps);
+ WpADOProperties aProps;
+ aProps.setWithOutAddRef(pProps);
+ return aProps;
+}
+
+rtl::OUString WpADOConnection::GetConnectionString() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_ConnectionString(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOConnection::PutConnectionString(const ::rtl::OUString &aCon) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(aCon);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_ConnectionString(bstr));
+
+ return bErg;
+}
+
+sal_Int32 WpADOConnection::GetCommandTimeout() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_CommandTimeout(&nRet);
+ return nRet;
+}
+
+void WpADOConnection::PutCommandTimeout(sal_Int32 nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_CommandTimeout(nRet);
+}
+
+sal_Int32 WpADOConnection::GetConnectionTimeout() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_ConnectionTimeout(&nRet);
+ return nRet;
+}
+
+void WpADOConnection::PutConnectionTimeout(sal_Int32 nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_ConnectionTimeout(nRet);
+}
+
+sal_Bool WpADOConnection::Close( )
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->Close()));
+}
+
+sal_Bool WpADOConnection::Execute(const ::rtl::OUString& _CommandText,OLEVariant& RecordsAffected,long Options, WpADORecordset** ppiRset)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString sStr1(_CommandText);
+ sal_Bool bErg = SUCCEEDED(pInterface->Execute(sStr1,&RecordsAffected,Options,(_ADORecordset**)ppiRset));
+ return bErg;
+}
+
+sal_Bool WpADOConnection::BeginTrans()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nIso=0;
+ return SUCCEEDED(pInterface->BeginTrans(&nIso));
+}
+
+sal_Bool WpADOConnection::CommitTrans( )
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->CommitTrans());
+}
+
+sal_Bool WpADOConnection::RollbackTrans( )
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->RollbackTrans());
+}
+
+sal_Bool WpADOConnection::Open(const ::rtl::OUString& ConnectionString, const ::rtl::OUString& UserID,const ::rtl::OUString& Password,long Options)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString sStr1(ConnectionString);
+ OLEString sStr2(UserID);
+ OLEString sStr3(Password);
+ sal_Bool bErg = SUCCEEDED(pInterface->Open(sStr1,sStr2,sStr3,Options));
+ return bErg;
+}
+
+sal_Bool WpADOConnection::GetErrors(ADOErrors** pErrors)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_Errors(pErrors));
+}
+
+::rtl::OUString WpADOConnection::GetDefaultDatabase() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR; pInterface->get_DefaultDatabase(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOConnection::PutDefaultDatabase(const ::rtl::OUString& _bstr)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_bstr);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_DefaultDatabase(bstr));
+
+ return bErg;
+}
+
+IsolationLevelEnum WpADOConnection::get_IsolationLevel() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ IsolationLevelEnum eNum=adXactUnspecified;
+ pInterface->get_IsolationLevel(&eNum);
+ return eNum;
+}
+
+sal_Bool WpADOConnection::put_IsolationLevel(const IsolationLevelEnum& eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_IsolationLevel(eNum));
+}
+
+sal_Int32 WpADOConnection::get_Attributes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_Attributes(&nRet);
+ return nRet;
+}
+
+sal_Bool WpADOConnection::put_Attributes(sal_Int32 nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_Attributes(nRet));
+}
+
+CursorLocationEnum WpADOConnection::get_CursorLocation() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ CursorLocationEnum eNum=adUseNone;
+ pInterface->get_CursorLocation(&eNum);
+ return eNum;
+}
+
+sal_Bool WpADOConnection::put_CursorLocation(const CursorLocationEnum &eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_CursorLocation(eNum));
+}
+
+ConnectModeEnum WpADOConnection::get_Mode() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ConnectModeEnum eNum=adModeUnknown;
+ pInterface->get_Mode(&eNum);
+ return eNum;
+}
+
+sal_Bool WpADOConnection::put_Mode(const ConnectModeEnum &eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_Mode(eNum));
+}
+
+::rtl::OUString WpADOConnection::get_Provider() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR; pInterface->get_Provider(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOConnection::put_Provider(const ::rtl::OUString& _bstr)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_bstr);
+ return SUCCEEDED(pInterface->put_Provider(bstr));
+}
+
+sal_Int32 WpADOConnection::get_State() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_State(&nRet);
+ return nRet;
+}
+
+sal_Bool WpADOConnection::OpenSchema(SchemaEnum eNum,OLEVariant& Restrictions,OLEVariant& SchemaID,ADORecordset**pprset)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->OpenSchema(eNum,Restrictions,SchemaID,pprset));
+}
+
+::rtl::OUString WpADOConnection::get_Version() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Version(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOCommand::putref_ActiveConnection( WpADOConnection *pCon)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ if(pCon)
+ return SUCCEEDED(pInterface->putref_ActiveConnection(pCon->pInterface));
+ else
+ return SUCCEEDED(pInterface->putref_ActiveConnection(NULL));
+}
+
+void WpADOCommand::put_ActiveConnection(/* [in] */ const OLEVariant& vConn)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_ActiveConnection(vConn);
+}
+
+void WpADOCommand::Create()
+{
+ IClassFactory2* pInterface2 = NULL;
+ IUnknown *pOuter = NULL;
+ HRESULT hr;
+ hr = CoGetClassObject( ADOS::CLSID_ADOCOMMAND_21,
+ CLSCTX_INPROC_SERVER,
+ NULL,
+ IID_IClassFactory2,
+ (void**)&pInterface2 );
+
+ if( !FAILED( hr ) )
+ {
+ ADOCommand* pCommand=NULL;
+
+ hr = pInterface2->CreateInstanceLic( pOuter,
+ NULL,
+ ADOS::IID_ADOCOMMAND_21,
+ ADOS::GetKeyStr(),
+ (void**) &pCommand);
+
+ if( !FAILED( hr ) )
+ {
+ operator=(pCommand);
+ pCommand->Release();
+ }
+
+ pInterface2->Release();
+ }
+}
+
+sal_Int32 WpADOCommand::get_State() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_State(&nRet);
+ return nRet;
+}
+
+::rtl::OUString WpADOCommand::get_CommandText() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_CommandText(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOCommand::put_CommandText(const ::rtl::OUString &aCon)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(aCon);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_CommandText(bstr));
+
+ return bErg;
+}
+
+sal_Int32 WpADOCommand::get_CommandTimeout() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nRet=0;
+ pInterface->get_CommandTimeout(&nRet);
+ return nRet;
+}
+
+void WpADOCommand::put_CommandTimeout(sal_Int32 nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_CommandTimeout(nRet);
+}
+
+sal_Bool WpADOCommand::get_Prepared() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL bPrepared = VARIANT_FALSE;
+ pInterface->get_Prepared(&bPrepared);
+ return bPrepared == VARIANT_TRUE;
+}
+
+sal_Bool WpADOCommand::put_Prepared(VARIANT_BOOL bPrepared) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_Prepared(bPrepared));
+}
+
+sal_Bool WpADOCommand::Execute(OLEVariant& RecordsAffected,OLEVariant& Parameters,long Options, ADORecordset** ppiRset)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->Execute(&RecordsAffected,&Parameters,Options,ppiRset));
+}
+
+ADOParameter* WpADOCommand::CreateParameter(const ::rtl::OUString &_bstr,DataTypeEnum Type,ParameterDirectionEnum Direction,long nSize,const OLEVariant &Value)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOParameter* pPara = NULL;
+ OLEString bstr(_bstr);
+ sal_Bool bErg = SUCCEEDED(pInterface->CreateParameter(bstr,Type,Direction,nSize,Value,&pPara));
+
+ return bErg ? pPara : NULL;
+}
+
+ADOParameters* WpADOCommand::get_Parameters() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOParameters* pPara=NULL;
+ pInterface->get_Parameters(&pPara);
+ return pPara;
+}
+
+sal_Bool WpADOCommand::put_CommandType( /* [in] */ CommandTypeEnum lCmdType)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_CommandType(lCmdType));
+}
+
+CommandTypeEnum WpADOCommand::get_CommandType( ) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ CommandTypeEnum eNum=adCmdUnspecified;
+ pInterface->get_CommandType(&eNum);
+ return eNum;
+}
+
+// gibt den Namen des Feldes zur"ueck
+::rtl::OUString WpADOCommand::GetName() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+sal_Bool WpADOCommand::put_Name(const ::rtl::OUString& _Name)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_Name);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+
+ return bErg;
+}
+sal_Bool WpADOCommand::Cancel()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->Cancel());
+}
+
+::rtl::OUString WpADOError::GetDescription() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Description(&aBSTR);
+ return aBSTR;
+}
+
+ ::rtl::OUString WpADOError::GetSource() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Source(&aBSTR);
+ return aBSTR;
+}
+
+ sal_Int32 WpADOError::GetNumber() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nErrNr=0;
+ pInterface->get_Number(&nErrNr);
+ return nErrNr;
+}
+
+ ::rtl::OUString WpADOError::GetSQLState() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_SQLState(&aBSTR);
+ return aBSTR;
+}
+
+ sal_Int32 WpADOError::GetNativeError() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nErrNr=0;
+ pInterface->get_NativeError(&nErrNr);
+ return nErrNr;
+}
+WpADOProperties WpADOField::get_Properties()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOProperties* pProps = NULL;
+ pInterface->get_Properties(&pProps);
+ WpADOProperties aProps;
+
+ aProps.setWithOutAddRef(pProps);
+ return aProps;
+}
+
+ sal_Int32 WpADOField::GetActualSize() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nActualSize=0;
+ pInterface->get_ActualSize(&nActualSize);
+ return nActualSize;
+}
+
+ sal_Int32 WpADOField::GetAttributes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 eADOSFieldAttributes=0;
+ pInterface->get_Attributes(&eADOSFieldAttributes);
+ return eADOSFieldAttributes;
+}
+
+sal_Int32 WpADOField::GetStatus() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 eADOSFieldAttributes=0;
+ // pInterface->get_Status(&eADOSFieldAttributes);
+ return eADOSFieldAttributes;
+}
+
+sal_Int32 WpADOField::GetDefinedSize() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nDefinedSize=0;
+ pInterface->get_DefinedSize(&nDefinedSize);
+ return nDefinedSize;
+}
+
+// gibt den Namen des Feldes zur"ueck
+::rtl::OUString WpADOField::GetName() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+ DataTypeEnum WpADOField::GetADOType() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ DataTypeEnum eType=adEmpty;
+ pInterface->get_Type(&eType);
+ return eType;
+}
+
+ void WpADOField::get_Value(OLEVariant& aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ aValVar.setEmpty();
+ sal_Bool bOk = SUCCEEDED(pInterface->get_Value(&aValVar));
+ (void)bOk;
+}
+
+ OLEVariant WpADOField::get_Value() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant aValVar;
+ pInterface->get_Value(&aValVar);
+ return aValVar;
+}
+
+ sal_Bool WpADOField::PutValue(const OLEVariant& aVariant)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Value(aVariant)));
+}
+
+sal_Int32 WpADOField::GetPrecision() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_uInt8 eType=0;
+ pInterface->get_Precision(&eType);
+ return eType;
+}
+
+ sal_Int32 WpADOField::GetNumericScale() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_uInt8 eType=0;
+ pInterface->get_NumericScale(&eType);
+ return eType;
+}
+
+ sal_Bool WpADOField::AppendChunk(const OLEVariant& _Variant)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->AppendChunk(_Variant)));
+}
+
+OLEVariant WpADOField::GetChunk(long Length) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant aValVar;
+ pInterface->GetChunk(Length,&aValVar);
+ return aValVar;
+}
+
+void WpADOField::GetChunk(long Length,OLEVariant &aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->GetChunk(Length,&aValVar);
+}
+
+OLEVariant WpADOField::GetOriginalValue() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant aValVar;
+ pInterface->get_OriginalValue(&aValVar);
+ return aValVar;
+}
+
+void WpADOField::GetOriginalValue(OLEVariant &aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_OriginalValue(&aValVar);
+}
+
+OLEVariant WpADOField::GetUnderlyingValue() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant aValVar;
+ pInterface->get_UnderlyingValue(&aValVar);
+ return aValVar;
+}
+
+ void WpADOField::GetUnderlyingValue(OLEVariant &aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_UnderlyingValue(&aValVar);
+}
+
+ sal_Bool WpADOField::PutPrecision(sal_Int8 _prec)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Precision(_prec)));
+}
+
+ sal_Bool WpADOField::PutNumericScale(sal_Int8 _prec)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_NumericScale(_prec)));
+}
+
+ void WpADOField::PutADOType(DataTypeEnum eType)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Type(eType);
+}
+
+ sal_Bool WpADOField::PutDefinedSize(sal_Int32 _nDefSize)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_DefinedSize(_nDefSize)));
+}
+
+ sal_Bool WpADOField::PutAttributes(sal_Int32 _nDefSize)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
+}
+
+OLEVariant WpADOProperty::GetValue() const
+{
+ OLEVariant aValVar;
+ if(pInterface)
+ pInterface->get_Value(&aValVar);
+ return aValVar;
+}
+
+void WpADOProperty::GetValue(OLEVariant &aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ if(pInterface)
+ pInterface->get_Value(&aValVar);
+}
+
+sal_Bool WpADOProperty::PutValue(const OLEVariant &aValVar)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Value(aValVar)));
+}
+
+ ::rtl::OUString WpADOProperty::GetName() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+ DataTypeEnum WpADOProperty::GetADOType() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ DataTypeEnum eType=adEmpty;
+ pInterface->get_Type(&eType);
+ return eType;
+}
+
+ sal_Int32 WpADOProperty::GetAttributes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 eADOSFieldAttributes=0;
+ pInterface->get_Attributes(&eADOSFieldAttributes);
+ return eADOSFieldAttributes;
+}
+
+ sal_Bool WpADOProperty::PutAttributes(sal_Int32 _nDefSize)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Attributes(_nDefSize)));
+}
+ void WpADORecordset::Create()
+{
+ IClassFactory2* pInterface2 = NULL;
+ IUnknown *pOuter = NULL;
+ HRESULT hr;
+ hr = CoGetClassObject( ADOS::CLSID_ADORECORDSET_21,
+ CLSCTX_INPROC_SERVER,
+ NULL,
+ IID_IClassFactory2,
+ (void**)&pInterface2 );
+
+ if( !FAILED( hr ) )
+ {
+ ADORecordset *pRec = NULL;
+ hr = pInterface2->CreateInstanceLic( pOuter,
+ NULL,
+ ADOS::IID_ADORECORDSET_21,
+ ADOS::GetKeyStr(),
+ (void**) &pRec);
+
+ if( !FAILED( hr ) )
+ {
+ operator=(pRec);
+ pRec->Release();
+ }
+
+ pInterface2->Release();
+ }
+}
+
+ sal_Bool WpADORecordset::Open(
+ /* [optional][in] */ VARIANT Source,
+ /* [optional][in] */ VARIANT ActiveConnection,
+ /* [defaultvalue][in] */ CursorTypeEnum CursorType,
+ /* [defaultvalue][in] */ LockTypeEnum LockType,
+ /* [defaultvalue][in] */ sal_Int32 Options)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->Open(Source,ActiveConnection,CursorType,LockType,Options)));
+}
+
+
+LockTypeEnum WpADORecordset::GetLockType()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ LockTypeEnum eType=adLockUnspecified;
+ pInterface->get_LockType(&eType);
+ return eType;
+}
+
+void WpADORecordset::Close()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->Close();
+}
+
+ sal_Bool WpADORecordset::Cancel() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->Cancel()));
+}
+
+ sal_Int32 WpADORecordset::get_State( )
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nState = 0;
+ pInterface->get_State(&nState);
+ return nState;
+}
+
+ sal_Bool WpADORecordset::Supports( /* [in] */ CursorOptionEnum CursorOptions)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL bSupports=VARIANT_FALSE;
+ pInterface->Supports(CursorOptions,&bSupports);
+ return bSupports == VARIANT_TRUE;
+}
+
+PositionEnum WpADORecordset::get_AbsolutePosition()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ PositionEnum aTemp=adPosUnknown;
+ pInterface->get_AbsolutePosition(&aTemp);
+ return aTemp;
+}
+
+ void WpADORecordset::GetDataSource(IUnknown** _pInterface) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_DataSource(_pInterface);
+}
+
+ void WpADORecordset::PutRefDataSource(IUnknown* _pInterface)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->putref_DataSource(_pInterface);
+}
+
+ void WpADORecordset::GetBookmark(VARIANT& var)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_Bookmark(&var);
+}
+
+ OLEVariant WpADORecordset::GetBookmark()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant var;
+ pInterface->get_Bookmark(&var);
+ return var;
+}
+
+CompareEnum WpADORecordset::CompareBookmarks(const OLEVariant& left,const OLEVariant& right)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ CompareEnum eNum=adCompareNotComparable;
+ pInterface->CompareBookmarks(left,right,&eNum);
+ return eNum;
+}
+
+ sal_Bool WpADORecordset::SetBookmark(const OLEVariant &pSafeAr)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_Bookmark(pSafeAr));
+}
+
+
+WpADOFields WpADORecordset::GetFields() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOFields* pFields=NULL;
+ pInterface->get_Fields(&pFields);
+ WpADOFields aFields;
+ aFields.setWithOutAddRef(pFields);
+ return aFields;
+}
+
+
+ sal_Bool WpADORecordset::Move(sal_Int32 nRows, VARIANT aBmk) {return pInterface && SUCCEEDED(pInterface->Move(nRows, aBmk));}
+ sal_Bool WpADORecordset::MoveNext() {return pInterface && SUCCEEDED(pInterface->MoveNext());}
+ sal_Bool WpADORecordset::MovePrevious() {return pInterface && SUCCEEDED(pInterface->MovePrevious());}
+ sal_Bool WpADORecordset::MoveFirst() {return pInterface && SUCCEEDED(pInterface->MoveFirst());}
+ sal_Bool WpADORecordset::MoveLast() {return pInterface && SUCCEEDED(pInterface->MoveLast());}
+
+ sal_Bool WpADORecordset::IsAtBOF() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL bIsAtBOF=VARIANT_FALSE;
+ pInterface->get_BOF(&bIsAtBOF);
+ return bIsAtBOF == VARIANT_TRUE;
+}
+
+ sal_Bool WpADORecordset::IsAtEOF() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL bIsAtEOF=VARIANT_FALSE;
+ pInterface->get_EOF(&bIsAtEOF);
+ return bIsAtEOF == VARIANT_TRUE;
+}
+
+ sal_Bool WpADORecordset::Delete(AffectEnum eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->Delete(eNum));
+}
+
+ sal_Bool WpADORecordset::AddNew(const OLEVariant &FieldList,const OLEVariant &Values)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->AddNew(FieldList,Values));
+}
+
+ sal_Bool WpADORecordset::Update(const OLEVariant &FieldList,const OLEVariant &Values)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->Update(FieldList,Values));
+}
+
+ sal_Bool WpADORecordset::CancelUpdate()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->CancelUpdate());
+}
+
+WpADOProperties WpADORecordset::get_Properties() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOProperties* pProps=NULL;
+ pInterface->get_Properties(&pProps);
+ WpADOProperties aProps;
+ aProps.setWithOutAddRef(pProps);
+ return aProps;
+}
+
+ sal_Bool WpADORecordset::NextRecordset(OLEVariant& RecordsAffected,ADORecordset** ppiRset)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->NextRecordset(&RecordsAffected,ppiRset));
+}
+
+ sal_Bool WpADORecordset::get_RecordCount(sal_Int32 &_nRet) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_RecordCount(&_nRet));
+}
+
+ sal_Bool WpADORecordset::get_MaxRecords(sal_Int32 &_nRet) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_MaxRecords(&_nRet));
+}
+
+ sal_Bool WpADORecordset::put_MaxRecords(sal_Int32 _nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_MaxRecords(_nRet));
+}
+
+ sal_Bool WpADORecordset::get_CursorType(CursorTypeEnum &_nRet) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_CursorType(&_nRet));
+}
+
+ sal_Bool WpADORecordset::put_CursorType(CursorTypeEnum _nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_CursorType(_nRet));
+}
+
+ sal_Bool WpADORecordset::get_LockType(LockTypeEnum &_nRet) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_LockType(&_nRet));
+}
+
+ sal_Bool WpADORecordset::put_LockType(LockTypeEnum _nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_LockType(_nRet));
+}
+
+ sal_Bool WpADORecordset::get_CacheSize(sal_Int32 &_nRet) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->get_CacheSize(&_nRet));
+}
+
+ sal_Bool WpADORecordset::put_CacheSize(sal_Int32 _nRet)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_CacheSize(_nRet));
+}
+
+ sal_Bool WpADORecordset::UpdateBatch(AffectEnum AffectRecords)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->UpdateBatch(AffectRecords));
+}
+
+ ::rtl::OUString WpADOParameter::GetName() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+ DataTypeEnum WpADOParameter::GetADOType() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ DataTypeEnum eType=adEmpty;
+ pInterface->get_Type(&eType);
+ return eType;
+}
+
+void WpADOParameter::put_Type(const DataTypeEnum& _eType)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Type(_eType);
+}
+
+ sal_Int32 WpADOParameter::GetAttributes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 eADOSFieldAttributes=0;
+ pInterface->get_Attributes(&eADOSFieldAttributes);
+ return eADOSFieldAttributes;
+}
+
+ sal_Int32 WpADOParameter::GetPrecision() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_uInt8 eType=0;
+ pInterface->get_Precision(&eType);
+ return eType;
+}
+
+ sal_Int32 WpADOParameter::GetNumericScale() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_uInt8 eType=0;
+ pInterface->get_NumericScale(&eType);
+ return eType;
+}
+
+ ParameterDirectionEnum WpADOParameter::get_Direction() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ParameterDirectionEnum alParmDirection=adParamUnknown;
+ pInterface->get_Direction(&alParmDirection);
+ return alParmDirection;
+}
+
+ void WpADOParameter::GetValue(OLEVariant& aValVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_Value(&aValVar);
+}
+
+ OLEVariant WpADOParameter::GetValue() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEVariant aValVar;
+ pInterface->get_Value(&aValVar);
+ return aValVar;
+}
+
+sal_Bool WpADOParameter::PutValue(const OLEVariant& aVariant)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Value(aVariant)));
+}
+sal_Bool WpADOParameter::AppendChunk(const OLEVariant& aVariant)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->AppendChunk(aVariant)));
+}
+sal_Bool WpADOParameter::put_Size(const sal_Int32& _nSize)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return (SUCCEEDED(pInterface->put_Size(_nSize)));
+}
+
+ ::rtl::OUString WpADOColumn::get_Name() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+::rtl::OUString WpADOColumn::get_RelatedColumn() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_RelatedColumn(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOColumn::put_Name(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+void WpADOColumn::put_RelatedColumn(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedColumn(bstr));
+ (void)bErg;
+}
+
+DataTypeEnum WpADOColumn::get_Type() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ DataTypeEnum eNum = adVarChar;
+ pInterface->get_Type(&eNum);
+ return eNum;
+}
+
+void WpADOColumn::put_Type(const DataTypeEnum& _eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Type(_eNum);
+}
+
+sal_Int32 WpADOColumn::get_Precision() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nPrec=0;
+ pInterface->get_Precision(&nPrec);
+ return nPrec;
+}
+
+void WpADOColumn::put_Precision(sal_Int32 _nPre)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Precision(_nPre);
+}
+
+sal_Int32 WpADOColumn::get_DefinedSize() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Int32 nPrec=0;
+ pInterface->get_DefinedSize(&nPrec);
+ return nPrec;
+}
+sal_uInt8 WpADOColumn::get_NumericScale() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_uInt8 nPrec=0;
+ pInterface->get_NumericScale(&nPrec);
+ return nPrec;
+}
+
+void WpADOColumn::put_NumericScale(sal_Int8 _nScale)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_NumericScale(_nScale);
+}
+
+SortOrderEnum WpADOColumn::get_SortOrder() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ SortOrderEnum nPrec=adSortAscending;
+ pInterface->get_SortOrder(&nPrec);
+ return nPrec;
+}
+
+void WpADOColumn::put_SortOrder(SortOrderEnum _nScale)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_SortOrder(_nScale);
+}
+
+ColumnAttributesEnum WpADOColumn::get_Attributes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ColumnAttributesEnum eNum=adColNullable;
+ pInterface->get_Attributes(&eNum);
+ return eNum;
+}
+
+sal_Bool WpADOColumn::put_Attributes(const ColumnAttributesEnum& _eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ return SUCCEEDED(pInterface->put_Attributes(_eNum));
+}
+
+WpADOProperties WpADOColumn::get_Properties() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOProperties* pProps = NULL;
+ pInterface->get_Properties(&pProps);
+ WpADOProperties aProps;
+
+ aProps.setWithOutAddRef(pProps);
+ return aProps;
+}
+
+::rtl::OUString WpADOKey::get_Name() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOKey::put_Name(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+
+KeyTypeEnum WpADOKey::get_Type() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ KeyTypeEnum eNum=adKeyPrimary;
+ pInterface->get_Type(&eNum);
+ return eNum;
+}
+
+void WpADOKey::put_Type(const KeyTypeEnum& _eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Type(_eNum);
+}
+
+::rtl::OUString WpADOKey::get_RelatedTable() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_RelatedTable(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOKey::put_RelatedTable(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_RelatedTable(bstr));
+ (void)bErg;
+}
+
+RuleEnum WpADOKey::get_DeleteRule() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ RuleEnum eNum = adRINone;
+ pInterface->get_DeleteRule(&eNum);
+ return eNum;
+}
+
+void WpADOKey::put_DeleteRule(const RuleEnum& _eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_DeleteRule(_eNum);
+}
+
+RuleEnum WpADOKey::get_UpdateRule() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ RuleEnum eNum = adRINone;
+ pInterface->get_UpdateRule(&eNum);
+ return eNum;
+}
+
+void WpADOKey::put_UpdateRule(const RuleEnum& _eNum)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_UpdateRule(_eNum);
+}
+
+WpADOColumns WpADOKey::get_Columns() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOColumns* pCols = NULL;
+ pInterface->get_Columns(&pCols);
+ WpADOColumns aCols;
+ aCols.setWithOutAddRef(pCols);
+ return aCols;
+}
+
+::rtl::OUString WpADOIndex::get_Name() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOIndex::put_Name(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+
+sal_Bool WpADOIndex::get_Clustered() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL eNum = VARIANT_FALSE;
+ pInterface->get_Clustered(&eNum);
+ return eNum == VARIANT_TRUE;
+}
+
+void WpADOIndex::put_Clustered(sal_Bool _b)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Clustered(_b ? VARIANT_TRUE : VARIANT_FALSE);
+}
+
+sal_Bool WpADOIndex::get_Unique() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL eNum = VARIANT_FALSE;
+ pInterface->get_Unique(&eNum);
+ return eNum == VARIANT_TRUE;
+}
+
+void WpADOIndex::put_Unique(sal_Bool _b)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_Unique(_b ? VARIANT_TRUE : VARIANT_FALSE);
+}
+
+sal_Bool WpADOIndex::get_PrimaryKey() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ VARIANT_BOOL eNum = VARIANT_FALSE;
+ pInterface->get_PrimaryKey(&eNum);
+ return eNum == VARIANT_TRUE;
+}
+
+void WpADOIndex::put_PrimaryKey(sal_Bool _b)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->put_PrimaryKey(_b ? VARIANT_TRUE : VARIANT_FALSE);
+}
+
+WpADOColumns WpADOIndex::get_Columns() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOColumns* pCols = NULL;
+ pInterface->get_Columns(&pCols);
+ WpADOColumns aCols;
+ aCols.setWithOutAddRef(pCols);
+ return aCols;
+}
+
+void WpADOCatalog::putref_ActiveConnection(IDispatch* pCon)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->putref_ActiveConnection(pCon);
+}
+
+WpADOTables WpADOCatalog::get_Tables()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOTables* pRet = NULL;
+ pInterface->get_Tables(&pRet);
+ WpADOTables aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+WpADOViews WpADOCatalog::get_Views()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOViews* pRet = NULL;
+ pInterface->get_Views(&pRet);
+ WpADOViews aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+WpADOGroups WpADOCatalog::get_Groups()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOGroups* pRet = NULL;
+ pInterface->get_Groups(&pRet);
+ WpADOGroups aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+WpADOUsers WpADOCatalog::get_Users()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOUsers* pRet = NULL;
+ pInterface->get_Users(&pRet);
+ WpADOUsers aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+ADOProcedures* WpADOCatalog::get_Procedures()
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOProcedures* pRet = NULL;
+ pInterface->get_Procedures(&pRet);
+ return pRet;
+}
+
+::rtl::OUString WpADOTable::get_Name() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOTable::put_Name(const ::rtl::OUString& _rName)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+
+::rtl::OUString WpADOTable::get_Type() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Type(&aBSTR);
+ return aBSTR;
+}
+
+WpADOColumns WpADOTable::get_Columns() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOColumns* pCols = NULL;
+ pInterface->get_Columns(&pCols);
+ WpADOColumns aCols;
+ aCols.setWithOutAddRef(pCols);
+ return aCols;
+}
+
+WpADOIndexes WpADOTable::get_Indexes() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOIndexes* pCols = NULL;
+ pInterface->get_Indexes(&pCols);
+ WpADOIndexes aRet;
+ aRet.setWithOutAddRef(pCols);
+ return aRet;
+}
+
+WpADOKeys WpADOTable::get_Keys() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOKeys* pCols = NULL;
+ pInterface->get_Keys(&pCols);
+ WpADOKeys aRet;
+ aRet.setWithOutAddRef(pCols);
+ return aRet;
+}
+
+WpADOCatalog WpADOTable::get_ParentCatalog() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOCatalog* pCat = NULL;
+ pInterface->get_ParentCatalog(&pCat);
+ WpADOCatalog aRet;
+ aRet.setWithOutAddRef(pCat);
+ return aRet;
+}
+
+WpADOProperties WpADOTable::get_Properties() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ ADOProperties* pProps = NULL;
+ pInterface->get_Properties(&pProps);
+ WpADOProperties aProps;
+ aProps.setWithOutAddRef(pProps);
+ return aProps;
+}
+
+::rtl::OUString WpADOView::get_Name() const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOView::get_Command(OLEVariant& _rVar) const
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ pInterface->get_Command(&_rVar);
+}
+
+void WpADOView::put_Command(OLEVariant& _rVar)
+{
+ pInterface->put_Command(_rVar);
+}
+
+::rtl::OUString WpADOGroup::get_Name() const
+{
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOGroup::put_Name(const ::rtl::OUString& _rName)
+{
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+
+RightsEnum WpADOGroup::GetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType)
+{
+ RightsEnum Rights=adRightNone;
+ OLEVariant ObjectTypeId;
+ ObjectTypeId.setNoArg();
+ pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
+ return Rights;
+}
+
+sal_Bool WpADOGroup::SetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType,
+ /* [in] */ ActionEnum Action,
+ /* [in] */ RightsEnum Rights)
+{
+ OLEVariant ObjectTypeId;
+ ObjectTypeId.setNoArg();
+ return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
+}
+
+WpADOUsers WpADOGroup::get_Users( )
+{
+ ADOUsers* pRet = NULL;
+ pInterface->get_Users( &pRet);
+ WpADOUsers aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+::rtl::OUString WpADOUser::get_Name() const
+{
+ OLEString aBSTR;
+ pInterface->get_Name(&aBSTR);
+ return aBSTR;
+}
+
+void WpADOUser::put_Name(const ::rtl::OUString& _rName)
+{
+ OLEString bstr(_rName);
+ sal_Bool bErg = SUCCEEDED(pInterface->put_Name(bstr));
+ (void)bErg;
+}
+
+sal_Bool WpADOUser::ChangePassword(const ::rtl::OUString& _rPwd,const ::rtl::OUString& _rNewPwd)
+{
+ OLEString sStr1(_rPwd);
+ OLEString sStr2(_rNewPwd);
+ sal_Bool bErg = SUCCEEDED(pInterface->ChangePassword(sStr1,sStr2));
+ return bErg;
+}
+
+WpADOGroups WpADOUser::get_Groups()
+{
+ ADOGroups* pRet = NULL;
+ pInterface->get_Groups(&pRet);
+ WpADOGroups aRet;
+ aRet.setWithOutAddRef(pRet);
+ return aRet;
+}
+
+RightsEnum WpADOUser::GetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType)
+{
+ RightsEnum Rights=adRightNone;
+ OLEVariant ObjectTypeId;
+ ObjectTypeId.setNoArg();
+ pInterface->GetPermissions(Name,ObjectType,ObjectTypeId,&Rights);
+ return Rights;
+}
+
+sal_Bool WpADOUser::SetPermissions(
+ /* [in] */ const OLEVariant& Name,
+ /* [in] */ ObjectTypeEnum ObjectType,
+ /* [in] */ ActionEnum Action,
+ /* [in] */ RightsEnum Rights)
+{
+ OLEVariant ObjectTypeId;
+ ObjectTypeId.setNoArg();
+ return SUCCEEDED(pInterface->SetPermissions(Name,ObjectType,Action,Rights,adInheritNone,ObjectTypeId));
+}
+
+WpBase::WpBase() : pIUnknown(NULL)
+{
+}
+WpBase::WpBase(IDispatch* pInt)
+ :pIUnknown(pInt)
+{
+ if (pIUnknown)
+ {
+ ULONG nCount = pIUnknown->AddRef();
+ (void)nCount;
+ // OSL_ENSURE(nCount == 1,"Count is greater than 1");
+ }
+}
+
+//inline
+WpBase& WpBase::operator=(const WpBase& rhs)
+{
+ if (rhs.pIUnknown != pIUnknown)
+ {
+ if (pIUnknown)
+ pIUnknown->Release();
+ pIUnknown = rhs.pIUnknown;
+ if (pIUnknown)
+ pIUnknown->AddRef();
+ }
+ return *this;
+};
+
+WpBase& WpBase::operator=(IDispatch* rhs)
+{
+ if (pIUnknown != rhs)
+ {
+ if (pIUnknown)
+ pIUnknown->Release();
+ pIUnknown = rhs;
+ if (pIUnknown)
+ pIUnknown->AddRef();
+ }
+ return *this;
+}
+
+WpBase::WpBase(const WpBase& aWrapper)
+{
+ operator=(aWrapper);
+}
+
+WpBase::~WpBase()
+{
+ if (pIUnknown)
+ {
+ pIUnknown->Release();
+ pIUnknown = NULL;
+ }
+}
+
+void WpBase::clear()
+{
+ if (pIUnknown)
+ {
+ pIUnknown->Release();
+ pIUnknown = NULL;
+ }
+}
+
+
+sal_Bool WpBase::IsValid() const
+{
+ return pIUnknown != NULL;
+}
+WpBase::operator IDispatch*()
+{
+ return pIUnknown;
+}
+
+ADORecordset* WpADOConnection::getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[6];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schema.getLength() && schema.toChar() != '%')
+ varCriteria[nPos].setString(schema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(table);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[6];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schema.getLength() && schema.toChar() != '%')
+ varCriteria[nPos].setString(schema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(table);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[3];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schema.getLength() && schema.toChar() != '%')
+ varCriteria[nPos].setString(schema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(table);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaPrimaryKeys,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getIndexInfo(
+ const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool /*unique*/, sal_Bool /*approximate*/ )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[5];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schema.getLength() && schema.toChar() != '%')
+ varCriteria[nPos].setString(schema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// INDEX_NAME
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TYPE
+
+ varCriteria[nPos].setString(table);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaIndexes,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getTablePrivileges( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern )
+{
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[5];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
+ varCriteria[nPos].setString(schemaPattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ if(tableNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(tableNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTOR
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// GRANTEE
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaTablePrivileges,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog,
+ const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable,
+ const ::com::sun::star::uno::Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema,
+ const ::rtl::OUString& foreignTable)
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[6];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(primaryCatalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(primaryCatalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(primarySchema.getLength() && primarySchema.toChar() != '%')
+ varCriteria[nPos].setString(primarySchema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(primaryTable);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ if(foreignCatalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(foreignCatalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(foreignSchema.getLength() && foreignSchema.toChar() != '%')
+ varCriteria[nPos].setString(foreignSchema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(foreignTable);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaForeignKeys,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getProcedures( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern )
+{
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[3];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
+ varCriteria[nPos].setString(schemaPattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ if(procedureNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(procedureNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaProcedures,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getProcedureColumns( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern,
+ const ::rtl::OUString& columnNamePattern )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[4];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
+ varCriteria[nPos].setString(schemaPattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ if(procedureNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(procedureNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ if(columnNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(columnNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaProcedureParameters,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getTables( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ OLEVariant varCriteria[4];
+
+ sal_Int32 nPos=0;
+ ::rtl::OUString sCatalog;
+ if ( catalog.hasValue() && (catalog >>= sCatalog) )
+ varCriteria[nPos].setString(sCatalog);
+
+ ++nPos;
+ if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
+ varCriteria[nPos].setString(schemaPattern);
+
+ ++nPos;
+ if(tableNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(tableNamePattern);
+
+ ++nPos;
+ ::rtl::OUStringBuffer aTypes;
+ ::rtl::OUString aComma = ::rtl::OUString::createFromAscii(",");
+ const ::rtl::OUString* pIter = types.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + types.getLength();
+ for( ; pIter != pEnd ; ++pIter)
+ {
+ if ( aTypes.getLength() )
+ aTypes.append(aComma);
+ aTypes.append(*pIter);
+ }
+
+ ::rtl::OUString sTypeNames = aTypes.makeStringAndClear();
+ if ( sTypeNames.getLength() )
+ varCriteria[nPos].setString(sTypeNames);
+
+ // Create SafeArray Bounds and initialize the array
+ const sal_Int32 nCrit = sizeof varCriteria / sizeof varCriteria[0];
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = nCrit;
+ SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ // Set the values for each element of the array
+ for( long i = 0 ; i < nCrit && SUCCEEDED( hr );i++)
+ {
+ hr = SafeArrayPutElement(psa, &i,&varCriteria[i]);
+ }
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaTables,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getColumns( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[4];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schemaPattern.getLength() && schemaPattern.toChar() != '%')
+ varCriteria[nPos].setString(schemaPattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ if(tableNamePattern.toChar() != '%')
+ varCriteria[nPos].setString(tableNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ varCriteria[nPos].setString(columnNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaColumns,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getColumnPrivileges( const ::com::sun::star::uno::Any& catalog,
+ const ::rtl::OUString& schema,
+ const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern )
+{
+ // Create elements used in the array
+ HRESULT hr = S_OK;
+ SAFEARRAYBOUND rgsabound[1];
+ SAFEARRAY *psa = NULL;
+ OLEVariant varCriteria[4];
+
+ // Create SafeArray Bounds and initialize the array
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = sizeof varCriteria / sizeof varCriteria[0];
+ psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos=0;
+ if(catalog.hasValue())
+ varCriteria[nPos].setString(::comphelper::getString(catalog));
+
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_CATALOG
+ if(schema.getLength() && schema.toChar() != '%')
+ varCriteria[nPos].setString(schema);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_SCHEMA
+
+ varCriteria[nPos].setString(table);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// TABLE_NAME
+
+ varCriteria[nPos].setString(columnNamePattern);
+ hr = SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;// COLUMN_NAME
+
+ OLEVariant vtEmpty;
+ vtEmpty.setNoArg();
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ ADORecordset *pRecordset = NULL;
+ OpenSchema(adSchemaColumnPrivileges,vsa,vtEmpty,&pRecordset);
+
+ return pRecordset;
+}
+// -----------------------------------------------------------------------------
+ADORecordset* WpADOConnection::getTypeInfo(DataTypeEnum /*_eType*/)
+{
+ // Create elements used in the array
+ OLEVariant varCriteria[2];
+ const int nCrit = sizeof varCriteria / sizeof varCriteria[0];
+ // Create SafeArray Bounds and initialize the array
+ SAFEARRAYBOUND rgsabound[1];
+ rgsabound[0].lLbound = 0;
+ rgsabound[0].cElements = nCrit;
+ SAFEARRAY *psa = SafeArrayCreate( VT_VARIANT, 1, rgsabound );
+
+ sal_Int32 nPos = 0;
+ SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
+ SafeArrayPutElement(psa,&nPos,&varCriteria[nPos]);nPos++;
+
+ // Initialize and fill the SafeArray
+ OLEVariant vsa;
+ vsa.setArray(psa,VT_VARIANT);
+
+ OLEVariant aEmpty;
+ aEmpty.setNoArg();
+
+ ADORecordset *pRec=NULL;
+ OpenSchema(adSchemaProviderTypes,vsa,aEmpty,&pRec);
+
+ return pRec;
+}
+// -----------------------------------------------------------------------------
+void WpADOColumn::put_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Bool bRet = SUCCEEDED(pInterface->put_ParentCatalog(ppvObject));
+ OSL_ENSURE(bRet,"Could not set ParentCatalog!");
+ OSL_UNUSED(bRet);
+}
+// -----------------------------------------------------------------------------
+void WpADOTable::putref_ParentCatalog(/* [in] */ _ADOCatalog __RPC_FAR *ppvObject)
+{
+ OSL_ENSURE(pInterface,"Interface is null!");
+ sal_Bool bRet = SUCCEEDED(pInterface->putref_ParentCatalog(ppvObject));
+ OSL_ENSURE(bRet,"Could not set ParentCatalog!");
+ OSL_UNUSED(bRet);
+}
+// -----------------------------------------------------------------------------
+void WpBase::setIDispatch(IDispatch* _pIUnknown)
+{
+ pIUnknown = _pIUnknown;
+}
+// -----------------------------------------------------------------------------
+void OTools::putValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition,const OLEVariant &_aValVar)
+{
+ OSL_ENSURE(_rProps.IsValid(),"Properties are not valid!");
+ WpADOProperty aProp(_rProps.GetItem(_aPosition));
+ if ( aProp.IsValid() )
+ {
+ sal_Bool bRet = aProp.PutValue(_aValVar);
+ OSL_ENSURE(bRet,"Could not put value!");
+ OSL_UNUSED(bRet);
+ }
+}
+// -----------------------------------------------------------------------------
+OLEVariant OTools::getValue(const WpADOProperties& _rProps,const OLEVariant &_aPosition)
+{
+ WpADOProperty aProp(_rProps.GetItem(_aPosition));
+ return aProp.GetValue();
+}
diff --git a/connectivity/source/drivers/ado/ado.xcu b/connectivity/source/drivers/ado/ado.xcu
new file mode 100755
index 000000000000..50c29cf7ba2e
--- /dev/null
+++ b/connectivity/source/drivers/ado/ado.xcu
@@ -0,0 +1,259 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:ado:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.ado.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">ADO</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="GeneratedValues" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseCatalogInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSchemaInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseIndexDirectionKeyword" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="PrimaryKeySupport" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.ado.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Microsoft Access</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>3</value>
+ </prop>
+ </node>
+ <node oor:name="ColumnAliasInOrderBy" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="ColumnAliasInOrderBy" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FileSystemBased" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="MediaType" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>application/msaccess</value>
+ </prop>
+ </node>
+ <node oor:name="Extension" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>mdb</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:ado:access:Provider=Microsoft.ACE.OLEDB.12.0;DATA SOURCE=*" oor:op="replace">
+ <prop oor:name="ParentURLPattern">
+ <value>sdbc:ado:access:PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=*</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Microsoft Access 2007</value>
+ </prop>
+ <node oor:name="MetaData">
+ <node oor:name="Extension" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/ado/ado.xml b/connectivity/source/drivers/ado/ado.xml
new file mode 100644
index 000000000000..dbd903e40fc4
--- /dev/null
+++ b/connectivity/source/drivers/ado/ado.xml
@@ -0,0 +1,29 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> ado </module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.comp.sdbc.ado.ODriver</name>
+ <description>
+ This is the implementation of the ado-sdbc bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.sdbc.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/drivers/ado/ado_post_sys_include.h b/connectivity/source/drivers/ado/ado_post_sys_include.h
new file mode 100644
index 000000000000..a368593027c7
--- /dev/null
+++ b/connectivity/source/drivers/ado/ado_post_sys_include.h
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#undef ADO_REDUCED_WARN_LEVEL
+
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif
diff --git a/connectivity/source/drivers/ado/ado_pre_sys_include.h b/connectivity/source/drivers/ado/ado_pre_sys_include.h
new file mode 100644
index 000000000000..6eee7ab0948e
--- /dev/null
+++ b/connectivity/source/drivers/ado/ado_pre_sys_include.h
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef ADO_REDUCED_WARN_LEVEL
+ #error "ado_pre_sys_include.h included twice!"
+#endif
+
+#ifdef _MSC_VER
+#pragma warning(push,1)
+#pragma warning(disable:4917)
+#endif
+
+#define ADO_REDUCED_WARN_LEVEL
diff --git a/connectivity/source/drivers/ado/adoimp.cxx b/connectivity/source/drivers/ado/adoimp.cxx
new file mode 100644
index 000000000000..1bc136a35662
--- /dev/null
+++ b/connectivity/source/drivers/ado/adoimp.cxx
@@ -0,0 +1,336 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "connectivity/dbexception.hxx"
+#include "ado/Awrapado.hxx"
+#include "ado/adoimp.hxx"
+#include <osl/diagnose.h>
+#include <com/sun/star/sdbc/DataType.hpp>
+
+
+using namespace connectivity::ado;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+
+#define MYADOID(l) {l, 0,0x10,0x80,0,0,0xAA,0,0x6D,0x2E,0xA4};
+
+const CLSID ADOS::CLSID_ADOCONNECTION_21 = MYADOID(0x00000514);
+const IID ADOS::IID_ADOCONNECTION_21 = MYADOID(0x00000550);
+
+const CLSID ADOS::CLSID_ADOCOMMAND_21 = MYADOID(0x00000507);
+const IID ADOS::IID_ADOCOMMAND_21 = MYADOID(0x0000054E);
+
+const CLSID ADOS::CLSID_ADORECORDSET_21 = MYADOID(0x00000535);
+const IID ADOS::IID_ADORECORDSET_21 = MYADOID(0x0000054F);
+
+const CLSID ADOS::CLSID_ADOCATALOG_25 = MYADOID(0x00000602);
+const IID ADOS::IID_ADOCATALOG_25 = MYADOID(0x00000603);
+
+const CLSID ADOS::CLSID_ADOINDEX_25 = MYADOID(0x0000061E);
+const IID ADOS::IID_ADOINDEX_25 = MYADOID(0x0000061F);
+
+const CLSID ADOS::CLSID_ADOTABLE_25 = MYADOID(0x00000609);
+const IID ADOS::IID_ADOTABLE_25 = MYADOID(0x00000610);
+
+const CLSID ADOS::CLSID_ADOKEY_25 = MYADOID(0x00000621);
+const IID ADOS::IID_ADOKEY_25 = MYADOID(0x00000622);
+
+const CLSID ADOS::CLSID_ADOCOLUMN_25 = MYADOID(0x0000061B);
+const IID ADOS::IID_ADOCOLUMN_25 = MYADOID(0x0000061C);
+
+const CLSID ADOS::CLSID_ADOGROUP_25 = MYADOID(0x00000615);
+const IID ADOS::IID_ADOGROUP_25 = MYADOID(0x00000616);
+
+const CLSID ADOS::CLSID_ADOUSER_25 = MYADOID(0x00000618);
+const IID ADOS::IID_ADOUSER_25 = MYADOID(0x00000619);
+
+const CLSID ADOS::CLSID_ADOVIEW_25 = MYADOID(0x00000612);
+const IID ADOS::IID_ADOVIEW_25 = MYADOID(0x00000613);
+
+OLEString& ADOS::GetKeyStr()
+{
+ static OLEString sKeyStr(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("gxwaezucfyqpwjgqbcmtsncuhwsnyhiohwxz")));
+ return sKeyStr;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 ADOS::MapADOType2Jdbc(DataTypeEnum eType)
+{
+ sal_Int32 nType = DataType::VARCHAR;;
+ switch (eType)
+ {
+ case adUnsignedSmallInt:
+ case adSmallInt: nType = DataType::SMALLINT; break;
+ case adUnsignedInt:
+ case adInteger: nType = DataType::INTEGER; break;
+ case adUnsignedBigInt:
+ case adBigInt: nType = DataType::BIGINT; break;
+ case adSingle: nType = DataType::FLOAT; break;
+ case adDouble: nType = DataType::DOUBLE; break;
+ case adCurrency: nType = DataType::DOUBLE; break;
+ case adVarNumeric:
+ case adNumeric: nType = DataType::NUMERIC; break;
+ case adDecimal: nType = DataType::DECIMAL; break;
+ case adDBDate: nType = DataType::DATE; break;
+ case adDBTime: nType = DataType::TIME; break;
+ case adDate:
+ case adDBTimeStamp: nType = DataType::TIMESTAMP; break;
+ case adBoolean: nType = DataType::BIT; break;
+// case adArray: nType = DataType::ARRAY; break;
+ case adBinary: nType = DataType::BINARY; break;
+ case adGUID: nType = DataType::OBJECT; break;
+ case adBSTR:
+ case adVarWChar:
+ case adWChar:
+ case adVarChar: nType = DataType::VARCHAR; break;
+ case adLongVarWChar:
+ case adLongVarChar: nType = DataType::LONGVARCHAR; break;
+ case adVarBinary: nType = DataType::VARBINARY; break;
+ case adLongVarBinary: nType = DataType::LONGVARBINARY;break;
+ case adChar: nType = DataType::CHAR; break;
+ case adUnsignedTinyInt:
+ case adTinyInt: nType = DataType::TINYINT; break;
+ case adEmpty: nType = DataType::SQLNULL; break;
+ case adUserDefined:
+ case adPropVariant:
+ case adFileTime:
+ case adChapter:
+ case adIDispatch:
+ case adIUnknown:
+ case adError:
+ case adVariant:
+ nType = DataType::OTHER; break;
+ default:
+ OSL_ENSURE(0,"MapADOType2Jdbc: Unknown Type!");
+ ;
+ }
+ return nType;
+}
+// -------------------------------------------------------------------------
+DataTypeEnum ADOS::MapJdbc2ADOType(sal_Int32 _nType,sal_Int32 _nJetEngine)
+{
+ switch (_nType)
+ {
+ case DataType::SMALLINT: return adSmallInt; break;
+ case DataType::INTEGER: return adInteger; break;
+ case DataType::BIGINT: return adBigInt; break;
+ case DataType::FLOAT: return adSingle; break;
+ case DataType::DOUBLE: return adDouble; break;
+ case DataType::NUMERIC: return adNumeric; break;
+ case DataType::DECIMAL: return adDecimal; break;
+ case DataType::DATE: return isJetEngine(_nJetEngine) ? adDate : adDBDate; break;
+ case DataType::TIME: return adDBTime; break;
+ case DataType::TIMESTAMP: return isJetEngine(_nJetEngine) ? adDate : adDBTimeStamp; break;
+ case DataType::BIT: return adBoolean; break;
+ case DataType::BINARY: return adBinary; break;
+ case DataType::VARCHAR: return adVarWChar; break;
+ case DataType::CLOB:
+ case DataType::LONGVARCHAR: return adLongVarWChar; break;
+ case DataType::VARBINARY: return adVarBinary; break;
+ case DataType::BLOB:
+ case DataType::LONGVARBINARY: return adLongVarBinary; break;
+ case DataType::CHAR: return adWChar; break;
+ case DataType::TINYINT: return isJetEngine(_nJetEngine) ? adUnsignedTinyInt : adTinyInt;break;
+ case DataType::OBJECT: return adGUID; break;
+ default:
+ OSL_ENSURE(0,"MapJdbc2ADOType: Unknown Type!");
+ ;
+ }
+ return adEmpty;
+}
+// -----------------------------------------------------------------------------
+const int JET_ENGINETYPE_UNKNOWN = 0;
+const int JET_ENGINETYPE_JET10 = 1;
+const int JET_ENGINETYPE_JET11 = 2;
+const int JET_ENGINETYPE_JET20 = 3;
+const int JET_ENGINETYPE_JET3X = 4;
+const int JET_ENGINETYPE_JET4X = 5;
+const int JET_ENGINETYPE_DBASE3 = 10;
+const int JET_ENGINETYPE_DBASE4 = 11;
+const int JET_ENGINETYPE_DBASE5 = 12;
+const int JET_ENGINETYPE_EXCEL30 = 20;
+const int JET_ENGINETYPE_EXCEL40 = 21;
+const int JET_ENGINETYPE_EXCEL50 = 22;
+const int JET_ENGINETYPE_EXCEL80 = 23;
+const int JET_ENGINETYPE_EXCEL90 = 24;
+const int JET_ENGINETYPE_EXCHANGE4 = 30;
+const int JET_ENGINETYPE_LOTUSWK1 = 40;
+const int JET_ENGINETYPE_LOTUSWK3 = 41;
+const int JET_ENGINETYPE_LOTUSWK4 = 42;
+const int JET_ENGINETYPE_PARADOX3X = 50;
+const int JET_ENGINETYPE_PARADOX4X = 51;
+const int JET_ENGINETYPE_PARADOX5X = 52;
+const int JET_ENGINETYPE_PARADOX7X = 53;
+const int JET_ENGINETYPE_TEXT1X = 60;
+const int JET_ENGINETYPE_HTML1X = 70;
+
+sal_Bool ADOS::isJetEngine(sal_Int32 _nEngineType)
+{
+ sal_Bool bRet = sal_False;
+ switch(_nEngineType)
+ {
+ case JET_ENGINETYPE_UNKNOWN:
+ case JET_ENGINETYPE_JET10:
+ case JET_ENGINETYPE_JET11:
+ case JET_ENGINETYPE_JET20:
+ case JET_ENGINETYPE_JET3X:
+ case JET_ENGINETYPE_JET4X:
+ case JET_ENGINETYPE_DBASE3:
+ case JET_ENGINETYPE_DBASE4:
+ case JET_ENGINETYPE_DBASE5:
+ case JET_ENGINETYPE_EXCEL30:
+ case JET_ENGINETYPE_EXCEL40:
+ case JET_ENGINETYPE_EXCEL50:
+ case JET_ENGINETYPE_EXCEL80:
+ case JET_ENGINETYPE_EXCEL90:
+ case JET_ENGINETYPE_EXCHANGE4:
+ case JET_ENGINETYPE_LOTUSWK1:
+ case JET_ENGINETYPE_LOTUSWK3:
+ case JET_ENGINETYPE_LOTUSWK4:
+ case JET_ENGINETYPE_PARADOX3X:
+ case JET_ENGINETYPE_PARADOX4X:
+ case JET_ENGINETYPE_PARADOX5X:
+ case JET_ENGINETYPE_PARADOX7X:
+ case JET_ENGINETYPE_TEXT1X:
+ case JET_ENGINETYPE_HTML1X:
+ bRet = sal_True;
+ break;
+ }
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+ObjectTypeEnum ADOS::mapObjectType2Ado(sal_Int32 objType)
+{
+ ObjectTypeEnum eType = adPermObjTable;
+ switch(objType)
+ {
+ case PrivilegeObject::TABLE:
+ eType = adPermObjTable;
+ break;
+ case PrivilegeObject::VIEW:
+ eType = adPermObjView;
+ break;
+ case PrivilegeObject::COLUMN:
+ eType = adPermObjColumn;
+ break;
+ }
+ return eType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ADOS::mapAdoType2Object(ObjectTypeEnum objType)
+{
+ sal_Int32 nType = PrivilegeObject::TABLE;
+ switch(objType)
+ {
+ case adPermObjTable:
+ nType = PrivilegeObject::TABLE;
+ break;
+ case adPermObjView:
+ nType = PrivilegeObject::VIEW;
+ break;
+ case adPermObjColumn:
+ nType = PrivilegeObject::COLUMN;
+ break;
+ default:
+ OSL_ENSURE( false, "ADOS::mapAdoType2Object: privilege type cannot be translated!" );
+ break;
+ }
+ return nType;
+}
+#ifdef DELETE
+#undef DELETE
+#endif
+// -----------------------------------------------------------------------------
+sal_Int32 ADOS::mapAdoRights2Sdbc(RightsEnum eRights)
+{
+ sal_Int32 nRights = 0;
+ if((eRights & adRightInsert) == adRightInsert)
+ nRights |= Privilege::INSERT;
+ if((eRights & adRightDelete) == adRightDelete)
+ nRights |= ::com::sun::star::sdbcx::Privilege::DELETE;
+ if((eRights & adRightUpdate) == adRightUpdate)
+ nRights |= Privilege::UPDATE;
+ if((eRights & adRightWriteDesign) == adRightWriteDesign)
+ nRights |= Privilege::ALTER;
+ if((eRights & adRightRead) == adRightRead)
+ nRights |= Privilege::SELECT;
+ if((eRights & adRightReference) == adRightReference)
+ nRights |= Privilege::REFERENCE;
+ if((eRights & adRightDrop) == adRightDrop)
+ nRights |= Privilege::DROP;
+
+ return nRights;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ADOS::mapRights2Ado(sal_Int32 nRights)
+{
+ sal_Int32 eRights = adRightNone;
+
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ eRights |= adRightInsert;
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ eRights |= adRightDelete;
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ eRights |= adRightUpdate;
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ eRights |= adRightWriteDesign;
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ eRights |= adRightRead;
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ eRights |= adRightReference;
+ if((nRights & Privilege::DROP) == Privilege::DROP)
+ eRights |= adRightDrop;
+
+ return eRights;
+}
+// -----------------------------------------------------------------------------
+WpADOField ADOS::getField(ADORecordset* _pRecordSet,sal_Int32 _nColumnIndex) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if ( !_pRecordSet )
+ return WpADOField();
+
+ ADOFields* pFields = NULL;
+ _pRecordSet->get_Fields(&pFields);
+ WpOLEAppendCollection<ADOFields, ADOField, WpADOField> aFields(pFields);
+ if(_nColumnIndex <= 0 || _nColumnIndex > aFields.GetItemCount())
+ ::dbtools::throwInvalidIndexException(NULL);
+ WpADOField aField(aFields.GetItem(_nColumnIndex-1));
+ if(!aField.IsValid())
+ ::dbtools::throwInvalidIndexException(NULL);
+ return aField;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/ado/exports.dxp b/connectivity/source/drivers/ado/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/ado/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/ado/makefile.mk b/connectivity/source/drivers/ado/makefile.mk
new file mode 100644
index 000000000000..33e470648219
--- /dev/null
+++ b/connectivity/source/drivers/ado/makefile.mk
@@ -0,0 +1,114 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=ado
+VISIBILITY_HIDDEN=TRUE
+
+# ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/version.mk
+.INCLUDE : $(PRJ)$/makefile.pmk
+
+.IF "$(GUI)"=="WNT"
+# --- Files -------------------------------------
+
+EXCEPTIONSFILES= \
+ $(SLO)$/ADatabaseMetaDataImpl.obj \
+ $(SLO)$/Aolevariant.obj \
+ $(SLO)$/ADatabaseMetaData.obj \
+ $(SLO)$/AColumn.obj \
+ $(SLO)$/AColumns.obj \
+ $(SLO)$/AIndex.obj \
+ $(SLO)$/AIndexes.obj \
+ $(SLO)$/AKey.obj \
+ $(SLO)$/AKeys.obj \
+ $(SLO)$/AUser.obj \
+ $(SLO)$/AUsers.obj \
+ $(SLO)$/AGroup.obj \
+ $(SLO)$/AGroups.obj \
+ $(SLO)$/ACatalog.obj \
+ $(SLO)$/AView.obj \
+ $(SLO)$/AViews.obj \
+ $(SLO)$/ATable.obj \
+ $(SLO)$/ATables.obj \
+ $(SLO)$/ACallableStatement.obj \
+ $(SLO)$/ADatabaseMetaDataResultSetMetaData.obj \
+ $(SLO)$/ADatabaseMetaDataResultSet.obj \
+ $(SLO)$/AResultSet.obj \
+ $(SLO)$/AConnection.obj \
+ $(SLO)$/AStatement.obj \
+ $(SLO)$/APreparedStatement.obj \
+ $(SLO)$/AResultSetMetaData.obj \
+ $(SLO)$/ADriver.obj \
+ $(SLO)$/Aservices.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/Awrapado.obj \
+ $(SLO)$/adoimp.obj
+# --- Library -----------------------------------
+
+SHL1TARGET= $(ADO_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(OLE32LIB) \
+ $(OLEAUT32LIB) \
+ $(UUIDLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(COMPHELPERLIB)" == ""
+SHL1STDLIBS+= icomphelp2.lib
+.ENDIF
+
+#SHL1DEPN=
+SHL1IMPLIB= i$(SHL1TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+.ELSE
+dummy:
+ @echo "Nothing to build for GUI $(GUI)"
+.ENDIF # "$(GUI)"=="WNT"
+# --- Targets ----------------------------------
+.INCLUDE : $(PRJ)$/target.pmk
+
diff --git a/connectivity/source/drivers/calc/CCatalog.cxx b/connectivity/source/drivers/calc/CCatalog.cxx
new file mode 100644
index 000000000000..449e720f18c4
--- /dev/null
+++ b/connectivity/source/drivers/calc/CCatalog.cxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "calc/CCatalog.hxx"
+#include "calc/CConnection.hxx"
+#include "calc/CTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+using namespace connectivity::calc;
+// -------------------------------------------------------------------------
+OCalcCatalog::OCalcCatalog(OCalcConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcCatalog::OCalcCatalog" );
+}
+// -------------------------------------------------------------------------
+void OCalcCatalog::refreshTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcCatalog::refreshTables" );
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ OCalcConnection::ODocHolder aDocHodler(((OCalcConnection*)m_pConnection));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OCalcTables(m_xMetaData,*this,m_aMutex,aVector);
+
+ // this avoids that the document will be loaded a 2nd time when one table will be accessed.
+ //if ( m_pTables && m_pTables->hasElements() )
+ // m_pTables->getByIndex(0);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/calc/CColumns.cxx b/connectivity/source/drivers/calc/CColumns.cxx
new file mode 100644
index 000000000000..394302c2aeb8
--- /dev/null
+++ b/connectivity/source/drivers/calc/CColumns.cxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CColumns.hxx"
+#include "calc/CTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::calc;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+sdbcx::ObjectType OCalcColumns::createObject(const ::rtl::OUString& _rName)
+{
+ OCalcTable* pTable = (OCalcTable*)m_pTable;
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+ sdbcx::ObjectType xRet;
+ if(aIter != aCols->get().end())
+ xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CConnection.cxx b/connectivity/source/drivers/calc/CConnection.cxx
new file mode 100644
index 000000000000..2d5e1a93d3ee
--- /dev/null
+++ b/connectivity/source/drivers/calc/CConnection.cxx
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CConnection.hxx"
+#include "calc/CDatabaseMetaData.hxx"
+#include "calc/CCatalog.hxx"
+#ifndef _CONNECTIVITY_CALC_ODRIVER_HXX_
+#include "calc/CDriver.hxx"
+#endif
+#ifndef CONNECTIVITY_RESOURCE_CALC_HRC
+#include "resource/calc_res.hrc"
+#endif
+#include "resource/sharedresources.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/frame/XComponentLoader.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <tools/urlobj.hxx>
+#include "calc/CPreparedStatement.hxx"
+#include "calc/CStatement.hxx"
+#include <unotools/pathoptions.hxx>
+#include <connectivity/dbexception.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+
+typedef connectivity::file::OConnection OConnection_BASE;
+
+//------------------------------------------------------------------------------
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::sheet;
+
+// --------------------------------------------------------------------------------
+
+OCalcConnection::OCalcConnection(ODriver* _pDriver) : OConnection(_pDriver),m_nDocCount(0)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::OCalcConnection" );
+ // m_aFilenameExtension is not used
+}
+
+OCalcConnection::~OCalcConnection()
+{
+}
+
+void OCalcConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info)
+ throw(SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::construct" );
+ // open file
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1));
+
+ m_aFileName = aDSN;
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ {
+ SvtPathOptions aPathOptions;
+ m_aFileName = aPathOptions.SubstituteVariable(m_aFileName);
+ }
+ aURL.SetSmartURL(m_aFileName);
+ if ( aURL.GetProtocol() == INET_PROT_NOT_VALID )
+ {
+ // don't pass invalid URL to loadComponentFromURL
+ throw SQLException();
+ }
+ m_aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ m_sPassword = ::rtl::OUString();
+ const char* pPwd = "password";
+
+ const PropertyValue *pIter = info.getConstArray();
+ const PropertyValue *pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(!pIter->Name.compareToAscii(pPwd))
+ {
+ pIter->Value >>= m_sPassword;
+ break;
+ }
+ } // for(;pIter != pEnd;++pIter)
+ ODocHolder aDocHodler(this); // just to test that the doc can be loaded
+ acquireDoc();
+}
+// -----------------------------------------------------------------------------
+Reference< XSpreadsheetDocument> OCalcConnection::acquireDoc()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::acquireDoc" );
+ if ( m_xDoc.is() )
+ {
+ osl_incrementInterlockedCount(&m_nDocCount);
+ return m_xDoc;
+ }
+ // open read-only as long as updating isn't implemented
+ Sequence<PropertyValue> aArgs(2);
+ aArgs[0].Name = ::rtl::OUString::createFromAscii("Hidden");
+ aArgs[0].Value <<= (sal_Bool) sal_True;
+ aArgs[1].Name = ::rtl::OUString::createFromAscii("ReadOnly");
+ aArgs[1].Value <<= (sal_Bool) sal_True;
+
+ if ( m_sPassword.getLength() )
+ {
+ const sal_Int32 nPos = aArgs.getLength();
+ aArgs.realloc(nPos+1);
+ aArgs[nPos].Name = ::rtl::OUString::createFromAscii("Password");
+ aArgs[nPos].Value <<= m_sPassword;
+ }
+
+ Reference< XComponentLoader > xDesktop( getDriver()->getFactory()->createInstance(
+ ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), UNO_QUERY );
+ if (!xDesktop.is())
+ {
+ OSL_ASSERT("no desktop");
+ throw SQLException();
+ }
+ Reference< XComponent > xComponent;
+ Any aLoaderException;
+ try
+ {
+ xComponent = xDesktop->loadComponentFromURL(
+ m_aFileName, ::rtl::OUString::createFromAscii("_blank"), 0, aArgs );
+ }
+ catch( const Exception& )
+ {
+ aLoaderException = ::cppu::getCaughtException();
+ }
+
+ m_xDoc.set(xComponent, UNO_QUERY );
+
+ // if the URL is not a spreadsheet document, throw the exception here
+ // instead of at the first access to it
+ if ( !m_xDoc.is() )
+ {
+ Any aErrorDetails;
+ if ( aLoaderException.hasValue() )
+ {
+ Exception aLoaderError;
+ OSL_VERIFY( aLoaderException >>= aLoaderError );
+
+ SQLException aDetailException;
+ aDetailException.Message = m_aResources.getResourceStringWithSubstitution(
+ STR_LOAD_FILE_ERROR_MESSAGE,
+ "$exception_type$", aLoaderException.getValueTypeName(),
+ "$error_message$", aLoaderError.Message
+ );
+ aErrorDetails <<= aDetailException;
+ }
+
+ const ::rtl::OUString sError( m_aResources.getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_FILE,
+ "$filename$", m_aFileName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this, aErrorDetails );
+ }
+ osl_incrementInterlockedCount(&m_nDocCount);
+ return m_xDoc;
+}
+// -----------------------------------------------------------------------------
+void OCalcConnection::releaseDoc()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::releaseDoc" );
+ if ( osl_decrementInterlockedCount(&m_nDocCount) == 0 )
+ ::comphelper::disposeComponent( m_xDoc );
+}
+// -----------------------------------------------------------------------------
+void OCalcConnection::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_nDocCount = 0;
+ ::comphelper::disposeComponent( m_xDoc );
+
+ OConnection::disposing();
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+
+IMPLEMENT_SERVICE_INFO(OCalcConnection, "com.sun.star.sdbc.drivers.calc.Connection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+
+Reference< XDatabaseMetaData > SAL_CALL OCalcConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OCalcDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+
+//------------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< XTablesSupplier > OCalcConnection::createCatalog()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::createCatalog" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ OCalcCatalog *pCat = new OCalcCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XStatement > SAL_CALL OCalcConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::createStatement" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XStatement > xReturn = new OCalcStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareStatement( const ::rtl::OUString& sql )
+ throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::prepareStatement" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OCalcPreparedStatement* pStmt = new OCalcPreparedStatement(this);
+ Reference< XPreparedStatement > xHoldAlive = pStmt;
+ pStmt->construct(sql);
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+
+// --------------------------------------------------------------------------------
+
+Reference< XPreparedStatement > SAL_CALL OCalcConnection::prepareCall( const ::rtl::OUString& /*sql*/ )
+ throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcConnection::prepareCall" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CDatabaseMetaData.cxx b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
new file mode 100644
index 000000000000..274597ebb72c
--- /dev/null
+++ b/connectivity/source/drivers/calc/CDatabaseMetaData.cxx
@@ -0,0 +1,490 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "calc/CDatabaseMetaData.hxx"
+#include "calc/CConnection.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <tools/urlobj.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::sheet;
+
+// -------------------------------------------------------------------------
+
+OCalcDatabaseMetaData::OCalcDatabaseMetaData(OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::OCalcDatabaseMetaData" );
+}
+
+// -------------------------------------------------------------------------
+
+OCalcDatabaseMetaData::~OCalcDatabaseMetaData()
+{
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > OCalcDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::impl_getTypeInfo_throw" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+
+ aRows.reserve(6);
+ aRow.reserve(18);
+
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)65535));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value()); // ORowSetValue((sal_Int32)ColumnValue::NULLABLE)
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::BIT);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DATE);
+ aRow[3] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIME);
+ aRow[3] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[3] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabIter = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabIter + aTabNames.getLength();
+ for(;pTabIter != pTabEnd;++pTabIter)
+ {
+ if(match(tableNamePattern,*pTabIter,'\0'))
+ {
+ const Reference< XColumnsSupplier> xTable(xNames->getByName(*pTabIter),UNO_QUERY_THROW);
+ OSL_ENSURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!");
+ aRow[3] = new ORowSetValueDecorator(*pTabIter);
+
+ const Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ const Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pColumnIter = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pColumnIter + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pColumnIter != pEnd;++pColumnIter,++i)
+ {
+ if(match(columnNamePattern,*pColumnIter,'\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator( *pColumnIter);
+
+ xColumns->getByName(*pColumnIter) >>= xColumn;
+ OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+ aRow[6] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
+ aRow[7] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
+ // aRow[8] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ aRow[9] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ aRow[11] = new ORowSetValueDecorator(::comphelper::getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
+ // aRow[12] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ aRow[13] = new ORowSetValueDecorator(::comphelper::getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
+ // aRow[14] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ // aRow[15] = xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME));
+ switch(sal_Int32(aRow[5]->getValue()))
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
+ break;
+ default:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
+ }
+ aRow[17] = new ORowSetValueDecorator(i);
+ switch(sal_Int32(aRow[11]->getValue()))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+ break;
+ default:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString());
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OCalcDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getURL" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:calc:")) + m_pConnection->getURL();
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxBinaryLiteralLength" );
+ return STRING_MAXLEN;
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxCharLiteralLength" );
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnNameLength" );
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnsInIndex" );
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getMaxColumnsInTable" );
+ return 256;
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool lcl_IsEmptyOrHidden( const Reference<XSpreadsheets>& xSheets, const ::rtl::OUString& rName )
+{
+ Any aAny = xSheets->getByName( rName );
+ Reference<XSpreadsheet> xSheet;
+ if ( aAny >>= xSheet )
+ {
+ // test if sheet is hidden
+
+ Reference<XPropertySet> xProp( xSheet, UNO_QUERY );
+ if (xProp.is())
+ {
+ sal_Bool bVisible = sal_Bool();
+ Any aVisAny = xProp->getPropertyValue( ::rtl::OUString::createFromAscii("IsVisible") );
+ if ( aVisAny >>= bVisible )
+ if (!bVisible)
+ return sal_True; // hidden
+ }
+
+#if 0
+ // test if whole sheet is empty
+
+ Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
+ Reference<XCellRangesQuery> xQuery( xSheet, UNO_QUERY );
+ if ( xAddr.is() && xQuery.is() )
+ {
+ CellRangeAddress aTotalRange = xAddr->getRangeAddress();
+ // queryIntersection to get a ranges object
+ Reference<XSheetCellRanges> xRanges = xQuery->queryIntersection( aTotalRange );
+ if (xRanges.is())
+ {
+ Reference<XEnumerationAccess> xCells = xRanges->getCells();
+ if (xCells.is())
+ {
+ if ( !xCells->hasElements() )
+ return sal_True; // empty
+ }
+ }
+ }
+#endif
+
+ // use the same data area as in OCalcTable to test for empty table
+
+ Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
+ Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
+ if ( xRange.is() )
+ {
+ xCursor->collapseToSize( 1, 1 ); // single (first) cell
+ xCursor->collapseToCurrentRegion(); // contiguous data area
+
+ CellRangeAddress aRangeAddr = xRange->getRangeAddress();
+ if ( aRangeAddr.StartColumn == aRangeAddr.EndColumn &&
+ aRangeAddr.StartRow == aRangeAddr.EndRow )
+ {
+ // single cell -> check content
+ Reference<XCell> xCell = xCursor->getCellByPosition( 0, 0 );
+ if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
+ return sal_True;
+ }
+ }
+ }
+
+ return sal_False;
+}
+
+sal_Bool lcl_IsUnnamed( const Reference<XDatabaseRanges>& xRanges, const ::rtl::OUString& rName )
+{
+ sal_Bool bUnnamed = sal_False;
+
+ Any aAny = xRanges->getByName( rName );
+ Reference<XDatabaseRange> xRange;
+ if ( aAny >>= xRange )
+ {
+ Reference<XPropertySet> xRangeProp( xRange, UNO_QUERY );
+ if ( xRangeProp.is() )
+ {
+ try
+ {
+ Any aUserAny = xRangeProp->getPropertyValue( ::rtl::OUString::createFromAscii("IsUserDefined") );
+ sal_Bool bUserDefined = sal_Bool();
+ if ( aUserAny >>= bUserDefined )
+ bUnnamed = !bUserDefined;
+ }
+ catch ( UnknownPropertyException& )
+ {
+ // optional property
+ }
+ }
+ }
+
+ return bUnnamed;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCalcDatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types )
+ throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcDatabaseMetaData::getTables" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xRef = pResult;
+
+ // check if ORowSetValue type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ sal_Bool bTableFound = sal_True;
+ sal_Int32 nLength = types.getLength();
+ if(nLength)
+ {
+ bTableFound = sal_False;
+
+ const ::rtl::OUString* pIter = types.getConstArray();
+ const ::rtl::OUString* pEnd = pIter + nLength;
+ for(;pIter != pEnd;++pIter)
+ {
+ if(*pIter == aTable)
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ }
+ }
+ if(!bTableFound)
+ return xRef;
+
+ // get the sheet names from the document
+
+ OCalcConnection::ODocHolder aDocHodler(((OCalcConnection*)m_pConnection));
+ Reference<XSpreadsheetDocument> xDoc = aDocHodler.getDoc();
+ if ( !xDoc.is() )
+ throw SQLException();
+ Reference<XSpreadsheets> xSheets = xDoc->getSheets();
+ if ( !xSheets.is() )
+ throw SQLException();
+ Sequence< ::rtl::OUString > aSheetNames = xSheets->getElementNames();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ sal_Int32 nSheetCount = aSheetNames.getLength();
+ for (sal_Int32 nSheet=0; nSheet<nSheetCount; nSheet++)
+ {
+ ::rtl::OUString aName = aSheetNames[nSheet];
+ if ( !lcl_IsEmptyOrHidden( xSheets, aName ) && match(tableNamePattern,aName,'\0') )
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRows.push_back(aRow);
+ }
+ }
+
+ // also use database ranges
+
+ Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY );
+ if ( xDocProp.is() )
+ {
+ Any aRangesAny = xDocProp->getPropertyValue( ::rtl::OUString::createFromAscii("DatabaseRanges") );
+ Reference<XDatabaseRanges> xRanges;
+ if ( aRangesAny >>= xRanges )
+ {
+ Sequence< ::rtl::OUString > aDBNames = xRanges->getElementNames();
+ sal_Int32 nDBCount = aDBNames.getLength();
+ for (sal_Int32 nRange=0; nRange<nDBCount; nRange++)
+ {
+ ::rtl::OUString aName = aDBNames[nRange];
+ if ( !lcl_IsUnnamed( xRanges, aName ) && match(tableNamePattern,aName,'\0') )
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/calc/CDriver.cxx b/connectivity/source/drivers/calc/CDriver.cxx
new file mode 100644
index 000000000000..f3ae81ad6670
--- /dev/null
+++ b/connectivity/source/drivers/calc/CDriver.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CDriver.hxx"
+#include "calc/CConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "resource/sharedresources.hxx"
+#include "resource/calc_res.hrc"
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+
+//------------------------------------------------------------------------------
+// static ServiceInfo
+
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.calc.ODriver");
+}
+
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// service names from file::OFileDriver
+
+//------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL
+ connectivity::calc::ODriver_CreateInstance(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url,
+ const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OCalcConnection* pCon = new OCalcConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return url.compareTo(::rtl::OUString::createFromAscii("sdbc:calc:"),10) == 0;
+}
+
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( !acceptsURL(url) )
+ {
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+ return Sequence< DriverPropertyInfo >();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CPreparedStatement.cxx b/connectivity/source/drivers/calc/CPreparedStatement.cxx
new file mode 100644
index 000000000000..46f5b8342a71
--- /dev/null
+++ b/connectivity/source/drivers/calc/CPreparedStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CPreparedStatement.hxx"
+#include "calc/CResultSet.hxx"
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OCalcPreparedStatement::createResultSet()
+{
+ return new OCalcResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OCalcPreparedStatement,"com.sun.star.sdbc.driver.calc.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
diff --git a/connectivity/source/drivers/calc/CResultSet.cxx b/connectivity/source/drivers/calc/CResultSet.cxx
new file mode 100644
index 000000000000..6f2566c5ff94
--- /dev/null
+++ b/connectivity/source/drivers/calc/CResultSet.cxx
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include "calc/CResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// using namespace com::sun::star::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OCalcResultSet::OCalcResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OCalcResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.calc.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OCalcResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCalcResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OResultSet::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OCalcResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OCalcResultSet::getTypes( ) throw( RuntimeException)
+{
+ return ::comphelper::concatSequences(OResultSet::getTypes(),OCalcResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OCalcResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False);
+
+ return relative(rows);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ return (lhs == rhs) ? 0 : 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCalcResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCalcResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OCalcResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+sal_Bool OCalcResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
+{
+ // Calc table has no index
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OCalcResultSet::getInfoHelper()
+{
+ return *OCalcResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OCalcResultSet::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL OCalcResultSet::acquire() throw()
+{
+ OCalcResultSet_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCalcResultSet::release() throw()
+{
+ OCalcResultSet_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCalcResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/calc/CStatement.cxx b/connectivity/source/drivers/calc/CStatement.cxx
new file mode 100644
index 000000000000..95eece44ddca
--- /dev/null
+++ b/connectivity/source/drivers/calc/CStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CStatement.hxx"
+#include "calc/CResultSet.hxx"
+
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OCalcStatement::createResultSet()
+{
+ return new OCalcResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OCalcStatement,"com.sun.star.sdbc.driver.calc.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/calc/CTable.cxx b/connectivity/source/drivers/calc/CTable.cxx
new file mode 100644
index 000000000000..a4e5f35825f5
--- /dev/null
+++ b/connectivity/source/drivers/calc/CTable.cxx
@@ -0,0 +1,871 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CTable.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+//#ifndef _COM_SUN_STAR_UCB_XCONTENTACCESS_HPP_
+//#include <com/sun/star/ucb/XContentAccess.hpp>
+//#endif
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
+#include <com/sun/star/sheet/XSpreadsheet.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangesQuery.hpp>
+#include <com/sun/star/sheet/XDatabaseRanges.hpp>
+#include <com/sun/star/sheet/XDatabaseRange.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
+#include <com/sun/star/sheet/XUsedAreaCursor.hpp>
+#include <com/sun/star/sheet/CellFlags.hpp>
+#include <com/sun/star/sheet/FormulaResult.hpp>
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <com/sun/star/util/XNumberFormatsSupplier.hpp>
+#include <com/sun/star/text/XText.hpp>
+#include <svl/converter.hxx>
+#include "calc/CConnection.hxx"
+#include "calc/CColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/math.hxx>
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace ::dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sheet;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::text;
+using namespace ::com::sun::star::util;
+
+// -------------------------------------------------------------------------
+
+void lcl_UpdateArea( const Reference<XCellRange>& xUsedRange, sal_Int32& rEndCol, sal_Int32& rEndRow )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_UpdateArea" );
+ // update rEndCol, rEndRow if any non-empty cell in xUsedRange is right/below
+
+ const Reference<XCellRangesQuery> xUsedQuery( xUsedRange, UNO_QUERY );
+ if ( xUsedQuery.is() )
+ {
+ const sal_Int16 nContentFlags =
+ CellFlags::STRING | CellFlags::VALUE | CellFlags::DATETIME | CellFlags::FORMULA | CellFlags::ANNOTATION;
+
+ const Reference<XSheetCellRanges> xUsedRanges = xUsedQuery->queryContentCells( nContentFlags );
+ const Sequence<CellRangeAddress> aAddresses = xUsedRanges->getRangeAddresses();
+
+ const sal_Int32 nCount = aAddresses.getLength();
+ const CellRangeAddress* pData = aAddresses.getConstArray();
+ for ( sal_Int32 i=0; i<nCount; i++ )
+ {
+ rEndCol = pData[i].EndColumn > rEndCol ? pData[i].EndColumn : rEndCol;
+ rEndRow = pData[i].EndRow > rEndRow ? pData[i].EndRow : rEndRow;
+ }
+ }
+}
+
+void lcl_GetDataArea( const Reference<XSpreadsheet>& xSheet, sal_Int32& rColumnCount, sal_Int32& rRowCount )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_GetDataArea" );
+ Reference<XSheetCellCursor> xCursor = xSheet->createCursor();
+ Reference<XCellRangeAddressable> xRange( xCursor, UNO_QUERY );
+ if ( !xRange.is() )
+ {
+ rColumnCount = rRowCount = 0;
+ return;
+ }
+
+ // first find the contiguous cell area starting at A1
+
+ xCursor->collapseToSize( 1, 1 ); // single (first) cell
+ xCursor->collapseToCurrentRegion(); // contiguous data area
+
+ CellRangeAddress aRegionAddr = xRange->getRangeAddress();
+ sal_Int32 nEndCol = aRegionAddr.EndColumn;
+ sal_Int32 nEndRow = aRegionAddr.EndRow;
+
+ Reference<XUsedAreaCursor> xUsed( xCursor, UNO_QUERY );
+ if ( xUsed.is() )
+ {
+ // The used area from XUsedAreaCursor includes visible attributes.
+ // If the used area is larger than the contiguous cell area, find non-empty
+ // cells in that area.
+
+ xUsed->gotoEndOfUsedArea( sal_False );
+ CellRangeAddress aUsedAddr = xRange->getRangeAddress();
+
+ if ( aUsedAddr.EndColumn > aRegionAddr.EndColumn )
+ {
+ Reference<XCellRange> xUsedRange = xSheet->getCellRangeByPosition(
+ aRegionAddr.EndColumn + 1, 0, aUsedAddr.EndColumn, aUsedAddr.EndRow );
+ lcl_UpdateArea( xUsedRange, nEndCol, nEndRow );
+ }
+
+ if ( aUsedAddr.EndRow > aRegionAddr.EndRow )
+ {
+ // only up to the last column of aRegionAddr, the other columns are handled above
+ Reference<XCellRange> xUsedRange = xSheet->getCellRangeByPosition(
+ 0, aRegionAddr.EndRow + 1, aRegionAddr.EndColumn, aUsedAddr.EndRow );
+ lcl_UpdateArea( xUsedRange, nEndCol, nEndRow );
+ }
+ }
+
+ rColumnCount = nEndCol + 1; // number of columns
+ rRowCount = nEndRow; // first row (headers) is not counted
+}
+
+CellContentType lcl_GetContentOrResultType( const Reference<XCell>& xCell )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_GetContentOrResultType" );
+ CellContentType eCellType = xCell->getType();
+ if ( eCellType == CellContentType_FORMULA )
+ {
+ static const ::rtl::OUString s_sFormulaResultType(RTL_CONSTASCII_USTRINGPARAM("FormulaResultType"));
+ Reference<XPropertySet> xProp( xCell, UNO_QUERY );
+ try
+ {
+ xProp->getPropertyValue( s_sFormulaResultType ) >>= eCellType; // type of formula result
+ }
+ catch (UnknownPropertyException&)
+ {
+ eCellType = CellContentType_VALUE; // if FormulaResultType property not available
+ }
+ }
+ return eCellType;
+}
+
+Reference<XCell> lcl_GetUsedCell( const Reference<XSpreadsheet>& xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_GetUsedCell" );
+ Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow );
+ if ( xCell.is() && xCell->getType() == CellContentType_EMPTY )
+ {
+ // get first non-empty cell
+
+ Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
+ if (xAddr.is())
+ {
+ CellRangeAddress aTotalRange = xAddr->getRangeAddress();
+ sal_Int32 nLastRow = aTotalRange.EndRow;
+ Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
+ if (xQuery.is())
+ {
+ // queryIntersection to get a ranges object
+ Reference<XSheetCellRanges> xRanges = xQuery->queryIntersection( aTotalRange );
+ if (xRanges.is())
+ {
+ Reference<XEnumerationAccess> xCells = xRanges->getCells();
+ if (xCells.is())
+ {
+ Reference<XEnumeration> xEnum = xCells->createEnumeration();
+ if ( xEnum.is() && xEnum->hasMoreElements() )
+ {
+ // get first non-empty cell from enumeration
+ xCell.set(xEnum->nextElement(),UNO_QUERY);
+ }
+ // otherwise, keep empty cell
+ }
+ }
+ }
+ }
+ }
+ return xCell;
+}
+
+bool lcl_HasTextInColumn( const Reference<XSpreadsheet>& xSheet, sal_Int32 nDocColumn, sal_Int32 nDocRow )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_HasTextInColumn" );
+ // look for any text cell or text result in the column
+
+ Reference<XCellRangeAddressable> xAddr( xSheet, UNO_QUERY );
+ if (xAddr.is())
+ {
+ CellRangeAddress aTotalRange = xAddr->getRangeAddress();
+ sal_Int32 nLastRow = aTotalRange.EndRow;
+ Reference<XCellRangesQuery> xQuery( xSheet->getCellRangeByPosition( nDocColumn, nDocRow, nDocColumn, nLastRow ), UNO_QUERY );
+ if (xQuery.is())
+ {
+ // are there text cells in the column?
+ Reference<XSheetCellRanges> xTextContent = xQuery->queryContentCells( CellFlags::STRING );
+ if ( xTextContent.is() && xTextContent->hasElements() )
+ return true;
+
+ // are there formulas with text results in the column?
+ Reference<XSheetCellRanges> xTextFormula = xQuery->queryFormulaCells( FormulaResult::STRING );
+ if ( xTextFormula.is() && xTextFormula->hasElements() )
+ return true;
+ }
+ }
+
+ return false;
+}
+
+void lcl_GetColumnInfo( const Reference<XSpreadsheet>& xSheet, const Reference<XNumberFormats>& xFormats,
+ sal_Int32 nDocColumn, sal_Int32 nStartRow, sal_Bool bHasHeaders,
+ ::rtl::OUString& rName, sal_Int32& rDataType, sal_Bool& rCurrency )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_GetColumnInfo" );
+ //! avoid duplicate field names
+
+ // get column name from first row, if range contains headers
+
+ if ( bHasHeaders )
+ {
+ Reference<XText> xHeaderText( xSheet->getCellByPosition( nDocColumn, nStartRow ), UNO_QUERY );
+ if ( xHeaderText.is() )
+ rName = xHeaderText->getString();
+ }
+
+ // get column type from first data row
+
+ sal_Int32 nDataRow = nStartRow;
+ if ( bHasHeaders )
+ ++nDataRow;
+ Reference<XCell> xDataCell = lcl_GetUsedCell( xSheet, nDocColumn, nDataRow );
+
+ Reference<XPropertySet> xProp( xDataCell, UNO_QUERY );
+ if ( xProp.is() )
+ {
+ rCurrency = sal_False; // set to true for currency below
+
+ const CellContentType eCellType = lcl_GetContentOrResultType( xDataCell );
+ // #i35178# use "text" type if there is any text cell in the column
+ if ( eCellType == CellContentType_TEXT || lcl_HasTextInColumn( xSheet, nDocColumn, nDataRow ) )
+ rDataType = DataType::VARCHAR;
+ else if ( eCellType == CellContentType_VALUE )
+ {
+ // get number format to distinguish between different types
+
+ sal_Int16 nNumType = NumberFormat::NUMBER;
+ try
+ {
+ static ::rtl::OUString s_NumberFormat(RTL_CONSTASCII_USTRINGPARAM("NumberFormat"));
+ sal_Int32 nKey = 0;
+
+ if ( xProp->getPropertyValue( s_NumberFormat ) >>= nKey )
+ {
+ const Reference<XPropertySet> xFormat = xFormats->getByKey( nKey );
+ if ( xFormat.is() )
+ {
+ xFormat->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE) ) >>= nNumType;
+ }
+ }
+ }
+ catch ( Exception& )
+ {
+ }
+
+ if ( nNumType & NumberFormat::TEXT )
+ rDataType = DataType::VARCHAR;
+ else if ( nNumType & NumberFormat::NUMBER )
+ rDataType = DataType::DECIMAL;
+ else if ( nNumType & NumberFormat::CURRENCY )
+ {
+ rCurrency = sal_True;
+ rDataType = DataType::DECIMAL;
+ }
+ else if ( ( nNumType & NumberFormat::DATETIME ) == NumberFormat::DATETIME )
+ {
+ // NumberFormat::DATETIME is DATE | TIME
+ rDataType = DataType::TIMESTAMP;
+ }
+ else if ( nNumType & NumberFormat::DATE )
+ rDataType = DataType::DATE;
+ else if ( nNumType & NumberFormat::TIME )
+ rDataType = DataType::TIME;
+ else if ( nNumType & NumberFormat::LOGICAL )
+ rDataType = DataType::BIT;
+ else
+ rDataType = DataType::DECIMAL;
+ }
+ else
+ {
+ // whole column empty
+ rDataType = DataType::VARCHAR;
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+
+void lcl_SetValue( ORowSetValue& rValue, const Reference<XSpreadsheet>& xSheet,
+ sal_Int32 nStartCol, sal_Int32 nStartRow, sal_Bool bHasHeaders,
+ const ::Date& rNullDate,
+ sal_Int32 nDBRow, sal_Int32 nDBColumn, sal_Int32 nType )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_SetValue" );
+ sal_Int32 nDocColumn = nStartCol + nDBColumn - 1; // database counts from 1
+ sal_Int32 nDocRow = nStartRow + nDBRow - 1;
+ if (bHasHeaders)
+ ++nDocRow;
+
+ const Reference<XCell> xCell = xSheet->getCellByPosition( nDocColumn, nDocRow );
+ if ( xCell.is() )
+ {
+ CellContentType eCellType = lcl_GetContentOrResultType( xCell );
+ switch (nType)
+ {
+ case DataType::VARCHAR:
+ if ( eCellType == CellContentType_EMPTY )
+ rValue.setNull();
+ else
+ {
+ // #i25840# still let Calc convert numbers to text
+ const Reference<XText> xText( xCell, UNO_QUERY );
+ if ( xText.is() )
+ rValue = xText->getString();
+ }
+ break;
+ case DataType::DECIMAL:
+ if ( eCellType == CellContentType_VALUE )
+ rValue = xCell->getValue(); // double
+ else
+ rValue.setNull();
+ break;
+ case DataType::BIT:
+ if ( eCellType == CellContentType_VALUE )
+ rValue = (sal_Bool)( xCell->getValue() != 0.0 );
+ else
+ rValue.setNull();
+ break;
+ case DataType::DATE:
+ if ( eCellType == CellContentType_VALUE )
+ {
+ ::Date aDate( rNullDate );
+ aDate += (long)::rtl::math::approxFloor( xCell->getValue() );
+ ::com::sun::star::util::Date aDateStruct( aDate.GetDay(), aDate.GetMonth(), aDate.GetYear() );
+ rValue = aDateStruct;
+ }
+ else
+ rValue.setNull();
+ break;
+ case DataType::TIME:
+ if ( eCellType == CellContentType_VALUE )
+ {
+ double fCellVal = xCell->getValue();
+ double fTime = fCellVal - rtl::math::approxFloor( fCellVal );
+ long nIntTime = (long)rtl::math::round( fTime * 8640000.0 );
+ if ( nIntTime == 8640000 )
+ nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
+ ::com::sun::star::util::Time aTime;
+ aTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
+ nIntTime /= 100;
+ aTime.Seconds = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ aTime.Minutes = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ OSL_ENSURE( nIntTime < 24, "error in time calculation" );
+ aTime.Hours = (sal_uInt16) nIntTime;
+ rValue = aTime;
+ }
+ else
+ rValue.setNull();
+ break;
+ case DataType::TIMESTAMP:
+ if ( eCellType == CellContentType_VALUE )
+ {
+ double fCellVal = xCell->getValue();
+ double fDays = ::rtl::math::approxFloor( fCellVal );
+ double fTime = fCellVal - fDays;
+ long nIntDays = (long)fDays;
+ long nIntTime = (long)::rtl::math::round( fTime * 8640000.0 );
+ if ( nIntTime == 8640000 )
+ {
+ nIntTime = 0; // 23:59:59.995 and above is 00:00:00.00
+ ++nIntDays; // (next day)
+ }
+
+ ::com::sun::star::util::DateTime aDateTime;
+
+ aDateTime.HundredthSeconds = (sal_uInt16)( nIntTime % 100 );
+ nIntTime /= 100;
+ aDateTime.Seconds = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ aDateTime.Minutes = (sal_uInt16)( nIntTime % 60 );
+ nIntTime /= 60;
+ OSL_ENSURE( nIntTime < 24, "error in time calculation" );
+ aDateTime.Hours = (sal_uInt16) nIntTime;
+
+ ::Date aDate( rNullDate );
+ aDate += nIntDays;
+ aDateTime.Day = aDate.GetDay();
+ aDateTime.Month = aDate.GetMonth();
+ aDateTime.Year = aDate.GetYear();
+
+ rValue = aDateTime;
+ }
+ else
+ rValue.setNull();
+ break;
+ } // switch (nType)
+ }
+
+// rValue.setTypeKind(nType);
+}
+
+// -------------------------------------------------------------------------
+
+::rtl::OUString lcl_GetColumnStr( sal_Int32 nColumn )
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::lcl_GetColumnStr" );
+ if ( nColumn < 26 )
+ return ::rtl::OUString::valueOf( (sal_Unicode) ( 'A' + nColumn ) );
+ else
+ {
+ ::rtl::OUStringBuffer aBuffer(2);
+ aBuffer.setLength( 2 );
+ aBuffer.setCharAt( 0, (sal_Unicode) ( 'A' + ( nColumn / 26 ) - 1 ) );
+ aBuffer.setCharAt( 1, (sal_Unicode) ( 'A' + ( nColumn % 26 ) ) );
+ return aBuffer.makeStringAndClear();
+ }
+}
+
+void OCalcTable::fillColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::fillColumns" );
+ if ( !m_xSheet.is() )
+ throw SQLException();
+
+ String aStrFieldName;
+ aStrFieldName.AssignAscii("Column");
+ ::rtl::OUString aTypeName;
+ ::comphelper::UStringMixEqual aCase(m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers());
+ const sal_Bool bStoresMixedCaseQuotedIdentifiers = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+
+ for (sal_Int32 i = 0; i < m_nDataCols; i++)
+ {
+ ::rtl::OUString aColumnName;
+ sal_Int32 eType = DataType::OTHER;
+ sal_Bool bCurrency = sal_False;
+
+ lcl_GetColumnInfo( m_xSheet, m_xFormats, m_nStartCol + i, m_nStartRow, m_bHasHeaders,
+ aColumnName, eType, bCurrency );
+
+ if ( !aColumnName.getLength() )
+ aColumnName = lcl_GetColumnStr( i );
+
+ sal_Int32 nPrecision = 0; //! ...
+ sal_Int32 nDecimals = 0; //! ...
+
+ switch ( eType )
+ {
+ case DataType::VARCHAR:
+ {
+ static const ::rtl::OUString s_sType(RTL_CONSTASCII_USTRINGPARAM("VARCHAR"));
+ aTypeName = s_sType;
+ }
+ break;
+ case DataType::DECIMAL:
+ aTypeName = ::rtl::OUString::createFromAscii("DECIMAL");
+ break;
+ case DataType::BIT:
+ aTypeName = ::rtl::OUString::createFromAscii("BOOL");
+ break;
+ case DataType::DATE:
+ aTypeName = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case DataType::TIME:
+ aTypeName = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ case DataType::TIMESTAMP:
+ aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ default:
+ OSL_ASSERT("missing type name");
+ aTypeName = ::rtl::OUString();
+ }
+
+ // check if the column name already exists
+ ::rtl::OUString aAlias = aColumnName;
+ OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ sal_Int32 nExprCnt = 0;
+ while(aFind != m_aColumns->get().end())
+ {
+ (aAlias = aColumnName) += ::rtl::OUString::valueOf((sal_Int32)++nExprCnt);
+ aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ }
+
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn( aAlias, aTypeName, ::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE, nPrecision, nDecimals,
+ eType, sal_False, sal_False, bCurrency,
+ bStoresMixedCaseQuotedIdentifiers);
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->get().push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nDecimals);
+ }
+}
+
+// -------------------------------------------------------------------------
+OCalcTable::OCalcTable(sdbcx::OCollection* _pTables,OCalcConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OCalcTable_BASE(_pTables,_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pConnection(_pConnection)
+ ,m_nStartCol(0)
+ ,m_nStartRow(0)
+ ,m_nDataCols(0)
+ ,m_nDataRows(0)
+ ,m_bHasHeaders(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::OCalcTable" );
+}
+// -----------------------------------------------------------------------------
+void OCalcTable::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::construct" );
+ // get sheet object
+ Reference< XSpreadsheetDocument> xDoc = m_pConnection->acquireDoc();
+ if (xDoc.is())
+ {
+ Reference<XSpreadsheets> xSheets = xDoc->getSheets();
+ if ( xSheets.is() && xSheets->hasByName( m_Name ) )
+ {
+ m_xSheet.set(xSheets->getByName( m_Name ),UNO_QUERY);
+ if ( m_xSheet.is() )
+ {
+ lcl_GetDataArea( m_xSheet, m_nDataCols, m_nDataRows );
+ m_bHasHeaders = sal_True;
+ // whole sheet is always assumed to include a header row
+ }
+ }
+ else // no sheet -> try database range
+ {
+ Reference<XPropertySet> xDocProp( xDoc, UNO_QUERY );
+ if ( xDocProp.is() )
+ {
+ Reference<XDatabaseRanges> xRanges(xDocProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DatabaseRanges")) ),UNO_QUERY);
+
+ if ( xRanges.is() && xRanges->hasByName( m_Name ) )
+ {
+ Reference<XDatabaseRange> xDBRange(xRanges->getByName( m_Name ),UNO_QUERY);
+ Reference<XCellRangeReferrer> xRefer( xDBRange, UNO_QUERY );
+ if ( xRefer.is() )
+ {
+ // Header flag is always stored with database range
+ // Get flag from FilterDescriptor
+
+ sal_Bool bRangeHeader = sal_True;
+ Reference<XPropertySet> xFiltProp( xDBRange->getFilterDescriptor(), UNO_QUERY );
+ if ( xFiltProp.is() )
+ xFiltProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ContainsHeader"))) >>= bRangeHeader;
+
+ Reference<XSheetCellRange> xSheetRange( xRefer->getReferredCells(), UNO_QUERY );
+ Reference<XCellRangeAddressable> xAddr( xSheetRange, UNO_QUERY );
+ if ( xSheetRange.is() && xAddr.is() )
+ {
+ m_xSheet = xSheetRange->getSpreadsheet();
+ CellRangeAddress aRangeAddr = xAddr->getRangeAddress();
+ m_nStartCol = aRangeAddr.StartColumn;
+ m_nStartRow = aRangeAddr.StartRow;
+ m_nDataCols = aRangeAddr.EndColumn - m_nStartCol + 1;
+ // m_nDataRows is excluding header row
+ m_nDataRows = aRangeAddr.EndRow - m_nStartRow;
+ if ( !bRangeHeader )
+ {
+ // m_nDataRows counts the whole range
+ m_nDataRows += 1;
+ }
+
+ m_bHasHeaders = bRangeHeader;
+ }
+ }
+ }
+ }
+ }
+
+ Reference<XNumberFormatsSupplier> xSupp( xDoc, UNO_QUERY );
+ if (xSupp.is())
+ m_xFormats = xSupp->getNumberFormats();
+
+ Reference<XPropertySet> xProp( xDoc, UNO_QUERY );
+ if (xProp.is())
+ {
+ ::com::sun::star::util::Date aDateStruct;
+ if ( xProp->getPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NullDate")) ) >>= aDateStruct )
+ m_aNullDate = ::Date( aDateStruct.Day, aDateStruct.Month, aDateStruct.Year );
+ }
+ }
+
+ //! default if no null date available?
+
+ fillColumns();
+
+ refreshColumns();
+}
+// -------------------------------------------------------------------------
+void OCalcTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::refreshColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+
+ OSQLColumns::Vector::const_iterator aEnd = m_aColumns->get().end();
+ for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != aEnd;++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OCalcColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OCalcTable::refreshIndexes()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::refreshIndexes" );
+ // Calc table has no index
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCalcTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::disposing" );
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aColumns = NULL;
+ if ( m_pConnection )
+ m_pConnection->releaseDoc();
+ m_pConnection = NULL;
+
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCalcTable::getTypes( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::getTypes" );
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!( *pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRename>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ aOwnTypes.push_back(*pBegin);
+ }
+ aOwnTypes.push_back(::getCppuType( (const Reference< ::com::sun::star::lang::XUnoTunnel > *)0 ));
+
+ const Type* pAttrs = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pAttrs, aOwnTypes.size());
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OCalcTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ const Any aRet = ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+ return aRet.hasValue() ? aRet : OTable_TYPEDEF::queryInterface(rType);
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OCalcTable::getUnoTunnelImplementationId()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::getUnoTunnelImplementationId" );
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OCalcTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OCalcTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Int32 OCalcTable::getCurrentLastPos() const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::getCurrentLastPos" );
+ return m_nDataRows;
+}
+//------------------------------------------------------------------
+sal_Bool OCalcTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::seekRow" );
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+
+ sal_uInt32 nNumberOfRecords = m_nDataRows;
+ sal_uInt32 nTempPos = m_nFilePos;
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ m_nFilePos++;
+ break;
+ case IResultSetHelper::PRIOR:
+ if (m_nFilePos > 0)
+ m_nFilePos--;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 1;
+ break;
+ case IResultSetHelper::LAST:
+ m_nFilePos = nNumberOfRecords;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L
+ : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset);
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = (sal_uInt32)nOffset;
+ break;
+ }
+
+ if (m_nFilePos > (sal_Int32)nNumberOfRecords)
+ m_nFilePos = (sal_Int32)nNumberOfRecords + 1;
+
+ if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1)
+ goto Error;
+ else
+ {
+ //! read buffer / setup row object etc?
+ }
+ goto End;
+
+Error:
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::PRIOR:
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ case IResultSetHelper::NEXT:
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::RELATIVE:
+ if (nOffset > 0)
+ m_nFilePos = nNumberOfRecords + 1;
+ else if (nOffset < 0)
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = nTempPos; // vorherige Position
+ }
+ // aStatus.Set(SDB_STAT_NO_DATA_FOUND);
+ return sal_False;
+
+End:
+ nCurPos = m_nFilePos;
+ return sal_True;
+}
+//------------------------------------------------------------------
+sal_Bool OCalcTable::fetchRow( OValueRefRow& _rRow, const OSQLColumns & _rCols,
+ sal_Bool _bUseTableDefs, sal_Bool bRetrieveData )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::fetchRow" );
+ // read the bookmark
+
+ BOOL bIsCurRecordDeleted = sal_False;
+ _rRow->setDeleted(bIsCurRecordDeleted);
+ *(_rRow->get())[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+
+ // fields
+
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end();
+ const OValueRefVector::Vector::size_type nCount = _rRow->get().size();
+ for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount;
+ ++aIter, i++)
+ {
+ if ( (_rRow->get())[i]->isBound() )
+ {
+ sal_Int32 nType = 0;
+ if ( _bUseTableDefs )
+ nType = m_aTypes[i-1];
+ else
+ (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+
+
+ lcl_SetValue( (_rRow->get())[i]->get(), m_xSheet, m_nStartCol, m_nStartRow, m_bHasHeaders,
+ m_aNullDate, m_nFilePos, i, nType );
+ }
+ }
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+void OCalcTable::FileClose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTable::FileClose" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OCalcTable_BASE::FileClose();
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CTables.cxx b/connectivity/source/drivers/calc/CTables.cxx
new file mode 100644
index 000000000000..64066b681728
--- /dev/null
+++ b/connectivity/source/drivers/calc/CTables.cxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CTables.hxx"
+#include "calc/CTable.hxx"
+#include "file/FCatalog.hxx"
+#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
+#include "file/FConnection.hxx"
+#endif
+#include "calc/CCatalog.hxx"
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::calc;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType OCalcTables::createObject(const ::rtl::OUString& _rName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "calc", "Ocke.Janssen@sun.com", "OCalcTables::createObject" );
+ OCalcTable* pTable = new OCalcTable(this,(OCalcConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+ sdbcx::ObjectType xRet = pTable;
+ pTable->construct();
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/calc/CalcDriver.xml b/connectivity/source/drivers/calc/CalcDriver.xml
new file mode 100644
index 000000000000..a8d5715f8e44
--- /dev/null
+++ b/connectivity/source/drivers/calc/CalcDriver.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Niklas Nebel</author>
+ <name>com.sun.star.sdbc.driver.calc.ODriver</name>
+ <description>This library implements the database driver for spreadsheet (Calc) file formats.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/calc/Cservices.cxx b/connectivity/source/drivers/calc/Cservices.cxx
new file mode 100644
index 000000000000..b172d9d4cf88
--- /dev/null
+++ b/connectivity/source/drivers/calc/Cservices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "calc/CDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::calc;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/calc/calc.xcu b/connectivity/source/drivers/calc/calc.xcu
new file mode 100755
index 000000000000..b7b494fdfa56
--- /dev/null
+++ b/connectivity/source/drivers/calc/calc.xcu
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:calc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.calc.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Spreadsheet</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FileSystemBased" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="MediaType" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>application/vnd.oasis.opendocument.spreadsheet</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/calc/exports.dxp b/connectivity/source/drivers/calc/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/calc/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/calc/makefile.mk b/connectivity/source/drivers/calc/makefile.mk
new file mode 100644
index 000000000000..8e193524aa45
--- /dev/null
+++ b/connectivity/source/drivers/calc/makefile.mk
@@ -0,0 +1,96 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=calc
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/CResultSet.obj \
+ $(SLO)$/CStatement.obj \
+ $(SLO)$/CPreparedStatement.obj \
+ $(SLO)$/CDatabaseMetaData.obj \
+ $(SLO)$/CCatalog.obj \
+ $(SLO)$/CColumns.obj \
+ $(SLO)$/CTable.obj \
+ $(SLO)$/CTables.obj \
+ $(SLO)$/CConnection.obj \
+ $(SLO)$/Cservices.obj \
+ $(SLO)$/CDriver.obj
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(COMPHELPERLIB)
+
+
+#.IF "$(DBFILELIB)" == ""
+#SHL1STDLIBS+= ifile.lib
+#.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/dbase/DCatalog.cxx b/connectivity/source/drivers/dbase/DCatalog.cxx
new file mode 100644
index 000000000000..0935e492ff02
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DCatalog.cxx
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "dbase/DCatalog.hxx"
+#include "dbase/DConnection.hxx"
+#include "dbase/DTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+using namespace connectivity::dbase;
+// -------------------------------------------------------------------------
+ODbaseCatalog::ODbaseCatalog(ODbaseConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+void ODbaseCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new ODbaseTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+
+
diff --git a/connectivity/source/drivers/dbase/DCode.cxx b/connectivity/source/drivers/dbase/DCode.cxx
new file mode 100644
index 000000000000..d292c7ab5291
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DCode.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DCode.hxx"
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include "dbase/DIndex.hxx"
+#include "dbase/DIndexIter.hxx"
+
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+
+TYPEINIT1(OFILEOperandAttr, OOperandAttr);
+// -----------------------------------------------------------------------------
+OOperandAttr* OFILEAnalyzer::createOperandAttr(sal_Int32 _nPos,
+ const Reference< XPropertySet>& _xCol,
+ const Reference< XNameAccess>& _xIndexes)
+{
+ return new OFILEOperandAttr((sal_uInt16)_nPos,_xCol,_xIndexes);
+}
+
+//------------------------------------------------------------------
+OFILEOperandAttr::OFILEOperandAttr(sal_uInt16 _nPos,
+ const Reference< XPropertySet>& _xColumn,
+ const Reference< XNameAccess>& _xIndexes)
+ : OOperandAttr(_nPos,_xColumn)
+{
+ if(_xIndexes.is())
+ {
+ ::rtl::OUString sName;
+ Reference<XPropertySetInfo> xColInfo = _xColumn->getPropertySetInfo();
+ Reference<XPropertySet> xIndex;
+
+ Sequence< ::rtl::OUString> aSeq = _xIndexes->getElementNames();
+ const ::rtl::OUString* pBegin = aSeq.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aSeq.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ _xIndexes->getByName(*pBegin) >>= xIndex;
+ if(xIndex.is())
+ {
+ Reference<XColumnsSupplier> xColsSup(xIndex,UNO_QUERY);
+ Reference<XNameAccess> xNameAccess = xColsSup->getColumns();
+ _xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sName;
+ if(xNameAccess->hasByName(sName))
+ {
+ m_xIndex = xIndex;
+ break;
+ }
+ else if(xColInfo->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)))
+ {
+ _xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME)) >>= sName;
+ if(xNameAccess->hasByName(sName))
+ {
+ m_xIndex = xIndex;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+}
+// -------------------------------------------------------------------------
+sal_Bool OFILEOperandAttr::isIndexed() const
+{
+ return m_xIndex.is();
+}
+//------------------------------------------------------------------
+OEvaluateSet* OFILEOperandAttr::preProcess(OBoolOperator* pOp, OOperand* pRight)
+{
+ OEvaluateSet* pEvaluateSet = NULL;
+ if (isIndexed())
+ {
+ Reference<XUnoTunnel> xTunnel(m_xIndex,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ if(pIndex)
+ {
+ OIndexIterator* pIter = pIndex->createIterator(pOp,pRight);
+
+ if (pIter)
+ {
+ pEvaluateSet = new OEvaluateSet();
+ ULONG nRec = pIter->First();
+ while (nRec != NODE_NOTFOUND)
+ {
+ (*pEvaluateSet)[nRec] = nRec;
+ nRec = pIter->Next();
+ }
+ }
+ delete pIter;
+ }
+ }
+ }
+ return pEvaluateSet;
+}
+
+
diff --git a/connectivity/source/drivers/dbase/DColumns.cxx b/connectivity/source/drivers/dbase/DColumns.cxx
new file mode 100644
index 000000000000..2f6eee5aba98
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DColumns.cxx
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DColumns.hxx"
+#include "dbase/DTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
+#include <comphelper/property.hxx>
+
+using namespace connectivity::dbase;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+typedef file::OColumns ODbaseColumns_BASE;
+sdbcx::ObjectType ODbaseColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ ODbaseTable* pTable = (ODbaseTable*)m_pTable;
+
+ // Reference< XFastPropertySet> xCol(pTable->getColumns()[_rName],UNO_QUERY);
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+
+ sdbcx::ObjectType xRet;
+ if(aIter != aCols->get().end())
+ xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void ODbaseColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > ODbaseColumns::createDescriptor()
+{
+ return new sdbcx::OColumn(isCaseSensitive());
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType ODbaseColumns::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ if ( m_pTable->isNew() )
+ return cloneDescriptor( descriptor );
+
+ m_pTable->addColumn( descriptor );
+ return createObject( _rForName );
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+// XDrop
+void ODbaseColumns::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
+{
+ if(!m_pTable->isNew())
+ m_pTable->dropColumn(_nPos);
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/dbase/DConnection.cxx b/connectivity/source/drivers/dbase/DConnection.cxx
new file mode 100644
index 000000000000..530df50e1674
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DConnection.cxx
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_DBASE_OCONNECTION_HXX_
+#include "dbase/DConnection.hxx"
+#endif
+#include "dbase/DDatabaseMetaData.hxx"
+#include "dbase/DCatalog.hxx"
+#ifndef _CONNECTIVITY_DBASE_ODRIVER_HXX_
+#include "dbase/DDriver.hxx"
+#endif
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <tools/urlobj.hxx>
+#include "dbase/DPreparedStatement.hxx"
+#include "dbase/DStatement.hxx"
+#include <tools/debug.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+
+typedef connectivity::file::OConnection OConnection_BASE;
+
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+DBG_NAME(ODbaseConnection)
+// --------------------------------------------------------------------------------
+ODbaseConnection::ODbaseConnection(ODriver* _pDriver) : OConnection(_pDriver)
+{
+ DBG_CTOR(ODbaseConnection,NULL);
+ m_aFilenameExtension = String::CreateFromAscii("dbf");
+}
+//-----------------------------------------------------------------------------
+ODbaseConnection::~ODbaseConnection()
+{
+ DBG_DTOR(ODbaseConnection,NULL);
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(ODbaseConnection, "com.sun.star.sdbc.drivers.dbase.Connection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL ODbaseConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODbaseDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XTablesSupplier > ODbaseConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ ODbaseCatalog *pCat = new ODbaseCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL ODbaseConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XStatement > xReturn = new ODbaseStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ ODbasePreparedStatement* pStmt = new ODbasePreparedStatement(this);
+ Reference< XPreparedStatement > xHoldAlive = pStmt;
+ pStmt->construct(sql);
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL ODbaseConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx
new file mode 100644
index 000000000000..1e9b565cc4d7
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DDatabaseMetaData.cxx
@@ -0,0 +1,416 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#ifndef _CONNECTIVITY_DBASE_ODbaseDatabaseMetaData_HXX_
+#include "dbase/DDatabaseMetaData.hxx"
+#endif
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <tools/urlobj.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include "dbase/DIndex.hxx"
+#include "connectivity/FValue.hxx"
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <ucbhelper/content.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity::dbase;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::lang;
+
+ODbaseDatabaseMetaData::ODbaseDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::ODbaseDatabaseMetaData" );
+}
+// -------------------------------------------------------------------------
+ODbaseDatabaseMetaData::~ODbaseDatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODbaseDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_getTypeInfo_throw" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.reserve(18);
+
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)254));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length")));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("C"))));
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)2147483647);
+ aRow[6] = new ORowSetValueDecorator();
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("M")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DATE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)10);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOLEAN"));
+ aRow[2] = new ORowSetValueDecorator(DataType::BIT);
+ aRow[3] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[4] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString());
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("L")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)8);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("B")));
+ aRows.push_back(aRow);
+
+ aRow[11] = new ORowSetValueDecorator(sal_True);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("Y"));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[11] = new ORowSetValueDecorator(sal_False);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("T")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER"));
+ aRow[2] = new ORowSetValueDecorator(DataType::INTEGER);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)10);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("I")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("length,scale"));
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("F")));
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)16);
+ aRow[13] = new ORowSetValueDecorator(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("N")));
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)16);
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabBegin = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength();
+ for(;pTabBegin != pTabEnd;++pTabBegin)
+ {
+ if(match(tableNamePattern,*pTabBegin,'\0'))
+ {
+ Reference< XColumnsSupplier> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin));
+ OSL_ENSURE(xTable.is(),"Table not found! Normallya exception had to be thrown here!");
+ aRow[3] = new ORowSetValueDecorator(*pTabBegin);
+
+ Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i)
+ {
+ if(match(columnNamePattern,*pBegin,'\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(*pBegin);
+
+ ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin));
+ OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+ aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
+ aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
+ aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
+ aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
+ switch((sal_Int32)aRow[5]->getValue())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
+ break;
+ default:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
+ }
+ aRow[17] = new ORowSetValueDecorator(i);
+ switch(sal_Int32(aRow[11]->getValue()))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+ break;
+ default:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString());
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODbaseDatabaseMetaData::getIndexInfo(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schema*/, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool /*approximate*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getIndexInfo" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(14);
+
+ aRow[5] = new ORowSetValueDecorator(::rtl::OUString());
+ aRow[10] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("A"));
+
+ Reference< XIndexesSupplier> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(table));
+ aRow[3] = new ORowSetValueDecorator(table);
+ aRow[7] = new ORowSetValueDecorator((sal_Int32)3);
+
+ Reference< XNameAccess> xIndexes = xTable->getIndexes();
+ if(!xIndexes.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aIdxNames(xIndexes->getElementNames());
+
+ const ::rtl::OUString* pBegin = aIdxNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aIdxNames.getLength();
+ Reference< XPropertySet> xIndex;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ ::cppu::extractInterface(xIndex,xIndexes->getByName(*pBegin));
+ OSL_ENSURE(xIndex.is(),"Indexes contains a column who isn't a fastpropertyset!");
+
+ if(unique && !getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ continue;
+ aRow[4] = new ORowSetValueDecorator(getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))));
+ aRow[6] = new ORowSetValueDecorator(*pBegin);
+
+ Reference< XUnoTunnel> xTunnel(xIndex,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ if(pIndex)
+ {
+ aRow[11] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_maxkeys);
+ aRow[12] = new ORowSetValueDecorator((sal_Int32)pIndex->getHeader().db_pagecount);
+ }
+ }
+
+ Reference<XColumnsSupplier> xColumnsSup(xIndex,UNO_QUERY);
+ Reference< XNameAccess> xColumns = xColumnsSup->getColumns();
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pColBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pColEnd = pColBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 j=1;pColBegin != pColEnd;++pColBegin,++j)
+ {
+ // xColumns->getByName(*pColBegin) >>= xColumn;
+ aRow[8] = new ORowSetValueDecorator(j);
+ aRow[9] = new ORowSetValueDecorator(*pColBegin);
+ aRows.push_back(aRow);
+ }
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODbaseDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getURL" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:dbase:")) + m_pConnection->getURL();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxBinaryLiteralLength" );
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxCharLiteralLength" );
+ return 254;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnNameLength" );
+ return 10;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnsInIndex" );
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::getMaxColumnsInTable" );
+ return 128;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::supportsAlterTableWithAddColumn" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::supportsAlterTableWithDropColumn" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::isReadOnly" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ sal_Bool bReadOnly = sal_False;
+ static ::rtl::OUString sReadOnly = ::rtl::OUString::createFromAscii("IsReadOnly");
+ ::ucbhelper::Content aFile(m_pConnection->getContent(),Reference< XCommandEnvironment >());
+ aFile.getPropertyValue(sReadOnly) >>= bReadOnly;
+
+ return bReadOnly;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODbaseDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw" );
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool ODbaseDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw" );
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/DDriver.cxx b/connectivity/source/drivers/dbase/DDriver.cxx
new file mode 100644
index 000000000000..7281ac4036c2
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DDriver.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DDriver.hxx"
+#include "dbase/DConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "resource/dbase_res.hrc"
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.dbase.ODriver");
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::dbase::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ ODbaseConnection* pCon = new ODbaseConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
+{
+ return !url.compareTo(::rtl::OUString::createFromAscii("sdbc:dbase:"),11);
+}
+// -----------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBoolean(2);
+ aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
+ aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Display inactive records."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EnableSQL92Check"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Use SQL92 naming constraints."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
+ }
+
+ SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/DIndex.cxx b/connectivity/source/drivers/dbase/DIndex.cxx
new file mode 100644
index 000000000000..c7e64beeef1a
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DIndex.cxx
@@ -0,0 +1,679 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DIndex.hxx"
+#include "dbase/DIndexColumns.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <comphelper/sequence.hxx>
+#include "dbase/DTable.hxx"
+#include "dbase/DIndexIter.hxx"
+#include <tools/config.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <comphelper/extract.hxx>
+#include <unotools/localfilehelper.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "dbase/DResultSet.hxx"
+#include "diagnose_ex.h"
+#include <comphelper/types.hxx>
+#include "resource/dbase_res.hrc"
+#include <unotools/sharedunocomponent.hxx>
+
+using namespace ::comphelper;
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace utl;
+using namespace ::cppu;
+using namespace connectivity::file;
+using namespace connectivity::sdbcx;
+using namespace connectivity::dbase;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::lang;
+
+IMPLEMENT_SERVICE_INFO(ODbaseIndex,"com.sun.star.sdbcx.driver.dbase.Index","com.sun.star.sdbcx.Index");
+// -------------------------------------------------------------------------
+ODbaseIndex::ODbaseIndex(ODbaseTable* _pTable) : OIndex(sal_True/*_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()*/)
+ ,m_pFileStream(NULL)
+ ,m_nCurNode(NODE_NOTFOUND)
+ ,m_pTable(_pTable)
+{
+ m_aHeader.db_pagecount = m_aHeader.db_rootpage = m_aHeader.db_keytype = m_aHeader.db_maxkeys = m_aHeader.db_keylen = 0;
+ m_aHeader.db_name[0] = '\0';
+ construct();
+}
+// -------------------------------------------------------------------------
+ODbaseIndex::ODbaseIndex( ODbaseTable* _pTable,
+ const NDXHeader& _rHeader,
+ const ::rtl::OUString& _rName)
+ :OIndex(_rName,::rtl::OUString(),_rHeader.db_unique,sal_False,sal_False,sal_True) // _pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers()
+ ,m_pFileStream(NULL)
+ ,m_aHeader(_rHeader)
+ ,m_nCurNode(NODE_NOTFOUND)
+ ,m_pTable(_pTable)
+{
+ construct();
+}
+// -----------------------------------------------------------------------------
+ODbaseIndex::~ODbaseIndex()
+{
+ closeImpl();
+}
+// -------------------------------------------------------------------------
+void ODbaseIndex::refreshColumns()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+ if(!isNew())
+ {
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ OSL_ENSURE(m_aHeader.db_name[0] != '\0',"Invalid name for the column!");
+ aVector.push_back(::rtl::OUString::createFromAscii(m_aHeader.db_name));
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new ODbaseIndexColumns(this,m_aMutex,aVector);
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODbaseIndex::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 ODbaseIndex::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : ODbaseIndex_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+ONDXPagePtr ODbaseIndex::getRoot()
+{
+ openIndexFile();
+ if (!m_aRoot.Is())
+ {
+ m_nRootPage = m_aHeader.db_rootpage;
+ m_nPageCount = m_aHeader.db_pagecount;
+ m_aRoot = CreatePage(m_nRootPage,NULL,TRUE);
+ }
+ return m_aRoot;
+}
+//------------------------------------------------------------------
+sal_Bool ODbaseIndex::openIndexFile()
+{
+ if(!m_pFileStream)
+ {
+ ::rtl::OUString sFile = getCompletePath();
+ if(UCBContentHelper::Exists(sFile))
+ {
+ m_pFileStream = OFileTable::createStream_simpleError(sFile, STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+ if (!m_pFileStream)
+ m_pFileStream = OFileTable::createStream_simpleError(sFile,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+ if(m_pFileStream)
+ {
+ m_pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ m_pFileStream->SetBufferSize(PAGE_SIZE);
+ (*m_pFileStream) >> *this;
+ }
+ }
+ if(!m_pFileStream)
+ {
+ const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_FILE,
+ "$filename$", sFile
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ }
+
+ return m_pFileStream != NULL;
+}
+//------------------------------------------------------------------
+OIndexIterator* ODbaseIndex::createIterator(OBoolOperator* pOp,
+ const OOperand* pOperand)
+{
+ openIndexFile();
+ return new OIndexIterator(this, pOp, pOperand);
+}
+//------------------------------------------------------------------
+BOOL ODbaseIndex::ConvertToKey(ONDXKey* rKey, sal_uInt32 nRec, const ORowSetValue& rValue)
+{
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ // Sucht ein bestimmten Wert im Index
+ // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja
+ try
+ {
+ if (m_aHeader.db_keytype == 0)
+ {
+ *rKey = ONDXKey(rValue.getString(), nRec );
+ }
+ else
+ {
+ if (rValue.isNull())
+ *rKey = ONDXKey(rValue.getDouble(), DataType::DOUBLE, nRec );
+ else
+ *rKey = ONDXKey(rValue.getDouble(), nRec );
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_ASSERT(0);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseIndex::Find(sal_uInt32 nRec, const ORowSetValue& rValue)
+{
+ openIndexFile();
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ // Sucht ein bestimmten Wert im Index
+ // Wenn der Index Unique ist, interssiert der Key nicht, sonst ja
+ ONDXKey aKey;
+ return ConvertToKey(&aKey, nRec, rValue) && getRoot()->Find(aKey);
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseIndex::Insert(sal_uInt32 nRec, const ORowSetValue& rValue)
+{
+ openIndexFile();
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ ONDXKey aKey;
+
+ // Existiert der Wert bereits
+ // Find immer verwenden um das aktuelle Blatt zu bestimmen
+ if (!ConvertToKey(&aKey, nRec, rValue) || (getRoot()->Find(aKey) && isUnique()))
+ return FALSE;
+
+ ONDXNode aNewNode(aKey);
+
+ // einfuegen in das aktuelle Blatt
+ if (!m_aCurLeaf.Is())
+ return FALSE;
+
+ BOOL bResult = m_aCurLeaf->Insert(aNewNode);
+ Release(bResult);
+
+ return bResult;
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseIndex::Update(sal_uInt32 nRec, const ORowSetValue& rOldValue,
+ const ORowSetValue& rNewValue)
+{
+ openIndexFile();
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ ONDXKey aKey;
+ if (!ConvertToKey(&aKey, nRec, rNewValue) || (isUnique() && getRoot()->Find(aKey)))
+ return FALSE;
+ else
+ return Delete(nRec, rOldValue) && Insert(nRec,rNewValue);
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseIndex::Delete(sal_uInt32 nRec, const ORowSetValue& rValue)
+{
+ openIndexFile();
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+ // Existiert der Wert bereits
+ // Find immer verwenden um das aktuelle Blatt zu bestimmen
+ ONDXKey aKey;
+ if (!ConvertToKey(&aKey, nRec, rValue) || !getRoot()->Find(aKey))
+ return FALSE;
+
+ ONDXNode aNewNode(aKey);
+
+ // einfuegen in das aktuelle Blatt
+ if (!m_aCurLeaf.Is())
+ return FALSE;
+#if OSL_DEBUG_LEVEL > 1
+ m_aRoot->PrintPage();
+#endif
+
+ return m_aCurLeaf->Delete(m_nCurNode);
+}
+//------------------------------------------------------------------
+void ODbaseIndex::Collect(ONDXPage* pPage)
+{
+ if (pPage)
+ m_aCollector.push_back(pPage);
+}
+//------------------------------------------------------------------
+void ODbaseIndex::Release(BOOL bSave)
+{
+ // Freigeben der Indexressourcen
+ m_bUseCollector = FALSE;
+
+ if (m_aCurLeaf.Is())
+ {
+ m_aCurLeaf->Release(bSave);
+ m_aCurLeaf.Clear();
+ }
+
+ // Wurzel freigeben
+ if (m_aRoot.Is())
+ {
+ m_aRoot->Release(bSave);
+ m_aRoot.Clear();
+ }
+ // alle Referenzen freigeben, bevor der FileStream geschlossen wird
+ for (ULONG i = 0; i < m_aCollector.size(); i++)
+ m_aCollector[i]->QueryDelete();
+
+ m_aCollector.clear();
+
+ // Header modifiziert ?
+ if (bSave && (m_aHeader.db_rootpage != m_nRootPage ||
+ m_aHeader.db_pagecount != m_nPageCount))
+ {
+ m_aHeader.db_rootpage = m_nRootPage;
+ m_aHeader.db_pagecount = m_nPageCount;
+ (*m_pFileStream) << *this;
+ }
+ m_nRootPage = m_nPageCount = 0;
+ m_nCurNode = NODE_NOTFOUND;
+
+ closeImpl();
+}
+// -----------------------------------------------------------------------------
+void ODbaseIndex::closeImpl()
+{
+ if(m_pFileStream)
+ {
+ delete m_pFileStream;
+ m_pFileStream = NULL;
+ }
+}
+//------------------------------------------------------------------
+ONDXPage* ODbaseIndex::CreatePage(sal_uInt32 nPagePos, ONDXPage* pParent, BOOL bLoad)
+{
+ OSL_ENSURE(m_pFileStream,"FileStream is not opened!");
+
+ ONDXPage* pPage;
+ if ( !m_aCollector.empty() )
+ {
+ pPage = *(m_aCollector.rbegin());
+ m_aCollector.pop_back();
+ pPage->SetPagePos(nPagePos);
+ pPage->SetParent(pParent);
+ }
+ else
+ pPage = new ONDXPage(*this, nPagePos, pParent);
+
+ if (bLoad)
+ (*m_pFileStream) >> *pPage;
+
+ return pPage;
+}
+
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator >> (SvStream &rStream, ODbaseIndex& rIndex)
+{
+ rStream.Seek(0);
+ rStream.Read(&rIndex.m_aHeader,PAGE_SIZE);
+
+/* OJ: no longer needed
+ // Text convertierung
+ ByteString aText(rIndex.m_aHeader.db_name);
+ // aText.Convert(rIndex.m_pTable->getConnection()->GetCharacterSet(), m_pTable->getConnection()->getTextEncoding());
+ // aText.Convert(rIndex.m_pTable->getConnection()->GetCharacterSet(), m_pTable->getConnection()->getTextEncoding());
+ strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer());
+*/
+ rIndex.m_nRootPage = rIndex.m_aHeader.db_rootpage;
+ rIndex.m_nPageCount = rIndex.m_aHeader.db_pagecount;
+ return rStream;
+}
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator << (SvStream &rStream, ODbaseIndex& rIndex)
+{
+ rStream.Seek(0);
+/* OJ: no longer needed
+ ByteString aText(rIndex.m_aHeader.db_name);
+ // aText.Convert(m_pTable->getConnection()->getTextEncoding(), rIndex.m_pTable->getConnection()->GetCharacterSet());
+ strcpy(rIndex.m_aHeader.db_name,aText.GetBuffer());
+*/
+ OSL_VERIFY_EQUALS( rStream.Write(&rIndex.m_aHeader,PAGE_SIZE), PAGE_SIZE, "Write not successful: Wrong header size for dbase index!");
+ return rStream;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODbaseIndex::getCompletePath()
+{
+ ::rtl::OUString sDir = m_pTable->getConnection()->getURL();
+ sDir += OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER);
+ sDir += m_Name;
+ sDir += ::rtl::OUString::createFromAscii(".ndx");
+ return sDir;
+}
+//------------------------------------------------------------------
+void ODbaseIndex::createINFEntry()
+{
+ // inf Datei abgleichen
+ String sEntry = m_Name;
+ sEntry += String::CreateFromAscii(".ndx");
+
+ ::rtl::OUString sCfgFile(m_pTable->getConnection()->getURL());
+ sCfgFile += OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER);
+ sCfgFile += m_pTable->getName();
+ sCfgFile += ::rtl::OUString::createFromAscii(".inf");
+
+ String sPhysicalPath;
+ LocalFileHelper::ConvertURLToPhysicalName(sCfgFile,sPhysicalPath);
+
+ Config aInfFile(sPhysicalPath);
+ aInfFile.SetGroup(dBASE_III_GROUP);
+
+ USHORT nSuffix = aInfFile.GetKeyCount();
+ ByteString aNewEntry,aKeyName;
+ BOOL bCase = isCaseSensitive();
+ while (!aNewEntry.Len())
+ {
+ aNewEntry = "NDX";
+ aNewEntry += ByteString::CreateFromInt32(++nSuffix);
+ for (USHORT i = 0; i < aInfFile.GetKeyCount(); i++)
+ {
+ aKeyName = aInfFile.GetKeyName(i);
+ if (bCase ? aKeyName == aNewEntry : aKeyName.EqualsIgnoreCaseAscii(aNewEntry))
+ {
+ aNewEntry.Erase();
+ break;
+ }
+ }
+ }
+ aInfFile.WriteKey(aNewEntry,ByteString(sEntry,m_pTable->getConnection()->getTextEncoding()));
+}
+// -------------------------------------------------------------------------
+BOOL ODbaseIndex::DropImpl()
+{
+ closeImpl();
+
+ ::rtl::OUString sPath = getCompletePath();
+ if(UCBContentHelper::Exists(sPath))
+ {
+ if(!UCBContentHelper::Kill(sPath))
+ m_pTable->getConnection()->throwGenericSQLException(STR_COULD_NOT_DELETE_INDEX,*m_pTable);
+ }
+
+ // InfDatei abgleichen
+
+ ::rtl::OUString sCfgFile(m_pTable->getConnection()->getURL());
+ sCfgFile += OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER);
+ sCfgFile += m_pTable->getName();
+ sCfgFile += ::rtl::OUString::createFromAscii(".inf");
+
+ String sPhysicalPath;
+ String sNDX(sCfgFile);
+ OSL_VERIFY_RES( LocalFileHelper::ConvertURLToPhysicalName(sNDX,sPhysicalPath),"Can not convert Config Filename into Physical Name!");
+
+ Config aInfFile(sPhysicalPath);
+ aInfFile.SetGroup(dBASE_III_GROUP);
+ USHORT nKeyCnt = aInfFile.GetKeyCount();
+ ByteString aKeyName;
+ String sEntry = m_Name;
+ sEntry += String::CreateFromAscii(".ndx");
+
+ // delete entries from the inf file
+ for (USHORT nKey = 0; nKey < nKeyCnt; nKey++)
+ {
+ // Verweist der Key auf ein Indexfile?...
+ aKeyName = aInfFile.GetKeyName( nKey );
+ if (aKeyName.Copy(0,3) == "NDX")
+ {
+ if(sEntry == String(aInfFile.ReadKey(aKeyName),m_pTable->getConnection()->getTextEncoding()))
+ {
+ aInfFile.DeleteKey(aKeyName);
+ break;
+ }
+ }
+ }
+ return TRUE;
+}
+// -------------------------------------------------------------------------
+void ODbaseIndex::impl_killFileAndthrowError_throw(sal_uInt16 _nErrorId,const ::rtl::OUString& _sFile)
+{
+ closeImpl();
+ if(UCBContentHelper::Exists(_sFile))
+ UCBContentHelper::Kill(_sFile);
+ m_pTable->getConnection()->throwGenericSQLException(_nErrorId,*this);
+}
+//------------------------------------------------------------------
+BOOL ODbaseIndex::CreateImpl()
+{
+ // Anlegen des Index
+ const ::rtl::OUString sFile = getCompletePath();
+ if(UCBContentHelper::Exists(sFile))
+ {
+ const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_CREATE_INDEX_NAME,
+ "$filename$", sFile
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ // Index ist nur einstufig
+ if (m_pColumns->getCount() > 1)
+ m_pTable->getConnection()->throwGenericSQLException(STR_ONL_ONE_COLUMN_PER_INDEX,*this);
+
+ Reference<XFastPropertySet> xCol(m_pColumns->getByIndex(0),UNO_QUERY);
+
+ // ist die Spalte schon indiziert ?
+ if ( !xCol.is() )
+ ::dbtools::throwFunctionSequenceException(*this);
+// else if (pColumn && pColumn->IsIndexed())
+// {
+// String aText = String(OResId(STR_STAT_INDEX_COLUMN_ALREADY_INDEXED));
+// aText.SearchAndReplace(String::CreateFromAscii("#"),pColumn->GetName());
+// aStatus.Set(SDB_STAT_ERROR,
+// String::CreateFromAscii("01000"),
+// aStatus.CreateErrorMessage(aText),
+// 0, String() );
+// return FALSE;
+// }
+
+ // create the index file
+ m_pFileStream = OFileTable::createStream_simpleError(sFile,STREAM_READWRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC);
+ if (!m_pFileStream)
+ {
+ const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_FILE,
+ "$filename$", sFile
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+
+ m_pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ m_pFileStream->SetBufferSize(PAGE_SIZE);
+ m_pFileStream->SetFiller('\0');
+
+ // Zunaechst muss das Ergebnis sortiert sein
+ utl::SharedUNOComponent<XStatement> xStmt;
+ utl::SharedUNOComponent<XResultSet> xSet;
+ String aName;
+ try
+ {
+ xStmt.set( m_pTable->getConnection()->createStatement(), UNO_SET_THROW);
+
+ aName = getString(xCol->getFastPropertyValue(PROPERTY_ID_NAME));
+
+ const String aQuote(m_pTable->getConnection()->getMetaData()->getIdentifierQuoteString());
+ String aStatement;
+ aStatement.AssignAscii("SELECT ");
+ aStatement += aQuote;
+ aStatement += aName;
+ aStatement += aQuote;
+ aStatement.AppendAscii(" FROM ");
+ aStatement += aQuote;
+ aStatement += m_pTable->getName().getStr();
+ aStatement += aQuote;
+ aStatement.AppendAscii(" ORDER BY ");
+ aStatement += aQuote;
+ aStatement += aName;
+ aStatement += aQuote;
+
+// if (!m_IsUnique) // zusaetzlich sortierung mit der bookmarkspalte
+// {
+// aStatement.AppendAscii(" ,");
+// aStatement += aQuote;
+// aStatement.AppendAscii("[BOOKMARK]"); // this is a special column
+// aStatement += aQuote;
+// }
+
+ xSet.set( xStmt->executeQuery(aStatement),UNO_SET_THROW );
+ }
+ catch(const Exception& )
+ {
+ impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX,sFile);
+ }
+ if (!xSet.is())
+ {
+ impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX,sFile);
+ }
+
+ // Setzen der Headerinfo
+ memset(&m_aHeader,0,sizeof(m_aHeader));
+ sal_Int32 nType = 0;
+ ::vos::ORef<OSQLColumns> aCols = m_pTable->getTableColumns();
+ const Reference< XPropertySet > xTableCol(*find(aCols->get().begin(),aCols->get().end(),aName,::comphelper::UStringMixEqual(isCaseSensitive())));
+
+ xTableCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+
+ m_aHeader.db_keytype = (nType == DataType::VARCHAR || nType == DataType::CHAR) ? 0 : 1;
+ m_aHeader.db_keylen = (m_aHeader.db_keytype) ? 8 : (USHORT)getINT32(xTableCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+ m_aHeader.db_keylen = (( m_aHeader.db_keylen - 1) / 4 + 1) * 4;
+ m_aHeader.db_maxkeys = (PAGE_SIZE - 4) / (8 + m_aHeader.db_keylen);
+ if ( m_aHeader.db_maxkeys < 3 )
+ {
+ impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX_KEYSIZE,sFile);
+ }
+
+ m_pFileStream->SetStreamSize(PAGE_SIZE);
+
+ ByteString aCol(aName,m_pTable->getConnection()->getTextEncoding());
+ strncpy(m_aHeader.db_name,aCol.GetBuffer(),std::min((USHORT)sizeof(m_aHeader.db_name), aCol.Len()));
+ m_aHeader.db_unique = m_IsUnique ? 1: 0;
+ m_aHeader.db_keyrec = m_aHeader.db_keylen + 8;
+
+ // modifizierung am Header werden ueber Unterschiede zw. HeaderInfo und nRootPage
+ // bzw. nPageCout erkannt
+
+ m_nRootPage = 1;
+ m_nPageCount = 2;
+
+ // ODatabaseType eType = m_aHeader.db_keytype == 0 ? DataType::VARCHAR : DataType::DOUBLE;
+ m_aCurLeaf = m_aRoot = CreatePage(m_nRootPage);
+ m_aRoot->SetModified(TRUE);
+
+ m_bUseCollector = TRUE;
+
+ // ULONG nRowsLeft = pCursor->RowCount();
+ sal_Int32 nRowsLeft = 0;
+ Reference<XRow> xRow(xSet,UNO_QUERY);
+
+ if(xSet->last())
+ {
+ Reference< XUnoTunnel> xTunnel(xSet,UNO_QUERY);
+ ODbaseResultSet* pDbaseRes = NULL;
+ if(xTunnel.is())
+ pDbaseRes = reinterpret_cast< ODbaseResultSet* >( xTunnel->getSomething(ODbaseResultSet::getUnoTunnelImplementationId()) );
+ OSL_ENSURE(pDbaseRes,"No dbase resultset found? What's going on here!");
+ Reference<XRowLocate> xRowLocate(xSet,UNO_QUERY);
+ nRowsLeft = xSet->getRow();
+
+ xSet->beforeFirst();
+ ORowSetValue atmpValue=ORowSetValue();
+ ONDXKey aKey(atmpValue, nType, 0);
+ ONDXKey aInsertKey(atmpValue, nType, 0);
+ // Erzeugen der Indexstruktur
+ while (xSet->next())
+ {
+ // ODbRow& rRow = *pCursor->GetRow();
+ ORowSetValue aValue(m_aHeader.db_keytype ? ORowSetValue(xRow->getDouble(1)) : ORowSetValue(xRow->getString(1)));
+ // ueberpruefen auf doppelten eintrag
+ if (m_IsUnique && m_nCurNode != NODE_NOTFOUND)
+ {
+ aKey.setValue(aValue);
+ if (aKey == (*m_aCurLeaf)[m_nCurNode].GetKey())
+ {
+ impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX_NOT_UNIQUE,sFile);
+ }
+ }
+ aInsertKey.setValue(aValue);
+ aInsertKey.setRecord(pDbaseRes->getCurrentFilePos());
+
+ ONDXNode aNewNode(aInsertKey);
+ if (!m_aCurLeaf->Insert(aNewNode, --nRowsLeft))
+ break;
+ }
+ }
+
+ if(nRowsLeft)
+ {
+ impl_killFileAndthrowError_throw(STR_COULD_NOT_CREATE_INDEX,sFile);
+ }
+ Release();
+ createINFEntry();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void SAL_CALL ODbaseIndex::acquire() throw()
+{
+ ODbaseIndex_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODbaseIndex::release() throw()
+{
+ ODbaseIndex_BASE::release();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/dbase/DIndexColumns.cxx b/connectivity/source/drivers/dbase/DIndexColumns.cxx
new file mode 100644
index 000000000000..59682a38d8af
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DIndexColumns.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DIndexColumns.hxx"
+#include "dbase/DTable.hxx"
+#include "connectivity/sdbcx/VIndexColumn.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/property.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity::dbase;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+sdbcx::ObjectType ODbaseIndexColumns::createObject(const ::rtl::OUString& _rName)
+{
+ const ODbaseTable* pTable = m_pIndex->getTable();
+
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+
+ Reference< XPropertySet > xCol;
+ if(aIter != aCols->get().end())
+ xCol = *aIter;
+
+ if(!xCol.is())
+ return sdbcx::ObjectType();
+
+ sdbcx::ObjectType xRet = new sdbcx::OIndexColumn(sal_True,_rName
+ ,getString(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)))
+ ,::rtl::OUString()
+ ,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)))
+ ,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)))
+ ,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)))
+ ,getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)))
+ ,sal_False
+ ,sal_False
+ ,sal_False
+ ,pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void ODbaseIndexColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pIndex->refreshColumns();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > ODbaseIndexColumns::createDescriptor()
+{
+ return new sdbcx::OIndexColumn(m_pIndex->getTable()->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+}
+// -------------------------------------------------------------------------
+sdbcx::ObjectType ODbaseIndexColumns::appendObject( const ::rtl::OUString& /*_rForName*/, const Reference< XPropertySet >& descriptor )
+{
+ return cloneDescriptor( descriptor );
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/DIndexIter.cxx b/connectivity/source/drivers/dbase/DIndexIter.cxx
new file mode 100644
index 000000000000..f32b1f2cffe0
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DIndexIter.cxx
@@ -0,0 +1,315 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DIndexIter.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+
+using namespace ::com::sun::star::sdb;
+using namespace connectivity;
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::com::sun::star::sdb;
+//==================================================================
+// OIndexIterator
+//==================================================================
+//------------------------------------------------------------------
+OIndexIterator::~OIndexIterator()
+{
+ // m_pIndex->UnLock();
+ m_pIndex->release();
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::First()
+{
+ return Find(TRUE);
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::Next()
+{
+ return Find(FALSE);
+}
+//------------------------------------------------------------------
+ULONG OIndexIterator::Find(BOOL bFirst)
+{
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+
+ ULONG nRes = STRING_NOTFOUND;
+// if (!m_pIndex->IsOpen())
+// return nRes;
+
+ if (bFirst)
+ {
+ m_aRoot = m_pIndex->getRoot();
+ m_aCurLeaf = NULL;
+ }
+
+ if (!m_pOperator)
+ {
+ // Vorbereitung , auf kleinstes Element positionieren
+ if (bFirst)
+ {
+ ONDXPage* pPage = m_aRoot;
+ while (pPage && !pPage->IsLeaf())
+ pPage = pPage->GetChild(m_pIndex);
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = NODE_NOTFOUND;
+ }
+ ONDXKey* pKey = GetNextKey();
+ nRes = pKey ? pKey->GetRecord() : STRING_NOTFOUND;
+ }
+ else if (m_pOperator->IsA(TYPE(OOp_ISNOTNULL)))
+ nRes = GetNotNull(bFirst);
+ else if (m_pOperator->IsA(TYPE(OOp_ISNULL)))
+ nRes = GetNull(bFirst);
+ else if (m_pOperator->IsA(TYPE(OOp_LIKE)))
+ nRes = GetLike(bFirst);
+ else if (m_pOperator->IsA(TYPE(OOp_COMPARE)))
+ nRes = GetCompare(bFirst);
+
+ return nRes;
+}
+
+//------------------------------------------------------------------
+ONDXKey* OIndexIterator::GetFirstKey(ONDXPage* pPage, const OOperand& rKey)
+{
+ // sucht den vorgegeben key
+ // Besonderheit: gelangt der Algorithmus ans Ende
+ // wird immer die aktuelle Seite und die Knotenposition vermerkt
+ // auf die die Bedingung <= zutrifft
+ // dieses findet beim Insert besondere Beachtung
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ OOp_COMPARE aTempOp(SQLFilterOperator::GREATER);
+ USHORT i = 0;
+
+ if (pPage->IsLeaf())
+ {
+ // im blatt wird die eigentliche Operation ausgefuehrt, sonst die temp. (>)
+ while (i < pPage->Count() && !m_pOperator->operate(&((*pPage)[i]).GetKey(),&rKey))
+ i++;
+ }
+ else
+ while (i < pPage->Count() && !aTempOp.operate(&((*pPage)[i]).GetKey(),&rKey))
+ i++;
+
+
+ ONDXKey* pFoundKey = NULL;
+ if (!pPage->IsLeaf())
+ {
+ // weiter absteigen
+ ONDXPagePtr aPage = (i==0) ? pPage->GetChild(m_pIndex)
+ : ((*pPage)[i-1]).GetChild(m_pIndex, pPage);
+ pFoundKey = aPage.Is() ? GetFirstKey(aPage, rKey) : NULL;
+ }
+ else if (i == pPage->Count())
+ {
+ pFoundKey = NULL;
+ }
+ else
+ {
+ pFoundKey = &(*pPage)[i].GetKey();
+ if (!m_pOperator->operate(pFoundKey,&rKey))
+ pFoundKey = NULL;
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = pFoundKey ? i : i - 1;
+ }
+ return pFoundKey;
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::GetCompare(BOOL bFirst)
+{
+ ONDXKey* pKey = NULL;
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ sal_Int32 ePredicateType = PTR_CAST(file::OOp_COMPARE,m_pOperator)->getPredicateType();
+
+ if (bFirst)
+ {
+ // Vorbereitung , auf kleinstes Element positionieren
+ ONDXPage* pPage = m_aRoot;
+ switch (ePredicateType)
+ {
+ case SQLFilterOperator::NOT_EQUAL:
+ case SQLFilterOperator::LESS:
+ case SQLFilterOperator::LESS_EQUAL:
+ while (pPage && !pPage->IsLeaf())
+ pPage = pPage->GetChild(m_pIndex);
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = NODE_NOTFOUND;
+ }
+
+
+ switch (ePredicateType)
+ {
+ case SQLFilterOperator::NOT_EQUAL:
+ while ( ( ( pKey = GetNextKey() ) != NULL ) && !m_pOperator->operate(pKey,m_pOperand)) ;
+ break;
+ case SQLFilterOperator::LESS:
+ while ( ( ( pKey = GetNextKey() ) != NULL ) && pKey->getValue().isNull()) ;
+ break;
+ case SQLFilterOperator::LESS_EQUAL:
+ while ( ( pKey = GetNextKey() ) != NULL ) ;
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ case SQLFilterOperator::EQUAL:
+ pKey = GetFirstKey(m_aRoot,*m_pOperand);
+ break;
+ case SQLFilterOperator::GREATER:
+ pKey = GetFirstKey(m_aRoot,*m_pOperand);
+ if ( !pKey )
+ while ( ( ( pKey = GetNextKey() ) != NULL ) && !m_pOperator->operate(pKey,m_pOperand)) ;
+ }
+ }
+ else
+ {
+ switch (ePredicateType)
+ {
+ case SQLFilterOperator::NOT_EQUAL:
+ while ( ( ( pKey = GetNextKey() ) != NULL ) && !m_pOperator->operate(pKey,m_pOperand))
+ ;
+ break;
+ case SQLFilterOperator::LESS:
+ case SQLFilterOperator::LESS_EQUAL:
+ case SQLFilterOperator::EQUAL:
+ if ( ( ( pKey = GetNextKey() ) == NULL ) || !m_pOperator->operate(pKey,m_pOperand))
+ {
+ pKey = NULL;
+ m_aCurLeaf = NULL;
+ }
+ break;
+ case SQLFilterOperator::GREATER_EQUAL:
+ case SQLFilterOperator::GREATER:
+ pKey = GetNextKey();
+ }
+ }
+
+ return pKey ? pKey->GetRecord() : STRING_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::GetLike(BOOL bFirst)
+{
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ if (bFirst)
+ {
+ ONDXPage* pPage = m_aRoot;
+
+ while (pPage && !pPage->IsLeaf())
+ pPage = pPage->GetChild(m_pIndex);
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = NODE_NOTFOUND;
+ }
+
+ ONDXKey* pKey;
+ while ( ( ( pKey = GetNextKey() ) != NULL ) && !m_pOperator->operate(pKey,m_pOperand))
+ ;
+ return pKey ? pKey->GetRecord() : STRING_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::GetNull(BOOL bFirst)
+{
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ if (bFirst)
+ {
+ ONDXPage* pPage = m_aRoot;
+ while (pPage && !pPage->IsLeaf())
+ pPage = pPage->GetChild(m_pIndex);
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = NODE_NOTFOUND;
+ }
+
+ ONDXKey* pKey;
+ if ( ( ( pKey = GetNextKey() ) == NULL ) || !pKey->getValue().isNull())
+ {
+ pKey = NULL;
+ m_aCurLeaf = NULL;
+ }
+ return pKey ? pKey->GetRecord() : STRING_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+ULONG OIndexIterator::GetNotNull(BOOL bFirst)
+{
+ ONDXKey* pKey;
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ if (bFirst)
+ {
+ // erst alle NULL werte abklappern
+ for (ULONG nRec = GetNull(bFirst);
+ nRec != STRING_NOTFOUND;
+ nRec = GetNull(FALSE))
+ ;
+ pKey = m_aCurLeaf.Is() ? &(*m_aCurLeaf)[m_nCurNode].GetKey() : NULL;
+ }
+ else
+ pKey = GetNextKey();
+
+ return pKey ? pKey->GetRecord() : STRING_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+ONDXKey* OIndexIterator::GetNextKey()
+{
+ // ONDXIndex* m_pIndex = GetNDXIndex();
+ if (m_aCurLeaf.Is() && ((++m_nCurNode) >= m_aCurLeaf->Count()))
+ {
+ ONDXPage* pPage = m_aCurLeaf;
+ // naechste Seite suchen
+ while (pPage)
+ {
+ ONDXPage* pParentPage = pPage->GetParent();
+ if (pParentPage)
+ {
+ USHORT nPos = pParentPage->Search(pPage);
+ if (nPos != pParentPage->Count() - 1)
+ { // Seite gefunden
+ pPage = (*pParentPage)[nPos+1].GetChild(m_pIndex,pParentPage);
+ break;
+ }
+ }
+ pPage = pParentPage;
+ }
+
+ // jetzt wieder zum Blatt
+ while (pPage && !pPage->IsLeaf())
+ pPage = pPage->GetChild(m_pIndex);
+
+ m_aCurLeaf = pPage;
+ m_nCurNode = 0;
+ }
+ return m_aCurLeaf.Is() ? &(*m_aCurLeaf)[m_nCurNode].GetKey() : NULL;
+}
+
diff --git a/connectivity/source/drivers/dbase/DIndexes.cxx b/connectivity/source/drivers/dbase/DIndexes.cxx
new file mode 100644
index 000000000000..fda3efa9cc5e
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DIndexes.cxx
@@ -0,0 +1,137 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DIndexes.hxx"
+#include "dbase/DIndex.hxx"
+#include <connectivity/dbexception.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <comphelper/types.hxx>
+#include "resource/dbase_res.hrc"
+
+using namespace ::comphelper;
+
+using namespace utl;
+using namespace ::connectivity;
+using namespace ::dbtools;
+using namespace ::connectivity::dbase;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType ODbaseIndexes::createObject(const ::rtl::OUString& _rName)
+{
+ // Dir* pDir = m_pTable->getConnection()->getDir();
+ // String aPath = pDir->GetName();
+ // aPath += _rName.getStr();
+ ::rtl::OUString sFile = m_pTable->getConnection()->getURL();
+ sFile += OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DELIMITER);
+ sFile += _rName;
+ sFile += ::rtl::OUString::createFromAscii(".ndx");
+ if ( !UCBContentHelper::Exists(sFile) )
+ {
+ const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_FILE,
+ "$filename$", sFile
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *m_pTable );
+ }
+
+ sdbcx::ObjectType xRet;
+ SvStream* pFileStream = ::connectivity::file::OFileTable::createStream_simpleError(sFile,STREAM_READ | STREAM_NOCREATE| STREAM_SHARE_DENYWRITE);
+ if(pFileStream)
+ {
+ pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ pFileStream->SetBufferSize(PAGE_SIZE);
+ ODbaseIndex::NDXHeader aHeader;
+
+ pFileStream->Seek(0);
+ pFileStream->Read(&aHeader,PAGE_SIZE);
+ delete pFileStream;
+
+ ODbaseIndex* pIndex = new ODbaseIndex(m_pTable,aHeader,_rName);
+ xRet = pIndex;
+ pIndex->openIndexFile();
+ }
+ else
+ {
+ const ::rtl::OUString sError( m_pTable->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_FILE,
+ "$filename$", sFile
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *m_pTable );
+ }
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void ODbaseIndexes::impl_refresh( ) throw(RuntimeException)
+{
+ if(m_pTable)
+ m_pTable->refreshIndexes();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > ODbaseIndexes::createDescriptor()
+{
+ return new ODbaseIndex(m_pTable);
+}
+typedef connectivity::sdbcx::OCollection ODbaseTables_BASE_BASE;
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType ODbaseIndexes::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ if(!pIndex || !pIndex->CreateImpl())
+ throw SQLException();
+ }
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void ODbaseIndexes::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
+{
+ Reference< XUnoTunnel> xTunnel(getObject(_nPos),UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ if ( pIndex )
+ pIndex->DropImpl();
+ }
+
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/DNoException.cxx b/connectivity/source/drivers/dbase/DNoException.cxx
new file mode 100644
index 000000000000..b39581f1be15
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DNoException.cxx
@@ -0,0 +1,650 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DTable.hxx"
+#include "dbase/DIndex.hxx"
+#include "dbase/dindexnode.hxx"
+#include <tools/debug.hxx>
+#include "diagnose_ex.h"
+
+#include <sal/types.h>
+#include <algorithm>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::dbase;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+//------------------------------------------------------------------
+sal_Bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::seekRow" );
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ OSL_ENSURE(m_pFileStream,"ODbaseTable::seekRow: FileStream is NULL!");
+
+ sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz;
+ sal_uInt32 nTempPos = m_nFilePos;
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nFilePos;
+ break;
+ case IResultSetHelper::PRIOR:
+ if (m_nFilePos > 0)
+ --m_nFilePos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 1;
+ break;
+ case IResultSetHelper::LAST:
+ m_nFilePos = nNumberOfRecords;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L
+ : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset);
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = (sal_uInt32)nOffset;
+ break;
+ }
+
+ if (m_nFilePos > (sal_Int32)nNumberOfRecords)
+ m_nFilePos = (sal_Int32)nNumberOfRecords + 1;
+
+ if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1)
+ goto Error;
+ else
+ {
+ sal_uInt16 nEntryLen = m_aHeader.db_slng;
+
+ OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
+ sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen;
+
+ ULONG nLen = m_pFileStream->Seek(nPos);
+ if (m_pFileStream->GetError() != ERRCODE_NONE)
+ goto Error;
+
+ nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen);
+ if (m_pFileStream->GetError() != ERRCODE_NONE)
+ goto Error;
+ }
+ goto End;
+
+Error:
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::PRIOR:
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ case IResultSetHelper::NEXT:
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::RELATIVE:
+ if (nOffset > 0)
+ m_nFilePos = nNumberOfRecords + 1;
+ else if (nOffset < 0)
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = nTempPos; // vorherige Position
+ }
+ // aStatus.Set(SDB_STAT_NO_DATA_FOUND);
+ return sal_False;
+
+End:
+ nCurPos = m_nFilePos;
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemo" );
+ BOOL bIsText = TRUE;
+ // SdbConnection* pConnection = GetConnection();
+
+ m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size);
+ switch (m_aMemoHeader.db_typ)
+ {
+ case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z
+ {
+ const char cEOF = (char) 0x1a;
+ ByteString aBStr;
+ static char aBuf[514];
+ aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen
+ BOOL bReady = sal_False;
+
+ do
+ {
+ m_pMemoStream->Read(&aBuf,512);
+
+ USHORT i = 0;
+ while (aBuf[i] != cEOF && ++i < 512)
+ ;
+ bReady = aBuf[i] == cEOF;
+
+ aBuf[i] = 0;
+ aBStr += aBuf;
+
+ } while (!bReady && !m_pMemoStream->IsEof() && aBStr.Len() < STRING_MAXLEN);
+
+ ::rtl::OUString aStr(aBStr.GetBuffer(), aBStr.Len(),getConnection()->getTextEncoding());
+ aVariable = aStr;
+
+ } break;
+ case MemoFoxPro:
+ case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe
+ {
+ char sHeader[4];
+ m_pMemoStream->Read(sHeader,4);
+ // Foxpro stores text and binary data
+ if (m_aMemoHeader.db_typ == MemoFoxPro)
+ {
+ if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0)
+ {
+// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
+// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
+// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
+// aStatus.Set(SDB_STAT_ERROR,
+// String::CreateFromAscii("01000"),
+// aStatus.CreateErrorMessage(aText),
+// 0, String() );
+ return sal_False;
+ }
+
+ bIsText = sHeader[3] != 0;
+ }
+ else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08)
+ {
+// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
+// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
+// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
+// aStatus.Set(SDB_STAT_ERROR,
+// String::CreateFromAscii("01000"),
+// aStatus.CreateErrorMessage(aText),
+// 0, String() );
+ return sal_False;
+ }
+
+ sal_uInt32 nLength;
+ (*m_pMemoStream) >> nLength;
+
+ if (m_aMemoHeader.db_typ == MemodBaseIV)
+ nLength -= 8;
+
+ // char cChar;
+ ::rtl::OUString aStr;
+ while ( nLength > STRING_MAXLEN )
+ {
+ ByteString aBStr;
+ aBStr.Expand(STRING_MAXLEN);
+ m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN);
+ aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding());
+ nLength -= STRING_MAXLEN;
+ }
+ if ( nLength > 0 )
+ {
+ ByteString aBStr;
+ aBStr.Expand(static_cast<xub_StrLen>(nLength));
+ m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength);
+ // aBStr.ReleaseBufferAccess();
+
+ aStr += ::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), getConnection()->getTextEncoding());
+
+ }
+ if ( aStr.getLength() )
+ aVariable = aStr;
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::AllocBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::AllocBuffer" );
+ UINT16 nSize = m_aHeader.db_slng;
+ OSL_ENSURE(nSize > 0, "Size too small");
+
+ if (m_nBufferSize != nSize)
+ {
+ delete[] m_pBuffer;
+ m_pBuffer = NULL;
+ }
+
+ // Falls noch kein Puffer vorhanden: allozieren:
+ if (m_pBuffer == NULL && nSize)
+ {
+ m_nBufferSize = nSize;
+ m_pBuffer = new BYTE[m_nBufferSize+1];
+ }
+}
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::WriteBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteBuffer" );
+ OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
+
+ // Auf gewuenschten Record positionieren:
+ long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng;
+ m_pFileStream->Seek(nPos);
+ return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODbaseTable::getCurrentLastPos() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getCurrentLastPos" );
+ return m_aHeader.db_anz;
+}
+// -----------------------------------------------------------------------------
+//==================================================================
+// ONDXNode
+//==================================================================
+
+//------------------------------------------------------------------
+void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::Read" );
+ rStream >> aKey.nRecord; // schluessel
+
+ if (rIndex.getHeader().db_keytype)
+ {
+ double aDbl;
+ rStream >> aDbl;
+ aKey = ONDXKey(aDbl,aKey.nRecord);
+ }
+ else
+ {
+ ByteString aBuf;
+ USHORT nLen = rIndex.getHeader().db_keylen;
+ char* pStr = aBuf.AllocBuffer(nLen+1);
+
+ rStream.Read(pStr,nLen);
+ pStr[nLen] = 0;
+ aBuf.ReleaseBufferAccess();
+ aBuf.EraseTrailingChars();
+
+ // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord);
+ aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
+ }
+ rStream >> aChild;
+}
+
+union
+{
+ double aDbl;
+ char aData[128];
+} aNodeData;
+//------------------------------------------------------------------
+void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::Write" );
+ const ODbaseIndex& rIndex = rPage.GetIndex();
+ if (!rIndex.isUnique() || rPage.IsLeaf())
+ rStream << (sal_uInt32)aKey.nRecord; // schluessel
+ else
+ rStream << (sal_uInt32)0; // schluessel
+
+ if (rIndex.getHeader().db_keytype) // double
+ {
+ if (aKey.getValue().isNull())
+ {
+ memset(aNodeData.aData,0,rIndex.getHeader().db_keylen);
+ rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
+ }
+ else
+ rStream << (double) aKey.getValue();
+ }
+ else
+ {
+ memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen);
+ if (!aKey.getValue().isNull())
+ {
+ ::rtl::OUString sValue = aKey.getValue();
+ ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding());
+ strncpy(aNodeData.aData,aText.GetBuffer(),std::min(rIndex.getHeader().db_keylen, aText.Len()));
+ }
+ rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
+ }
+ rStream << aChild;
+}
+
+
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXNode::GetChild" );
+ if (!aChild.Is() && pIndex)
+ {
+ aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage());
+ }
+ return aChild;
+}
+
+//==================================================================
+// ONDXKey
+//==================================================================
+//------------------------------------------------------------------
+BOOL ONDXKey::IsText(sal_Int32 eType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::IsText" );
+ return eType == DataType::VARCHAR || eType == DataType::CHAR;
+}
+
+//------------------------------------------------------------------
+StringCompare ONDXKey::Compare(const ONDXKey& rKey) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::Compare" );
+ // DBG_ASSERT(is(), "Falscher Indexzugriff");
+ StringCompare eResult;
+
+ if (getValue().isNull())
+ {
+ if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength()))
+ eResult = COMPARE_EQUAL;
+ else
+ eResult = COMPARE_LESS;
+ }
+ else if (rKey.getValue().isNull())
+ {
+ if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength()))
+ eResult = COMPARE_EQUAL;
+ else
+ eResult = COMPARE_GREATER;
+ }
+ else if (IsText(getDBType()))
+ {
+ INT32 nRes = getValue().getString().compareTo(rKey.getValue());
+ eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS;
+ }
+ else
+ {
+ double m = getValue(),n = rKey.getValue();
+ eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS;
+ }
+
+ // Record vergleich, wenn Index !Unique
+ if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord)
+ eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER :
+ (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS;
+
+ return eResult;
+}
+// -----------------------------------------------------------------------------
+void ONDXKey::setValue(const ORowSetValue& _rVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::setValue" );
+ xValue = _rVal;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& ONDXKey::getValue() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXKey::getValue" );
+ return xValue;
+}
+// -----------------------------------------------------------------------------
+SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage)
+{
+ rStream >> rPage.nPagePos;
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage)
+{
+ rStream << rPage.nPagePos;
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+//==================================================================
+// ONDXPagePtr
+//==================================================================
+//------------------------------------------------------------------
+ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef)
+ :ONDXPageRef(rRef)
+ ,nPagePos(rRef.nPagePos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPagePtr::ONDXPagePtr" );
+}
+
+//------------------------------------------------------------------
+ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage)
+ :ONDXPageRef(pRefPage)
+ ,nPagePos(0)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPagePtr::ONDXPagePtr" );
+ if (pRefPage)
+ nPagePos = pRefPage->GetPagePos();
+}
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef)
+{
+ ONDXPageRef::operator=(rRef);
+ nPagePos = rRef.nPagePos;
+ return *this;
+}
+
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef)
+{
+ ONDXPageRef::operator=(pRef);
+ nPagePos = (pRef) ? pRef->GetPagePos() : 0;
+ return *this;
+}
+// -----------------------------------------------------------------------------
+static UINT32 nValue;
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage)
+{
+ rStream.Seek(rPage.GetPagePos() * 512);
+ rStream >> nValue >> rPage.aChild;
+ rPage.nCount = USHORT(nValue);
+
+// DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count");
+ for (USHORT i = 0; i < rPage.nCount; i++)
+ rPage[i].Read(rStream, rPage.GetIndex());
+ return rStream;
+}
+
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage)
+{
+ // Seite existiert noch nicht
+ ULONG nSize = (rPage.GetPagePos() + 1) * 512;
+ if (nSize > rStream.Seek(STREAM_SEEK_TO_END))
+ {
+ rStream.SetStreamSize(nSize);
+ rStream.Seek(rPage.GetPagePos() * 512);
+
+ char aEmptyData[512];
+ memset(aEmptyData,0x00,512);
+ rStream.Write((BYTE*)aEmptyData,512);
+ }
+ ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * 512);
+ OSL_UNUSED( nCurrentPos );
+
+ nValue = rPage.nCount;
+ rStream << nValue << rPage.aChild;
+
+ USHORT i = 0;
+ for (; i < rPage.nCount; i++)
+ rPage[i].Write(rStream, rPage);
+
+ // check if we have to fill the stream with '\0'
+ if(i < rPage.rIndex.getHeader().db_maxkeys)
+ {
+ ULONG nTell = rStream.Tell() % 512;
+ USHORT nBufferSize = rStream.GetBufferSize();
+ ULONG nSize = nBufferSize - nTell;
+ char* pEmptyData = new char[nSize];
+ memset(pEmptyData,0x00,nSize);
+ rStream.Write((BYTE*)pEmptyData,nSize);
+ rStream.Seek(nTell);
+ delete [] pEmptyData;
+ }
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 1
+//------------------------------------------------------------------
+void ONDXPage::PrintPage()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::PrintPage" );
+ DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----",
+ nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos());
+
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ ONDXNode rNode = (*this)[i];
+ ONDXKey& rKey = rNode.GetKey();
+ if (!IsLeaf())
+ rNode.GetChild(&rIndex, this);
+
+ if (rKey.getValue().isNull())
+ {
+ DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos());
+ }
+ else if (rIndex.getHeader().db_keytype)
+ {
+ DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos());
+ }
+ else
+ {
+ DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos());
+ }
+ }
+ DBG_TRACE("SDB: -----------------------------------------------\n");
+ if (!IsLeaf())
+ {
+#if OSL_DEBUG_LEVEL > 1
+ GetChild(&rIndex)->PrintPage();
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ ONDXNode rNode = (*this)[i];
+ rNode.GetChild(&rIndex,this)->PrintPage();
+ }
+#endif
+ }
+ DBG_TRACE("SDB: ===============================================\n");
+}
+#endif
+// -----------------------------------------------------------------------------
+BOOL ONDXPage::IsFull() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::IsFull" );
+ return Count() == rIndex.getHeader().db_maxkeys;
+}
+// -----------------------------------------------------------------------------
+//------------------------------------------------------------------
+USHORT ONDXPage::Search(const ONDXKey& rSearch)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Search" );
+ // binare Suche spaeter
+ USHORT i = 0xFFFF;
+ while (++i < Count())
+ if ((*this)[i].GetKey() == rSearch)
+ break;
+
+ return (i < Count()) ? i : NODE_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+USHORT ONDXPage::Search(const ONDXPage* pPage)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Search" );
+ USHORT i = 0xFFFF;
+ while (++i < Count())
+ if (((*this)[i]).GetChild() == pPage)
+ break;
+
+ // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst
+ // auf die Page zeigt
+ return (i < Count()) ? i : NODE_NOTFOUND;
+}
+// -----------------------------------------------------------------------------
+// laeuft rekursiv
+void ONDXPage::SearchAndReplace(const ONDXKey& rSearch,
+ ONDXKey& rReplace)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::SearchAndReplace" );
+ OSL_ENSURE(rSearch != rReplace,"Invalid here:rSearch == rReplace");
+ if (rSearch != rReplace)
+ {
+ USHORT nPos = NODE_NOTFOUND;
+ ONDXPage* pPage = this;
+
+ while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND)
+ pPage = pPage->aParent;
+
+ if (pPage)
+ {
+ (*pPage)[nPos].GetKey() = rReplace;
+ pPage->SetModified(TRUE);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+ONDXNode& ONDXPage::operator[] (USHORT nPos)
+{
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+ return ppNodes[nPos];
+}
+
+//------------------------------------------------------------------
+const ONDXNode& ONDXPage::operator[] (USHORT nPos) const
+{
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+ return ppNodes[nPos];
+}
+// -----------------------------------------------------------------------------
+void ONDXPage::Remove(USHORT nPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ONDXPage::Remove" );
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+
+ for (USHORT i = nPos; i < (nCount-1); i++)
+ (*this)[i] = (*this)[i+1];
+
+ nCount--;
+ bModified = TRUE;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/dbase/DPreparedStatement.cxx b/connectivity/source/drivers/dbase/DPreparedStatement.cxx
new file mode 100644
index 000000000000..42bfff750eca
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DPreparedStatement.cxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DPreparedStatement.hxx"
+#include "dbase/DResultSet.hxx"
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* ODbasePreparedStatement::createResultSet()
+{
+ return new ODbaseResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(ODbasePreparedStatement,"com.sun.star.sdbc.driver.dbase.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
diff --git a/connectivity/source/drivers/dbase/DResultSet.cxx b/connectivity/source/drivers/dbase/DResultSet.cxx
new file mode 100644
index 000000000000..ab19bc49ff9d
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DResultSet.cxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include "dbase/DResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include "dbase/DIndex.hxx"
+#include "dbase/DIndexIter.hxx"
+#include "dbase/DCode.hxx"
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/dbase_res.hrc"
+
+using namespace ::comphelper;
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// using namespace com::sun::star::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+ODbaseResultSet::ODbaseResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODbaseResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.dbase.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL ODbaseResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODbaseResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ODbaseResultSet_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OResultSet::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL ODbaseResultSet::getTypes( ) throw( RuntimeException)
+{
+ return ::comphelper::concatSequences(OResultSet::getTypes(),ODbaseResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL ODbaseResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getBookmark called for deleted row");
+
+ return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return m_pTable ? Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ if(!m_pTable)
+ return sal_False;
+
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False);
+
+ return relative(rows);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ sal_Int32 nFirst(0),nSecond(0),nResult(0);
+ if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_INVALID_BOOKMARK);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) )
+
+ // have a look at CompareBookmark
+ // we can't use the names there because we already have defines with the same name from the parser
+ if(nFirst < nSecond)
+ nResult = -1;
+ else if(nFirst > nSecond)
+ nResult = 1;
+ else
+ nResult = 0;
+
+ return nResult;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODbaseResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODbaseResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL ODbaseResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+sal_Bool ODbaseResultSet::fillIndexValues(const Reference< XColumnsSupplier> &_xIndex)
+{
+ Reference<XUnoTunnel> xTunnel(_xIndex,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ dbase::ODbaseIndex* pIndex = reinterpret_cast< dbase::ODbaseIndex* >( xTunnel->getSomething(dbase::ODbaseIndex::getUnoTunnelImplementationId()) );
+ if(pIndex)
+ {
+ dbase::OIndexIterator* pIter = pIndex->createIterator(NULL,NULL);
+
+ if (pIter)
+ {
+ sal_uInt32 nRec = pIter->First();
+ while (nRec != SQL_COLUMN_NOTFOUND)
+ {
+ if (m_aOrderbyAscending[0])
+ m_pFileSet->get().push_back(nRec);
+ else
+ m_pFileSet->get().insert(m_pFileSet->get().begin(),nRec);
+ nRec = pIter->Next();
+ }
+ m_pFileSet->setFrozen();
+ // if(!bDistinct)
+ // SetRowCount(pFileSet->count());
+ delete pIter;
+ return sal_True;
+ }
+ delete pIter;
+ }
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & ODbaseResultSet::getInfoHelper()
+{
+ return *ODbaseResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODbaseResultSet::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODbaseResultSet::acquire() throw()
+{
+ ODbaseResultSet_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODbaseResultSet::release() throw()
+{
+ ODbaseResultSet_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL ODbaseResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+OSQLAnalyzer* ODbaseResultSet::createAnalyzer()
+{
+ return new OFILEAnalyzer(m_pTable->getConnection());
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODbaseResultSet::getCurrentFilePos() const
+{
+ return m_pTable->getFilePos();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/DStatement.cxx b/connectivity/source/drivers/dbase/DStatement.cxx
new file mode 100644
index 000000000000..f65cfabe0dda
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DStatement.cxx
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DStatement.hxx"
+#include "dbase/DResultSet.hxx"
+
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+
+// -------------------------------------------------------------------------
+OResultSet* ODbaseStatement::createResultSet()
+{
+ return new ODbaseResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(ODbaseStatement,"com.sun.star.sdbc.driver.dbase.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/dbase/DTable.cxx b/connectivity/source/drivers/dbase/DTable.cxx
new file mode 100644
index 000000000000..8544e4affda7
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DTable.cxx
@@ -0,0 +1,2855 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DTable.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <svl/converter.hxx>
+#include "dbase/DConnection.hxx"
+#include "dbase/DColumns.hxx"
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include "dbase/DIndex.hxx"
+#include "dbase/DIndexes.hxx"
+//#include "file/FDriver.hxx"
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <unotools/syslocale.hxx>
+#include <rtl/math.hxx>
+#include <stdio.h> //sprintf
+#include <ucbhelper/content.hxx>
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbconversion.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/property.hxx>
+//#include <unotools/calendarwrapper.hxx>
+#include <unotools/tempfile.hxx>
+#include <unotools/ucbhelper.hxx>
+#include <comphelper/types.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include "connectivity/PColumn.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/FValue.hxx"
+#include "connectivity/dbconversion.hxx"
+#include "resource/dbase_res.hrc"
+#include <rtl/logfile.hxx>
+
+#include <algorithm>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::sdbcx;
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::ucbhelper;
+using namespace ::utl;
+using namespace ::cppu;
+using namespace ::dbtools;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::i18n;
+
+// stored as the Field Descriptor terminator
+#define FIELD_DESCRIPTOR_TERMINATOR 0x0D
+#define DBF_EOL 0x1A
+
+namespace
+{
+sal_Int32 lcl_getFileSize(SvStream& _rStream)
+{
+ sal_Int32 nFileSize = 0;
+ _rStream.Seek(STREAM_SEEK_TO_END);
+ _rStream.SeekRel(-1);
+ char cEOL;
+ _rStream >> cEOL;
+ nFileSize = _rStream.Tell();
+ if ( cEOL == DBF_EOL )
+ nFileSize -= 1;
+ return nFileSize;
+}
+/**
+ calculates the Julian date
+*/
+void lcl_CalcJulDate(sal_Int32& _nJulianDate,sal_Int32& _nJulianTime,const com::sun::star::util::DateTime _aDateTime)
+{
+ com::sun::star::util::DateTime aDateTime = _aDateTime;
+ // weird: months fix
+ if (aDateTime.Month > 12)
+ {
+ aDateTime.Month--;
+ sal_uInt16 delta = _aDateTime.Month / 12;
+ aDateTime.Year += delta;
+ aDateTime.Month -= delta * 12;
+ aDateTime.Month++;
+ }
+
+ _nJulianTime = ((aDateTime.Hours*3600000)+(aDateTime.Minutes*60000)+(aDateTime.Seconds*1000)+(aDateTime.HundredthSeconds*10));
+ /* conversion factors */
+ sal_uInt16 iy0;
+ sal_uInt16 im0;
+ if ( aDateTime.Month <= 2 )
+ {
+ iy0 = aDateTime.Year - 1;
+ im0 = aDateTime.Month + 12;
+ }
+ else
+ {
+ iy0 = aDateTime.Year;
+ im0 = aDateTime.Month;
+ }
+ sal_Int32 ia = iy0 / 100;
+ sal_Int32 ib = 2 - ia + (ia >> 2);
+ /* calculate julian date */
+ if ( aDateTime.Year <= 0 )
+ {
+ _nJulianDate = (sal_Int32) ((365.25 * iy0) - 0.75)
+ + (sal_Int32) (30.6001 * (im0 + 1) )
+ + aDateTime.Day + 1720994;
+ } // if ( _aDateTime.Year <= 0 )
+ else
+ {
+ _nJulianDate = static_cast<sal_Int32>( ((365.25 * iy0)
+ + (sal_Int32) (30.6001 * (im0 + 1))
+ + aDateTime.Day + 1720994));
+ }
+ double JD = _nJulianDate + 0.5;
+ _nJulianDate = (sal_Int32)( JD + 0.5);
+ const double gyr = aDateTime.Year + (0.01 * aDateTime.Month) + (0.0001 * aDateTime.Day);
+ if ( gyr >= 1582.1015 ) /* on or after 15 October 1582 */
+ _nJulianDate += ib;
+}
+
+/**
+ calculates date time from the Julian Date
+*/
+void lcl_CalDate(sal_Int32 _nJulianDate,sal_Int32 _nJulianTime,com::sun::star::util::DateTime& _rDateTime)
+{
+ if ( _nJulianDate )
+ {
+ sal_Int32 ialp;
+ sal_Int32 ka = _nJulianDate;
+ if ( _nJulianDate >= 2299161 )
+ {
+ ialp = (sal_Int32)( ((double) _nJulianDate - 1867216.25 ) / ( 36524.25 ));
+ ka = _nJulianDate + 1 + ialp - ( ialp >> 2 );
+ }
+ sal_Int32 kb = ka + 1524;
+ sal_Int32 kc = (sal_Int32) ( ((double) kb - 122.1 ) / 365.25 );
+ sal_Int32 kd = (sal_Int32) ((double) kc * 365.25);
+ sal_Int32 ke = (sal_Int32) ((double) ( kb - kd ) / 30.6001 );
+ _rDateTime.Day = static_cast<sal_uInt16>(kb - kd - ((sal_Int32) ( (double) ke * 30.6001 )));
+ if ( ke > 13 )
+ _rDateTime.Month = static_cast<sal_uInt16>(ke - 13);
+ else
+ _rDateTime.Month = static_cast<sal_uInt16>(ke - 1);
+ if ( (_rDateTime.Month == 2) && (_rDateTime.Day > 28) )
+ _rDateTime.Day = 29;
+ if ( (_rDateTime.Month == 2) && (_rDateTime.Day == 29) && (ke == 3) )
+ _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716);
+ else if ( _rDateTime.Month > 2 )
+ _rDateTime.Year = static_cast<sal_uInt16>(kc - 4716);
+ else
+ _rDateTime.Year = static_cast<sal_uInt16>(kc - 4715);
+ } // if ( _nJulianDate )
+
+ if ( _nJulianTime )
+ {
+ double d_s = _nJulianTime / 1000;
+ double d_m = d_s / 60;
+ double d_h = d_m / 60;
+ _rDateTime.Hours = (sal_uInt16) (d_h);
+ _rDateTime.Minutes = (sal_uInt16) d_m; // integer _aDateTime.Minutes
+ //// weird: time fix
+ // int test = (_rDateTime.Hours % 3) * 100 + _rDateTime.Minutes;
+ //int test_tbl[] = {0, 1, 2, 11, 12, 13, 22, 23, 24, 25, 34, 35, 36,
+ // 45, 46, 47, 56, 57, 58, 107, 108, 109, 110, 119, 120, 121,
+ // 130, 131, 132, 141, 142, 143, 152, 153, 154, 155, 204, 205,
+ // 206, 215, 216, 217, 226, 227, 228, 237, 238, 239, 240, 249,
+ // 250, 251};
+ // for (int i = 0; i < sizeof(test_tbl)/sizeof(test_tbl[0]); i++)
+ //{
+ // if (test == test_tbl[i])
+ // {
+ // // frac += 0.000012;
+ // //d_hour = frac * 24.0;
+ // _rDateTime.Hours = (sal_uInt16)d_hour;
+ // d_minute = (d_hour - (double)_rDateTime.Hours) * 60.0;
+ // _rDateTime.Minutes = (sal_uInt16)d_minute;
+ // break;
+ // }
+ // }
+
+ _rDateTime.Seconds = static_cast<sal_uInt16>(( d_m - (double) _rDateTime.Minutes ) * 60.0);
+ }
+}
+
+}
+
+// -------------------------------------------------------------------------
+void ODbaseTable::readHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::readHeader" );
+ OSL_ENSURE(m_pFileStream,"No Stream available!");
+ if(!m_pFileStream)
+ return;
+ m_pFileStream->RefreshBuffer(); // sicherstellen, dass die Kopfinformationen tatsaechlich neu gelesen werden
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ BYTE nType=0;
+ (*m_pFileStream) >> nType;
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+
+ m_pFileStream->Read((char*)(&m_aHeader.db_aedat), 3*sizeof(BYTE));
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+ (*m_pFileStream) >> m_aHeader.db_anz;
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+ (*m_pFileStream) >> m_aHeader.db_kopf;
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+ (*m_pFileStream) >> m_aHeader.db_slng;
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+ m_pFileStream->Read((char*)(&m_aHeader.db_frei), 20*sizeof(BYTE));
+ if(ERRCODE_NONE != m_pFileStream->GetErrorCode())
+ throwInvalidDbaseFormat();
+
+ if ( ( ( m_aHeader.db_kopf - 1 ) / 32 - 1 ) <= 0 ) // anzahl felder
+ {
+ // no dbase file
+ throwInvalidDbaseFormat();
+ }
+ else
+ {
+ // Konsistenzpruefung des Header:
+ m_aHeader.db_typ = (DBFType)nType;
+ switch (m_aHeader.db_typ)
+ {
+ case dBaseIII:
+ case dBaseIV:
+ case dBaseV:
+ case VisualFoxPro:
+ case VisualFoxProAuto:
+ case dBaseFS:
+ case dBaseFSMemo:
+ case dBaseIVMemoSQL:
+ case dBaseIIIMemo:
+ case FoxProMemo:
+ m_pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ if ( m_aHeader.db_frei[17] != 0x00
+ && !m_aHeader.db_frei[18] && !m_aHeader.db_frei[19] && getConnection()->isTextEncodingDefaulted() )
+ {
+ switch(m_aHeader.db_frei[17])
+ {
+ case 0x01: m_eEncoding = RTL_TEXTENCODING_IBM_437; break; // DOS USA code page 437
+ case 0x02: m_eEncoding = RTL_TEXTENCODING_IBM_850; break; // DOS Multilingual code page 850
+ case 0x03: m_eEncoding = RTL_TEXTENCODING_MS_1252; break; // Windows ANSI code page 1252
+ case 0x04: m_eEncoding = RTL_TEXTENCODING_APPLE_ROMAN; break; // Standard Macintosh
+ case 0x64: m_eEncoding = RTL_TEXTENCODING_IBM_852; break; // EE MS-DOS code page 852
+ case 0x65: m_eEncoding = RTL_TEXTENCODING_IBM_865; break; // Nordic MS-DOS code page 865
+ case 0x66: m_eEncoding = RTL_TEXTENCODING_IBM_866; break; // Russian MS-DOS code page 866
+ case 0x67: m_eEncoding = RTL_TEXTENCODING_IBM_861; break; // Icelandic MS-DOS
+ //case 0x68: m_eEncoding = ; break; // Kamenicky (Czech) MS-DOS
+ //case 0x69: m_eEncoding = ; break; // Mazovia (Polish) MS-DOS
+ case 0x6A: m_eEncoding = RTL_TEXTENCODING_IBM_737; break; // Greek MS-DOS (437G)
+ case 0x6B: m_eEncoding = RTL_TEXTENCODING_IBM_857; break; // Turkish MS-DOS
+ case 0x96: m_eEncoding = RTL_TEXTENCODING_APPLE_CYRILLIC; break; // Russian Macintosh
+ case 0x97: m_eEncoding = RTL_TEXTENCODING_APPLE_CENTEURO; break; // Eastern European Macintosh
+ case 0x98: m_eEncoding = RTL_TEXTENCODING_APPLE_GREEK; break; // Greek Macintosh
+ case 0xC8: m_eEncoding = RTL_TEXTENCODING_MS_1250; break; // Windows EE code page 1250
+ case 0xC9: m_eEncoding = RTL_TEXTENCODING_MS_1251; break; // Russian Windows
+ case 0xCA: m_eEncoding = RTL_TEXTENCODING_MS_1254; break; // Turkish Windows
+ case 0xCB: m_eEncoding = RTL_TEXTENCODING_MS_1253; break; // Greek Windows
+ default:
+ break;
+ }
+ }
+ break;
+ case dBaseIVMemo:
+ m_pFileStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ break;
+ default:
+ {
+ throwInvalidDbaseFormat();
+ }
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void ODbaseTable::fillColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::fillColumns" );
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+ m_pFileStream->Seek(32L);
+
+ if(!m_aColumns.isValid())
+ m_aColumns = new OSQLColumns();
+ else
+ m_aColumns->get().clear();
+
+ m_aTypes.clear();
+ m_aPrecisions.clear();
+ m_aScales.clear();
+
+ // Anzahl Felder:
+ const sal_Int32 nFieldCount = (m_aHeader.db_kopf - 1) / 32 - 1;
+ OSL_ENSURE(nFieldCount,"No columns in table!");
+
+ m_aColumns->get().reserve(nFieldCount);
+ m_aTypes.reserve(nFieldCount);
+ m_aPrecisions.reserve(nFieldCount);
+ m_aScales.reserve(nFieldCount);
+
+ String aStrFieldName;
+ aStrFieldName.AssignAscii("Column");
+ ::rtl::OUString aTypeName;
+ static const ::rtl::OUString sVARCHAR(RTL_CONSTASCII_USTRINGPARAM("VARCHAR"));
+ const sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ const bool bFoxPro = m_aHeader.db_typ == VisualFoxPro || m_aHeader.db_typ == VisualFoxProAuto || m_aHeader.db_typ == FoxProMemo;
+
+ sal_Int32 i = 0;
+ for (; i < nFieldCount; i++)
+ {
+ DBFColumn aDBFColumn;
+ m_pFileStream->Read((char*)&aDBFColumn, sizeof(aDBFColumn));
+ if ( FIELD_DESCRIPTOR_TERMINATOR == aDBFColumn.db_fnm[0] ) // 0x0D stored as the Field Descriptor terminator.
+ break;
+
+ sal_Bool bIsRowVersion = bFoxPro && ( aDBFColumn.db_frei2[0] & 0x01 ) == 0x01;
+ //if ( bFoxPro && ( aDBFColumn.db_frei2[0] & 0x01 ) == 0x01 ) // system column not visible to user
+ // continue;
+ const String aColumnName((const char *)aDBFColumn.db_fnm,m_eEncoding);
+
+ m_aRealFieldLengths.push_back(aDBFColumn.db_flng);
+ sal_Int32 nPrecision = aDBFColumn.db_flng;
+ sal_Int32 eType;
+ sal_Bool bIsCurrency = sal_False;
+
+ char cType[2];
+ cType[0] = aDBFColumn.db_typ;
+ cType[1] = 0;
+ aTypeName = ::rtl::OUString::createFromAscii(cType);
+OSL_TRACE("column type: %c",aDBFColumn.db_typ);
+
+ switch (aDBFColumn.db_typ)
+ {
+ case 'C':
+ eType = DataType::VARCHAR;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VARCHAR"));
+ break;
+ case 'F':
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DECIMAL"));
+ case 'N':
+ if ( aDBFColumn.db_typ == 'N' )
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMERIC"));
+ eType = DataType::DECIMAL;
+
+ // Bei numerischen Feldern werden zwei Zeichen mehr geschrieben, als die Precision der Spaltenbeschreibung eigentlich
+ // angibt, um Platz fuer das eventuelle Vorzeichen und das Komma zu haben. Das muss ich jetzt aber wieder rausrechnen.
+ nPrecision = SvDbaseConverter::ConvertPrecisionToOdbc(nPrecision,aDBFColumn.db_dez);
+ // leider gilt das eben Gesagte nicht fuer aeltere Versionen ....
+ break;
+ case 'L':
+ eType = DataType::BIT;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BOOLEAN"));
+ break;
+ case 'Y':
+ bIsCurrency = sal_True;
+ eType = DataType::DOUBLE;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOUBLE"));
+ break;
+ case 'D':
+ eType = DataType::DATE;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATE"));
+ break;
+ case 'T':
+ eType = DataType::TIMESTAMP;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TIMESTAMP"));
+ break;
+ case 'I':
+ eType = DataType::INTEGER;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INTEGER"));
+ break;
+ case 'M':
+ if ( bFoxPro && ( aDBFColumn.db_frei2[0] & 0x04 ) == 0x04 )
+ {
+ eType = DataType::LONGVARBINARY;
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY"));
+ }
+ else
+ {
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARCHAR"));
+ eType = DataType::LONGVARCHAR;
+ }
+ nPrecision = 2147483647;
+ break;
+ case 'P':
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY"));
+ eType = DataType::LONGVARBINARY;
+ nPrecision = 2147483647;
+ break;
+ case '0':
+ case 'B':
+ if ( m_aHeader.db_typ == VisualFoxPro || m_aHeader.db_typ == VisualFoxProAuto )
+ {
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOUBLE"));
+ eType = DataType::DOUBLE;
+ }
+ else
+ {
+ aTypeName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LONGVARBINARY"));
+ eType = DataType::LONGVARBINARY;
+ nPrecision = 2147483647;
+ }
+ break;
+ default:
+ eType = DataType::OTHER;
+ }
+
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(aDBFColumn.db_dez);
+
+ Reference< XPropertySet> xCol = new sdbcx::OColumn(aColumnName,
+ aTypeName,
+ ::rtl::OUString(),
+ ::rtl::OUString(),
+ ColumnValue::NULLABLE,
+ nPrecision,
+ aDBFColumn.db_dez,
+ eType,
+ sal_False,
+ bIsRowVersion,
+ bIsCurrency,
+ bCase);
+ m_aColumns->get().push_back(xCol);
+ } // for (; i < nFieldCount; i++)
+ OSL_ENSURE(i,"No columns in table!");
+}
+// -------------------------------------------------------------------------
+ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection)
+ :ODbaseTable_BASE(_pTables,_pConnection)
+ ,m_pMemoStream(NULL)
+ ,m_bWriteableMemo(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ODbaseTable" );
+ // initialize the header
+ m_aHeader.db_typ = dBaseIII;
+ m_aHeader.db_anz = 0;
+ m_aHeader.db_kopf = 0;
+ m_aHeader.db_slng = 0;
+ m_eEncoding = getConnection()->getTextEncoding();
+}
+// -------------------------------------------------------------------------
+ODbaseTable::ODbaseTable(sdbcx::OCollection* _pTables,ODbaseConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : ODbaseTable_BASE(_pTables,_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pMemoStream(NULL)
+ ,m_bWriteableMemo(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ODbaseTable" );
+ m_eEncoding = getConnection()->getTextEncoding();
+}
+
+// -----------------------------------------------------------------------------
+void ODbaseTable::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::construct" );
+ // initialize the header
+ m_aHeader.db_typ = dBaseIII;
+ m_aHeader.db_anz = 0;
+ m_aHeader.db_kopf = 0;
+ m_aHeader.db_slng = 0;
+ m_aMemoHeader.db_size = 0;
+
+ String sFileName(getEntry(m_pConnection,m_Name));
+
+ INetURLObject aURL;
+ aURL.SetURL(sFileName);
+
+ OSL_ENSURE( m_pConnection->matchesExtension( aURL.getExtension() ),
+ "ODbaseTable::ODbaseTable: invalid extension!");
+ // getEntry is expected to ensure the corect file name
+
+ m_pFileStream = createStream_simpleError( sFileName, STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+ m_bWriteable = ( m_pFileStream != NULL );
+
+ if ( !m_pFileStream )
+ {
+ m_bWriteable = sal_False;
+ m_pFileStream = createStream_simpleError( sFileName, STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+ }
+
+ if(m_pFileStream)
+ {
+ readHeader();
+ if (HasMemoFields())
+ {
+ // Memo-Dateinamen bilden (.DBT):
+ // nyi: Unschoen fuer Unix und Mac!
+
+ if ( m_aHeader.db_typ == FoxProMemo || VisualFoxPro == m_aHeader.db_typ || VisualFoxProAuto == m_aHeader.db_typ ) // foxpro uses another extension
+ aURL.SetExtension(String::CreateFromAscii("fpt"));
+ else
+ aURL.SetExtension(String::CreateFromAscii("dbt"));
+
+ // Wenn die Memodatei nicht gefunden wird, werden die Daten trotzdem angezeigt
+ // allerdings koennen keine Updates durchgefuehrt werden
+ // jedoch die Operation wird ausgefuehrt
+ m_pMemoStream = createStream_simpleError( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+ if ( !m_pMemoStream )
+ {
+ m_bWriteableMemo = sal_False;
+ m_pMemoStream = createStream_simpleError( aURL.GetMainURL(INetURLObject::NO_DECODE), STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+ }
+ if (m_pMemoStream)
+ ReadMemoHeader();
+ }
+ // if(!m_pColumns && (!m_aColumns.isValid() || !m_aColumns->size()))
+ fillColumns();
+
+ UINT32 nFileSize = lcl_getFileSize(*m_pFileStream);
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+ if ( m_aHeader.db_anz == 0 && ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng) > 0) // seems to be empty or someone wrote bullshit into the dbase file
+ m_aHeader.db_anz = ((nFileSize-m_aHeader.db_kopf)/m_aHeader.db_slng);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pFileStream->SetBufferSize(nFileSize > 1000000 ? 32768 :
+ nFileSize > 100000 ? 16384 :
+ nFileSize > 10000 ? 4096 : 1024);
+
+ if (m_pMemoStream)
+ {
+ // Puffer genau auf Laenge eines Satzes stellen
+ m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ nFileSize = m_pMemoStream->Tell();
+ m_pMemoStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pMemoStream->SetBufferSize(nFileSize > 1000000 ? 32768 :
+ nFileSize > 100000 ? 16384 :
+ nFileSize > 10000 ? 4096 :
+ m_aMemoHeader.db_size);
+ }
+
+ AllocBuffer();
+ }
+}
+//------------------------------------------------------------------
+BOOL ODbaseTable::ReadMemoHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemoHeader" );
+ m_pMemoStream->SetNumberFormatInt(NUMBERFORMAT_INT_LITTLEENDIAN);
+ m_pMemoStream->RefreshBuffer(); // sicherstellen das die Kopfinformationen tatsaechlich neu gelesen werden
+ m_pMemoStream->Seek(0L);
+
+ (*m_pMemoStream) >> m_aMemoHeader.db_next;
+ switch (m_aHeader.db_typ)
+ {
+ case dBaseIIIMemo: // dBase III: feste Blockgroesse
+ case dBaseIVMemo:
+ // manchmal wird aber auch dBase3 dBase4 Memo zugeordnet
+ m_pMemoStream->Seek(20L);
+ (*m_pMemoStream) >> m_aMemoHeader.db_size;
+ if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size != 512) // 1 steht auch fuer dBase 3
+ m_aMemoHeader.db_typ = MemodBaseIV;
+ else if (m_aMemoHeader.db_size > 1 && m_aMemoHeader.db_size == 512)
+ {
+ // nun gibt es noch manche Dateien, die verwenden eine Groessenangabe,
+ // sind aber dennoch dBase Dateien
+ char sHeader[4];
+ m_pMemoStream->Seek(m_aMemoHeader.db_size);
+ m_pMemoStream->Read(sHeader,4);
+
+ if ((m_pMemoStream->GetErrorCode() != ERRCODE_NONE) || ((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08)
+ m_aMemoHeader.db_typ = MemodBaseIII;
+ else
+ m_aMemoHeader.db_typ = MemodBaseIV;
+ }
+ else
+ {
+ m_aMemoHeader.db_typ = MemodBaseIII;
+ m_aMemoHeader.db_size = 512;
+ }
+ break;
+ case VisualFoxPro:
+ case VisualFoxProAuto:
+ case FoxProMemo:
+ m_aMemoHeader.db_typ = MemoFoxPro;
+ m_pMemoStream->Seek(6L);
+ m_pMemoStream->SetNumberFormatInt(NUMBERFORMAT_INT_BIGENDIAN);
+ (*m_pMemoStream) >> m_aMemoHeader.db_size;
+ break;
+ default:
+ OSL_ENSURE( false, "ODbaseTable::ReadMemoHeader: unsupported memo type!" );
+ break;
+ }
+ return TRUE;
+}
+// -------------------------------------------------------------------------
+String ODbaseTable::getEntry(OConnection* _pConnection,const ::rtl::OUString& _sName )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getEntry" );
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XResultSet > xDir = _pConnection->getDir()->getStaticResultSet();
+ Reference< XRow> xRow(xDir,UNO_QUERY);
+ ::rtl::OUString sName;
+ ::rtl::OUString sExt;
+ INetURLObject aURL;
+ static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/"));
+ xDir->beforeFirst();
+ while(xDir->next())
+ {
+ sName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = _pConnection->getURL() + s_sSeparator + sName;
+ aURL.SetSmartURL( sUrl );
+
+ // cut the extension
+ sExt = aURL.getExtension();
+
+ // name and extension have to coincide
+ if ( _pConnection->matchesExtension( sExt ) )
+ {
+ sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString());
+ if ( sName == _sName )
+ {
+ Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY );
+ sURL = xContentAccess->queryContentIdentifierString();
+ break;
+ }
+ }
+ }
+ xDir->beforeFirst(); // move back to before first record
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT(0);
+ }
+ return sURL;
+}
+// -------------------------------------------------------------------------
+void ODbaseTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::refreshColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+ aVector.reserve(m_aColumns->get().size());
+
+ for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new ODbaseColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void ODbaseTable::refreshIndexes()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::refreshIndexes" );
+ TStringVector aVector;
+ if(m_pFileStream && (!m_pIndexes || m_pIndexes->getCount() == 0))
+ {
+ INetURLObject aURL;
+ aURL.SetURL(getEntry(m_pConnection,m_Name));
+
+ aURL.setExtension(String::CreateFromAscii("inf"));
+ Config aInfFile(aURL.getFSysPath(INetURLObject::FSYS_DETECT));
+ aInfFile.SetGroup(dBASE_III_GROUP);
+ USHORT nKeyCnt = aInfFile.GetKeyCount();
+ ByteString aKeyName;
+ ByteString aIndexName;
+
+ for (USHORT nKey = 0; nKey < nKeyCnt; nKey++)
+ {
+ // Verweist der Key auf ein Indexfile?...
+ aKeyName = aInfFile.GetKeyName( nKey );
+ //...wenn ja, Indexliste der Tabelle hinzufuegen
+ if (aKeyName.Copy(0,3) == ByteString("NDX") )
+ {
+ aIndexName = aInfFile.ReadKey(aKeyName);
+ aURL.setName(String(aIndexName,m_eEncoding));
+ try
+ {
+ Content aCnt(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+ if (aCnt.isDocument())
+ {
+ aVector.push_back(aURL.getBase());
+ }
+ }
+ catch(Exception&) // a execption is thrown when no file exists
+ {
+ }
+ }
+ }
+ }
+ if(m_pIndexes)
+ m_pIndexes->reFill(aVector);
+ else
+ m_pIndexes = new ODbaseIndexes(this,m_aMutex,aVector);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL ODbaseTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::disposing" );
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aColumns = NULL;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODbaseTable::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getTypes" );
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ // *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ aOwnTypes.push_back(::getCppuType( (const Reference< ::com::sun::star::lang::XUnoTunnel > *)0 ));
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL ODbaseTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::queryInterface" );
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ Any aRet = OTable_TYPEDEF::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > ODbaseTable::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getUnoTunnelImplementationId" );
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 ODbaseTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : ODbaseTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Bool ODbaseTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols, sal_Bool _bUseTableDefs,sal_Bool bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::fetchRow" );
+ // Einlesen der Daten
+ BOOL bIsCurRecordDeleted = ((char)m_pBuffer[0] == '*') ? TRUE : sal_False;
+
+ // only read the bookmark
+
+ // Satz als geloescht markieren
+ // rRow.setState(bIsCurRecordDeleted ? ROW_DELETED : ROW_CLEAN );
+ _rRow->setDeleted(bIsCurRecordDeleted);
+ *(_rRow->get())[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+
+ sal_Size nByteOffset = 1;
+ // Felder:
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end();
+ const sal_Size nCount = _rRow->get().size();
+ for (sal_Size i = 1; aIter != aEnd && nByteOffset <= m_nBufferSize && i < nCount;++aIter, i++)
+ {
+ // Laengen je nach Datentyp:
+ sal_Int32 nLen = 0;
+ sal_Int32 nType = 0;
+ if(_bUseTableDefs)
+ {
+ nLen = m_aPrecisions[i-1];
+ nType = m_aTypes[i-1];
+ }
+ else
+ {
+ (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
+ (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ switch(nType)
+ {
+ case DataType::INTEGER:
+ case DataType::DOUBLE:
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::BIT:
+ case DataType::LONGVARCHAR:
+ case DataType::LONGVARBINARY:
+ nLen = m_aRealFieldLengths[i-1];
+ break;
+ case DataType::DECIMAL:
+ if(_bUseTableDefs)
+ nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,m_aScales[i-1]);
+ else
+ nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,getINT32((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ break; // das Vorzeichen und das Komma
+
+ case DataType::BINARY:
+ case DataType::OTHER:
+ nByteOffset += nLen;
+ continue;
+ }
+
+ // Ist die Variable ueberhaupt gebunden?
+ if ( !(_rRow->get())[i]->isBound() )
+ {
+ // Nein - naechstes Feld.
+ nByteOffset += nLen;
+ OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!");
+ continue;
+ } // if ( !(_rRow->get())[i]->isBound() )
+ if ( ( nByteOffset + nLen) > m_nBufferSize )
+ break; // length doesn't match buffer size.
+
+ char *pData = (char *) (m_pBuffer + nByteOffset);
+
+ // (*_rRow)[i].setType(nType);
+
+ if (nType == DataType::CHAR || nType == DataType::VARCHAR)
+ {
+ char cLast = pData[nLen];
+ pData[nLen] = 0;
+ String aStr(pData,(xub_StrLen)nLen,m_eEncoding);
+ aStr.EraseTrailingChars();
+
+ if ( aStr.Len() )
+ *(_rRow->get())[i] = ::rtl::OUString(aStr);
+ else// keine StringLaenge, dann NULL
+ (_rRow->get())[i]->setNull();
+
+ pData[nLen] = cLast;
+ } // if (nType == DataType::CHAR || nType == DataType::VARCHAR)
+ else if ( DataType::TIMESTAMP == nType )
+ {
+ sal_Int32 nDate = 0,nTime = 0;
+ memcpy(&nDate, pData, 4);
+ memcpy(&nTime, pData+ 4, 4);
+ if ( !nDate && !nTime )
+ {
+ (_rRow->get())[i]->setNull();
+ }
+ else
+ {
+ ::com::sun::star::util::DateTime aDateTime;
+ lcl_CalDate(nDate,nTime,aDateTime);
+ *(_rRow->get())[i] = aDateTime;
+ }
+ }
+ else if ( DataType::INTEGER == nType )
+ {
+ sal_Int32 nValue = 0;
+ memcpy(&nValue, pData, nLen);
+ *(_rRow->get())[i] = nValue;
+ }
+ else if ( DataType::DOUBLE == nType )
+ {
+ double d = 0.0;
+ if (getBOOL((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt
+ {
+ sal_Int64 nValue = 0;
+ memcpy(&nValue, pData, nLen);
+
+ if ( m_aScales[i-1] )
+ d = (double)(nValue / pow(10.0,(int)m_aScales[i-1]));
+ else
+ d = (double)(nValue);
+ }
+ else
+ {
+ memcpy(&d, pData, nLen);
+ }
+
+ *(_rRow->get())[i] = d;
+ }
+ else
+ {
+ // Falls Nul-Zeichen im String enthalten sind, in Blanks umwandeln!
+ for (sal_Int32 k = 0; k < nLen; k++)
+ {
+ if (pData[k] == '\0')
+ pData[k] = ' ';
+ }
+
+ String aStr(pData, (xub_StrLen)nLen,m_eEncoding); // Spaces am Anfang und am Ende entfernen:
+ aStr.EraseLeadingChars();
+ aStr.EraseTrailingChars();
+
+ if (!aStr.Len())
+ {
+ nByteOffset += nLen;
+ (_rRow->get())[i]->setNull(); // keine Werte -> fertig
+ continue;
+ }
+
+ switch (nType)
+ {
+ case DataType::DATE:
+ {
+ if (aStr.Len() != nLen)
+ {
+ (_rRow->get())[i]->setNull();
+ break;
+ }
+ const sal_uInt16 nYear = (sal_uInt16)aStr.Copy( 0, 4 ).ToInt32();
+ const sal_uInt16 nMonth = (sal_uInt16)aStr.Copy( 4, 2 ).ToInt32();
+ const sal_uInt16 nDay = (sal_uInt16)aStr.Copy( 6, 2 ).ToInt32();
+
+ const ::com::sun::star::util::Date aDate(nDay,nMonth,nYear);
+ *(_rRow->get())[i] = aDate;
+ }
+ break;
+ case DataType::DECIMAL:
+ *(_rRow->get())[i] = ORowSetValue(aStr);
+ // pVal->setDouble(SdbTools::ToDouble(aStr));
+ break;
+ case DataType::BIT:
+ {
+ BOOL b;
+ switch (* ((const char *)pData))
+ {
+ case 'T':
+ case 'Y':
+ case 'J': b = TRUE; break;
+ default: b = FALSE; break;
+ }
+ *(_rRow->get())[i] = b;
+ // pVal->setDouble(b);
+ }
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BINARY:
+ case DataType::LONGVARCHAR:
+ {
+ const long nBlockNo = aStr.ToInt32(); // Blocknummer lesen
+ if (nBlockNo > 0 && m_pMemoStream) // Daten aus Memo-Datei lesen, nur wenn
+ {
+ if ( !ReadMemo(nBlockNo, (_rRow->get())[i]->get()) )
+ break;
+ }
+ else
+ (_rRow->get())[i]->setNull();
+ } break;
+ default:
+ OSL_ASSERT("Falscher Type");
+ }
+ (_rRow->get())[i]->setTypeKind(nType);
+ }
+
+ nByteOffset += nLen;
+ OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!");
+ }
+ return sal_True;
+}
+//------------------------------------------------------------------
+// -------------------------------------------------------------------------
+void ODbaseTable::FileClose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::FileClose" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ // falls noch nicht alles geschrieben wurde
+ if (m_pMemoStream && m_pMemoStream->IsWritable())
+ m_pMemoStream->Flush();
+
+ delete m_pMemoStream;
+ m_pMemoStream = NULL;
+
+ ODbaseTable_BASE::FileClose();
+}
+// -------------------------------------------------------------------------
+BOOL ODbaseTable::CreateImpl()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateImpl" );
+ OSL_ENSURE(!m_pFileStream, "SequenceError");
+
+ if ( m_pConnection->isCheckEnabled() && ::dbtools::convertName2SQLName(m_Name,::rtl::OUString()) != m_Name )
+ {
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_SQL_NAME_ERROR,
+ "$name$", m_Name
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String aName = getEntry(m_pConnection,m_Name);
+ if(!aName.Len())
+ {
+ ::rtl::OUString aIdent = m_pConnection->getContent()->getIdentifier()->getContentIdentifier();
+ if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) )
+ aIdent += ::rtl::OUString::createFromAscii("/");
+ aIdent += m_Name;
+ aName = aIdent.getStr();
+ }
+ aURL.SetURL(aName);
+
+ if ( !m_pConnection->matchesExtension( aURL.getExtension() ) )
+ aURL.setExtension(m_pConnection->getExtension());
+
+ try
+ {
+ Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+ if (aContent.isDocument())
+ {
+ // Hack fuer Bug #30609 , nur wenn das File existiert und die Laenge > 0 gibt es einen Fehler
+ SvStream* pFileStream = createStream_simpleError( aURL.GetMainURL(INetURLObject::NO_DECODE),STREAM_READ);
+
+ if (pFileStream && pFileStream->Seek(STREAM_SEEK_TO_END))
+ {
+ // aStatus.SetError(ERRCODE_IO_ALREADYEXISTS,TABLE,aFile.GetFull());
+ return sal_False;
+ }
+ delete pFileStream;
+ }
+ }
+ catch(Exception&) // a execption is thrown when no file exists
+ {
+ }
+
+ BOOL bMemoFile = sal_False;
+
+ sal_Bool bOk = CreateFile(aURL, bMemoFile);
+
+ FileClose();
+
+ if (!bOk)
+ {
+ try
+ {
+ Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+ aContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) );
+ }
+ catch(Exception&) // a execption is thrown when no file exists
+ {
+ }
+ return sal_False;
+ }
+
+ if (bMemoFile)
+ {
+ String aExt = aURL.getExtension();
+ aURL.setExtension(String::CreateFromAscii("dbt")); // extension for memo file
+ Content aMemo1Content(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+
+ sal_Bool bMemoAlreadyExists = sal_False;
+ try
+ {
+ bMemoAlreadyExists = aMemo1Content.isDocument();
+ }
+ catch(Exception&) // a execption is thrown when no file exists
+ {
+ }
+ if (bMemoAlreadyExists)
+ {
+ // aStatus.SetError(ERRCODE_IO_ALREADYEXISTS,MEMO,aFile.GetFull());
+ aURL.setExtension(aExt); // kill dbf file
+ try
+ {
+ Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+ aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) );
+ }
+ catch(const Exception&)
+ {
+
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COULD_NOT_DELETE_FILE,
+ "$name$", aName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ }
+ if (!CreateMemoFile(aURL))
+ {
+ aURL.setExtension(aExt); // kill dbf file
+ Content aMemoContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+ aMemoContent.executeCommand( rtl::OUString::createFromAscii( "delete" ),bool2any( sal_True ) );
+ return sal_False;
+ }
+ m_aHeader.db_typ = dBaseIIIMemo;
+ }
+ else
+ m_aHeader.db_typ = dBaseIII;
+
+ return TRUE;
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::throwInvalidColumnType(const sal_uInt16 _nErrorId,const ::rtl::OUString& _sColumnName)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::throwInvalidColumnType" );
+ try
+ {
+ // we have to drop the file because it is corrupted now
+ DropImpl();
+ }
+ catch(const Exception&)
+ {
+ }
+
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ _nErrorId,
+ "$columnname$", _sColumnName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+}
+//------------------------------------------------------------------
+// erzeugt grundsaetzlich dBase IV Datei Format
+BOOL ODbaseTable::CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateFile" );
+ bCreateMemo = sal_False;
+ Date aDate; // aktuelles Datum
+
+ m_pFileStream = createStream_simpleError( aFile.GetMainURL(INetURLObject::NO_DECODE),STREAM_READWRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC );
+
+ if (!m_pFileStream)
+ return sal_False;
+
+ BYTE nDbaseType = dBaseIII;
+ Reference<XIndexAccess> xColumns(getColumns(),UNO_QUERY);
+ Reference<XPropertySet> xCol;
+ const ::rtl::OUString sPropType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE);
+
+ try
+ {
+ const sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ xColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"This should be a column!");
+
+ switch (getINT32(xCol->getPropertyValue(sPropType)))
+ {
+ case DataType::DOUBLE:
+ case DataType::INTEGER:
+ case DataType::TIMESTAMP:
+ case DataType::LONGVARBINARY:
+ nDbaseType = VisualFoxPro;
+ i = nCount; // no more columns need to be checked
+ break;
+ } // switch (getINT32(xCol->getPropertyValue(sPropType)))
+ }
+ }
+ catch ( const Exception& e )
+ {
+ (void)e;
+
+ try
+ {
+ // we have to drop the file because it is corrupted now
+ DropImpl();
+ }
+ catch(const Exception&) { }
+ throw;
+ }
+
+ char aBuffer[21]; // write buffer
+ memset(aBuffer,0,sizeof(aBuffer));
+
+ m_pFileStream->Seek(0L);
+ (*m_pFileStream) << (BYTE) nDbaseType; // dBase format
+ (*m_pFileStream) << (BYTE) (aDate.GetYear() % 100); // aktuelles Datum
+
+
+ (*m_pFileStream) << (BYTE) aDate.GetMonth();
+ (*m_pFileStream) << (BYTE) aDate.GetDay();
+ (*m_pFileStream) << 0L; // Anzahl der Datensaetze
+ (*m_pFileStream) << (USHORT)((m_pColumns->getCount()+1) * 32 + 1); // Kopfinformationen,
+ // pColumns erhaelt immer eine Spalte mehr
+ (*m_pFileStream) << (USHORT) 0; // Satzlaenge wird spaeter bestimmt
+ m_pFileStream->Write(aBuffer, 20);
+
+ USHORT nRecLength = 1; // Laenge 1 fuer deleted flag
+ sal_Int32 nMaxFieldLength = m_pConnection->getMetaData()->getMaxColumnNameLength();
+ ::rtl::OUString aName;
+ const ::rtl::OUString sPropName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ const ::rtl::OUString sPropPrec = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION);
+ const ::rtl::OUString sPropScale = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE);
+
+ try
+ {
+ const sal_Int32 nCount = xColumns->getCount();
+ for(sal_Int32 i=0;i<nCount;++i)
+ {
+ xColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"This should be a column!");
+
+ char cTyp( 'C' );
+
+ xCol->getPropertyValue(sPropName) >>= aName;
+
+ ::rtl::OString aCol;
+ if ( DBTypeConversion::convertUnicodeString( aName, aCol, m_eEncoding ) > nMaxFieldLength)
+ {
+ throwInvalidColumnType( STR_INVALID_COLUMN_NAME_LENGTH, aName );
+ }
+
+ (*m_pFileStream) << aCol.getStr();
+ m_pFileStream->Write(aBuffer, 11 - aCol.getLength());
+
+ sal_Int32 nPrecision = 0;
+ xCol->getPropertyValue(sPropPrec) >>= nPrecision;
+ sal_Int32 nScale = 0;
+ xCol->getPropertyValue(sPropScale) >>= nScale;
+
+ bool bBinary = false;
+
+ switch (getINT32(xCol->getPropertyValue(sPropType)))
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ cTyp = 'C';
+ break;
+ case DataType::DOUBLE:
+ if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt
+ cTyp = 'Y';
+ else
+ cTyp = 'B';
+ break;
+ case DataType::INTEGER:
+ cTyp = 'I';
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::BIGINT:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ cTyp = 'N'; // nur dBase 3 format
+ break;
+ case DataType::TIMESTAMP:
+ cTyp = 'T';
+ break;
+ case DataType::DATE:
+ cTyp = 'D';
+ break;
+ case DataType::BIT:
+ cTyp = 'L';
+ break;
+ case DataType::LONGVARBINARY:
+ bBinary = true;
+ // run through
+ case DataType::LONGVARCHAR:
+ cTyp = 'M';
+ break;
+ default:
+ {
+ throwInvalidColumnType(STR_INVALID_COLUMN_TYPE, aName);
+ }
+ }
+
+ (*m_pFileStream) << cTyp;
+ if ( nDbaseType == VisualFoxPro )
+ (*m_pFileStream) << (nRecLength-1);
+ else
+ m_pFileStream->Write(aBuffer, 4);
+
+ switch(cTyp)
+ {
+ case 'C':
+ OSL_ENSURE(nPrecision < 255, "ODbaseTable::Create: Column zu lang!");
+ if (nPrecision > 254)
+ {
+ throwInvalidColumnType(STR_INVALID_COLUMN_PRECISION, aName);
+ }
+ (*m_pFileStream) << (BYTE) Min((ULONG)nPrecision, 255UL); //Feldlaenge
+ nRecLength = nRecLength + (USHORT)::std::min((USHORT)nPrecision, (USHORT)255UL);
+ (*m_pFileStream) << (BYTE)0; //Nachkommastellen
+ break;
+ case 'F':
+ case 'N':
+ OSL_ENSURE(nPrecision >= nScale,
+ "ODbaseTable::Create: Feldlaenge muss groesser Nachkommastellen sein!");
+ if (nPrecision < nScale)
+ {
+ throwInvalidColumnType(STR_INVALID_PRECISION_SCALE, aName);
+ }
+ if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt
+ {
+ (*m_pFileStream) << (BYTE)10; // Standard Laenge
+ (*m_pFileStream) << (BYTE)4;
+ nRecLength += 10;
+ }
+ else
+ {
+ sal_Int32 nPrec = SvDbaseConverter::ConvertPrecisionToDbase(nPrecision,nScale);
+
+ (*m_pFileStream) << (BYTE)( nPrec);
+ (*m_pFileStream) << (BYTE)nScale;
+ nRecLength += (USHORT)nPrec;
+ }
+ break;
+ case 'L':
+ (*m_pFileStream) << (BYTE)1;
+ (*m_pFileStream) << (BYTE)0;
+ ++nRecLength;
+ break;
+ case 'I':
+ (*m_pFileStream) << (BYTE)4;
+ (*m_pFileStream) << (BYTE)0;
+ nRecLength += 4;
+ break;
+ case 'Y':
+ case 'B':
+ case 'T':
+ case 'D':
+ (*m_pFileStream) << (BYTE)8;
+ (*m_pFileStream) << (BYTE)0;
+ nRecLength += 8;
+ break;
+ case 'M':
+ bCreateMemo = TRUE;
+ (*m_pFileStream) << (BYTE)10;
+ (*m_pFileStream) << (BYTE)0;
+ nRecLength += 10;
+ if ( bBinary )
+ aBuffer[0] = 0x06;
+ break;
+ default:
+ throwInvalidColumnType(STR_INVALID_COLUMN_TYPE, aName);
+ }
+ m_pFileStream->Write(aBuffer, 14);
+ aBuffer[0] = 0x00;
+ }
+
+ (*m_pFileStream) << (BYTE)FIELD_DESCRIPTOR_TERMINATOR; // kopf ende
+ (*m_pFileStream) << (char)DBF_EOL;
+ m_pFileStream->Seek(10L);
+ (*m_pFileStream) << nRecLength; // Satzlaenge nachtraeglich eintragen
+
+ if (bCreateMemo)
+ {
+ m_pFileStream->Seek(0L);
+ if (nDbaseType == VisualFoxPro)
+ (*m_pFileStream) << (BYTE) FoxProMemo;
+ else
+ (*m_pFileStream) << (BYTE) dBaseIIIMemo;
+ } // if (bCreateMemo)
+ }
+ catch ( const Exception& e )
+ {
+ (void)e;
+
+ try
+ {
+ // we have to drop the file because it is corrupted now
+ DropImpl();
+ }
+ catch(const Exception&) { }
+ throw;
+ }
+ return TRUE;
+}
+
+//------------------------------------------------------------------
+// erzeugt grundsaetzlich dBase III Datei Format
+BOOL ODbaseTable::CreateMemoFile(const INetURLObject& aFile)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::CreateMemoFile" );
+ // Makro zum Filehandling fuers Erzeugen von Tabellen
+ m_pMemoStream = createStream_simpleError( aFile.GetMainURL(INetURLObject::NO_DECODE),STREAM_READWRITE | STREAM_SHARE_DENYWRITE);
+
+ if (!m_pMemoStream)
+ return sal_False;
+
+ char aBuffer[512]; // write buffer
+ memset(aBuffer,0,sizeof(aBuffer));
+
+#ifdef WIN
+ m_pMemoStream->Seek(0L);
+ for (UINT16 i = 0; i < 512; i++)
+ {
+ (*m_pMemoStream) << BYTE(0);
+ }
+#else
+ m_pMemoStream->SetFiller('\0');
+ m_pMemoStream->SetStreamSize(512);
+#endif
+
+ m_pMemoStream->Seek(0L);
+ (*m_pMemoStream) << long(1); // Zeiger auf ersten freien Block
+
+ m_pMemoStream->Flush();
+ delete m_pMemoStream;
+ m_pMemoStream = NULL;
+ return TRUE;
+}
+//------------------------------------------------------------------
+BOOL ODbaseTable::Drop_Static(const ::rtl::OUString& _sUrl,sal_Bool _bHasMemoFields,OCollection* _pIndexes )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::Drop_Static" );
+ INetURLObject aURL;
+ aURL.SetURL(_sUrl);
+
+ BOOL bDropped = ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE));
+
+ if(bDropped)
+ {
+ if (_bHasMemoFields)
+ { // delete the memo fields
+ aURL.setExtension(String::CreateFromAscii("dbt"));
+ bDropped = ::utl::UCBContentHelper::Kill(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ }
+
+ if(bDropped)
+ {
+ if(_pIndexes)
+ {
+ try
+ {
+ sal_Int32 i = _pIndexes->getCount();
+ while (i)
+ {
+ _pIndexes->dropByIndex(--i);
+ }
+ }
+ catch(SQLException)
+ {
+ }
+ }
+ // aFile.SetBase(m_Name);
+ aURL.setExtension(String::CreateFromAscii("inf"));
+
+ // as the inf file does not necessarily exist, we aren't allowed to use UCBContentHelper::Kill
+ // 89711 - 16.07.2001 - frank.schoenheit@sun.com
+ try
+ {
+ ::ucbhelper::Content aDeleteContent( aURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment > () );
+ aDeleteContent.executeCommand( ::rtl::OUString::createFromAscii( "delete" ), makeAny( sal_Bool( sal_True ) ) );
+ }
+ catch(Exception&)
+ {
+ // silently ignore this ....
+ }
+ }
+ }
+ return bDropped;
+}
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::DropImpl()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::DropImpl" );
+ FileClose();
+
+ if(!m_pIndexes)
+ refreshIndexes(); // look for indexes which must be deleted as well
+
+ BOOL bDropped = Drop_Static(getEntry(m_pConnection,m_Name),HasMemoFields(),m_pIndexes);
+ if(!bDropped)
+ {// we couldn't drop the table so we have to reopen it
+ construct();
+ if(m_pColumns)
+ m_pColumns->refresh();
+ }
+ return bDropped;
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseTable::InsertRow(OValueRefVector& rRow, BOOL bFlush,const Reference<XIndexAccess>& _xCols)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::InsertRow" );
+ // Buffer mit Leerzeichen fuellen
+ AllocBuffer();
+ memset(m_pBuffer, 0, m_aHeader.db_slng);
+ m_pBuffer[0] = ' ';
+
+ // Gesamte neue Row uebernehmen:
+ // ... und am Ende als neuen Record hinzufuegen:
+ UINT32 nTempPos = m_nFilePos,
+ nFileSize = 0,
+ nMemoFileSize = 0;
+
+ m_nFilePos = (ULONG)m_aHeader.db_anz + 1;
+ BOOL bInsertRow = UpdateBuffer( rRow, NULL, _xCols );
+ if ( bInsertRow )
+ {
+ nFileSize = lcl_getFileSize(*m_pFileStream);
+
+ if (HasMemoFields() && m_pMemoStream)
+ {
+ m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ nMemoFileSize = m_pMemoStream->Tell();
+ }
+
+ if (!WriteBuffer())
+ {
+ m_pFileStream->SetStreamSize(nFileSize); // alte Groesse restaurieren
+
+ if (HasMemoFields() && m_pMemoStream)
+ m_pMemoStream->SetStreamSize(nMemoFileSize); // alte Groesse restaurieren
+ m_nFilePos = nTempPos; // Fileposition restaurieren
+ }
+ else
+ {
+ (*m_pFileStream) << (char)DBF_EOL; // write EOL
+ // Anzahl Datensaetze im Header erhoehen:
+ m_pFileStream->Seek( 4L );
+ (*m_pFileStream) << (m_aHeader.db_anz + 1);
+
+ // beim AppendOnly kein Flush!
+ if (bFlush)
+ m_pFileStream->Flush();
+
+ // bei Erfolg # erhoehen
+ m_aHeader.db_anz++;
+ *rRow.get()[0] = m_nFilePos; // BOOKmark setzen
+ m_nFilePos = nTempPos;
+ }
+ }
+ else
+ m_nFilePos = nTempPos;
+
+ return bInsertRow;
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseTable::UpdateRow(OValueRefVector& rRow, OValueRefRow& pOrgRow,const Reference<XIndexAccess>& _xCols)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateRow" );
+ // Buffer mit Leerzeichen fuellen
+ AllocBuffer();
+
+ // Auf gewuenschten Record positionieren:
+ long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng;
+ m_pFileStream->Seek(nPos);
+ m_pFileStream->Read((char*)m_pBuffer, m_aHeader.db_slng);
+
+ UINT32 nMemoFileSize( 0 );
+ if (HasMemoFields() && m_pMemoStream)
+ {
+ m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ nMemoFileSize = m_pMemoStream->Tell();
+ }
+ if (!UpdateBuffer(rRow, pOrgRow,_xCols) || !WriteBuffer())
+ {
+ if (HasMemoFields() && m_pMemoStream)
+ m_pMemoStream->SetStreamSize(nMemoFileSize); // alte Groesse restaurieren
+ }
+ else
+ {
+ m_pFileStream->Flush();
+ }
+ return sal_True;
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseTable::DeleteRow(const OSQLColumns& _rCols)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::DeleteRow" );
+ // Einfach das Loesch-Flag setzen (egal, ob es schon gesetzt war
+ // oder nicht):
+ // Auf gewuenschten Record positionieren:
+ long nFilePos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng;
+ m_pFileStream->Seek(nFilePos);
+
+ OValueRefRow aRow = new OValueRefVector(_rCols.get().size());
+
+ if (!fetchRow(aRow,_rCols,TRUE,TRUE))
+ return sal_False;
+
+ Reference<XPropertySet> xCol;
+ ::rtl::OUString aColName;
+ ::comphelper::UStringMixEqual aCase(isCaseSensitive());
+ for (USHORT i = 0; i < m_pColumns->getCount(); i++)
+ {
+ Reference<XPropertySet> xIndex = isUniqueByColumnName(i);
+ if (xIndex.is())
+ {
+ ::cppu::extractInterface(xCol,m_pColumns->getByIndex(i));
+ OSL_ENSURE(xCol.is(),"ODbaseTable::DeleteRow column is null!");
+ if(xCol.is())
+ {
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+
+ Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY);
+ OSL_ENSURE(xTunnel.is(),"No TunnelImplementation!");
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ OSL_ENSURE(pIndex,"ODbaseTable::DeleteRow: No Index returned!");
+
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ sal_Int32 nPos = 1;
+ for(;aIter != _rCols.get().end();++aIter,++nPos)
+ {
+ if(aCase(getString((*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME))),aColName))
+ break;
+ }
+ if (aIter == _rCols.get().end())
+ continue;
+
+ pIndex->Delete(m_nFilePos,*(aRow->get())[nPos]);
+ }
+ }
+ }
+
+ m_pFileStream->Seek(nFilePos);
+ (*m_pFileStream) << (BYTE)'*'; // mark the row in the table as deleted
+ m_pFileStream->Flush();
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+Reference<XPropertySet> ODbaseTable::isUniqueByColumnName(sal_Int32 _nColumnPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::isUniqueByColumnName" );
+ if(!m_pIndexes)
+ refreshIndexes();
+ if(m_pIndexes->hasElements())
+ {
+ Reference<XPropertySet> xCol;
+ m_pColumns->getByIndex(_nColumnPos) >>= xCol;
+ OSL_ENSURE(xCol.is(),"ODbaseTable::isUniqueByColumnName column is null!");
+ ::rtl::OUString sColName;
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sColName;
+
+ Reference<XPropertySet> xIndex;
+ for(sal_Int32 i=0;i<m_pIndexes->getCount();++i)
+ {
+ ::cppu::extractInterface(xIndex,m_pIndexes->getByIndex(i));
+ if(xIndex.is() && getBOOL(xIndex->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISUNIQUE))))
+ {
+ Reference<XNameAccess> xCols(Reference<XColumnsSupplier>(xIndex,UNO_QUERY)->getColumns());
+ if(xCols->hasByName(sColName))
+ return xIndex;
+
+ }
+ }
+ }
+ return Reference<XPropertySet>();
+}
+//------------------------------------------------------------------
+double toDouble(const ByteString& rString)
+{
+ return ::rtl::math::stringToDouble( rString, '.', ',', NULL, NULL );
+}
+
+//------------------------------------------------------------------
+BOOL ODbaseTable::UpdateBuffer(OValueRefVector& rRow, OValueRefRow pOrgRow,const Reference<XIndexAccess>& _xCols)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::UpdateBuffer" );
+ OSL_ENSURE(m_pBuffer,"Buffer is NULL!");
+ if ( !m_pBuffer )
+ return FALSE;
+ sal_Int32 nByteOffset = 1;
+
+ // Felder aktualisieren:
+ Reference<XPropertySet> xCol;
+ Reference<XPropertySet> xIndex;
+ USHORT i;
+ ::rtl::OUString aColName;
+ const sal_Int32 nColumnCount = m_pColumns->getCount();
+ ::std::vector< Reference<XPropertySet> > aIndexedCols(nColumnCount);
+
+ ::comphelper::UStringMixEqual aCase(isCaseSensitive());
+
+ Reference<XIndexAccess> xColumns = m_pColumns;
+ // first search a key that exist already in the table
+ for (i = 0; i < nColumnCount; ++i)
+ {
+ sal_Int32 nPos = i;
+ if(_xCols != xColumns)
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+
+ for(nPos = 0;nPos<_xCols->getCount();++nPos)
+ {
+ Reference<XPropertySet> xFindCol;
+ ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos));
+ OSL_ENSURE(xFindCol.is(),"ODbaseTable::UpdateBuffer column is null!");
+ if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName))
+ break;
+ }
+ if (nPos >= _xCols->getCount())
+ continue;
+ }
+
+ ++nPos;
+ xIndex = isUniqueByColumnName(i);
+ aIndexedCols[i] = xIndex;
+ if (xIndex.is())
+ {
+ // first check if the value is different to the old one and when if it conform to the index
+ if(pOrgRow.isValid() && (rRow.get()[nPos]->getValue().isNull() || rRow.get()[nPos] == (pOrgRow->get())[nPos]))
+ continue;
+ else
+ {
+ // ODbVariantRef xVar = (pVal == NULL) ? new ODbVariant() : pVal;
+ Reference<XUnoTunnel> xTunnel(xIndex,UNO_QUERY);
+ OSL_ENSURE(xTunnel.is(),"No TunnelImplementation!");
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ OSL_ENSURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!");
+
+ if (pIndex->Find(0,*rRow.get()[nPos]))
+ {
+ // es existiert kein eindeutiger Wert
+ if ( !aColName.getLength() )
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+ xCol.clear();
+ } // if ( !aColName.getLength() )
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_DUPLICATE_VALUE_IN_COLUMN
+ ,"$columnname$", aColName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ }
+ }
+ }
+
+ // when we are here there is no double key in the table
+
+ for (i = 0; i < nColumnCount && nByteOffset <= m_nBufferSize ; ++i)
+ {
+ // Laengen je nach Datentyp:
+ OSL_ENSURE(i < m_aPrecisions.size(),"Illegal index!");
+ sal_Int32 nLen = 0;
+ sal_Int32 nType = 0;
+ sal_Int32 nScale = 0;
+ if ( i < m_aPrecisions.size() )
+ {
+ nLen = m_aPrecisions[i];
+ nType = m_aTypes[i];
+ nScale = m_aScales[i];
+ }
+ else
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ if ( xCol.is() )
+ {
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
+ }
+ }
+
+ bool bSetZero = false;
+ switch (nType)
+ {
+ case DataType::INTEGER:
+ case DataType::DOUBLE:
+ case DataType::TIMESTAMP:
+ bSetZero = true;
+ case DataType::LONGVARBINARY:
+ case DataType::DATE:
+ case DataType::BIT:
+ case DataType::LONGVARCHAR:
+ nLen = m_aRealFieldLengths[i];
+ break;
+ case DataType::DECIMAL:
+ nLen = SvDbaseConverter::ConvertPrecisionToDbase(nLen,nScale);
+ break; // das Vorzeichen und das Komma
+ default:
+ break;
+
+ } // switch (nType)
+
+ sal_Int32 nPos = i;
+ if(_xCols != xColumns)
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+ for(nPos = 0;nPos<_xCols->getCount();++nPos)
+ {
+ Reference<XPropertySet> xFindCol;
+ ::cppu::extractInterface(xFindCol,_xCols->getByIndex(nPos));
+ if(aCase(getString(xFindCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME))),aColName))
+ break;
+ }
+ if (nPos >= _xCols->getCount())
+ {
+ nByteOffset += nLen;
+ continue;
+ }
+ }
+
+
+
+ ++nPos; // the row values start at 1
+ // Ist die Variable ueberhaupt gebunden?
+ if ( !rRow.get()[nPos]->isBound() )
+ {
+ // Nein - naechstes Feld.
+ nByteOffset += nLen;
+ continue;
+ }
+ if (aIndexedCols[i].is())
+ {
+ Reference<XUnoTunnel> xTunnel(aIndexedCols[i],UNO_QUERY);
+ OSL_ENSURE(xTunnel.is(),"No TunnelImplementation!");
+ ODbaseIndex* pIndex = reinterpret_cast< ODbaseIndex* >( xTunnel->getSomething(ODbaseIndex::getUnoTunnelImplementationId()) );
+ OSL_ENSURE(pIndex,"ODbaseTable::UpdateBuffer: No Index returned!");
+ // Update !!
+ if (pOrgRow.isValid() && !rRow.get()[nPos]->getValue().isNull() )//&& pVal->isModified())
+ pIndex->Update(m_nFilePos,*(pOrgRow->get())[nPos],*rRow.get()[nPos]);
+ else
+ pIndex->Insert(m_nFilePos,*rRow.get()[nPos]);
+ }
+
+ char* pData = (char *)(m_pBuffer + nByteOffset);
+ if (rRow.get()[nPos]->getValue().isNull())
+ {
+ if ( bSetZero )
+ memset(pData,0,nLen); // Zuruecksetzen auf NULL
+ else
+ memset(pData,' ',nLen); // Zuruecksetzen auf NULL
+ nByteOffset += nLen;
+ OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!");
+ continue;
+ }
+
+ sal_Bool bHadError = sal_False;
+ try
+ {
+ switch (nType)
+ {
+ case DataType::TIMESTAMP:
+ {
+ sal_Int32 nJulianDate = 0, nJulianTime = 0;
+ lcl_CalcJulDate(nJulianDate,nJulianTime,rRow.get()[nPos]->getValue());
+ // Genau 8 Byte kopieren:
+ memcpy(pData,&nJulianDate,4);
+ memcpy(pData+4,&nJulianTime,4);
+ }
+ break;
+ case DataType::DATE:
+ {
+ ::com::sun::star::util::Date aDate;
+ if(rRow.get()[nPos]->getValue().getTypeKind() == DataType::DOUBLE)
+ aDate = ::dbtools::DBTypeConversion::toDate(rRow.get()[nPos]->getValue().getDouble());
+ else
+ aDate = rRow.get()[nPos]->getValue();
+ char s[9];
+ snprintf(s,
+ sizeof(s),
+ "%04d%02d%02d",
+ (int)aDate.Year,
+ (int)aDate.Month,
+ (int)aDate.Day);
+
+ // Genau 8 Byte kopieren:
+ strncpy(pData,s,sizeof s - 1);
+ } break;
+ case DataType::INTEGER:
+ {
+ sal_Int32 nValue = rRow.get()[nPos]->getValue();
+ memcpy(pData,&nValue,nLen);
+ }
+ break;
+ case DataType::DOUBLE:
+ {
+ const double d = rRow.get()[nPos]->getValue();
+ m_pColumns->getByIndex(i) >>= xCol;
+
+ if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt
+ {
+ sal_Int64 nValue = 0;
+ if ( m_aScales[i] )
+ nValue = (sal_Int64)(d * pow(10.0,(int)m_aScales[i]));
+ else
+ nValue = (sal_Int64)(d);
+ memcpy(pData,&nValue,nLen);
+ } // if (getBOOL(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)))) // Currency wird gesondert behandelt
+ else
+ memcpy(pData,&d,nLen);
+ }
+ break;
+ case DataType::DECIMAL:
+ {
+ memset(pData,' ',nLen); // Zuruecksetzen auf NULL
+
+ const double n = rRow.get()[nPos]->getValue();
+
+ // ein const_cast, da GetFormatPrecision am SvNumberFormat nicht const ist, obwohl es das eigentlich
+ // sein koennte und muesste
+
+ const ByteString aDefaultValue( ::rtl::math::doubleToString( n, rtl_math_StringFormat_F, nScale, '.', NULL, 0));
+ BOOL bValidLength = aDefaultValue.Len() <= nLen;
+ if ( bValidLength )
+ {
+ strncpy(pData,aDefaultValue.GetBuffer(),nLen);
+ // write the resulting double back
+ *rRow.get()[nPos] = toDouble(aDefaultValue);
+ }
+ else
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE(xCol.is(),"ODbaseTable::UpdateBuffer column is null!");
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+ ::std::list< ::std::pair<const sal_Char* , ::rtl::OUString > > aStringToSubstitutes;
+ aStringToSubstitutes.push_back(::std::pair<const sal_Char* , ::rtl::OUString >("$columnname$", aColName));
+ aStringToSubstitutes.push_back(::std::pair<const sal_Char* , ::rtl::OUString >("$precision$", String::CreateFromInt32(nLen)));
+ aStringToSubstitutes.push_back(::std::pair<const sal_Char* , ::rtl::OUString >("$scale$", String::CreateFromInt32(nScale)));
+ aStringToSubstitutes.push_back(::std::pair<const sal_Char* , ::rtl::OUString >("$value$", ::rtl::OStringToOUString(aDefaultValue,RTL_TEXTENCODING_UTF8)));
+
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMN_DECIMAL_VALUE
+ ,aStringToSubstitutes
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ } break;
+ case DataType::BIT:
+ *pData = rRow.get()[nPos]->getValue().getBool() ? 'T' : 'F';
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::LONGVARCHAR:
+ {
+ char cNext = pData[nLen]; // merken und temporaer durch 0 ersetzen
+ pData[nLen] = '\0'; // das geht, da der Puffer immer ein Zeichen groesser ist ...
+
+ ULONG nBlockNo = strtol((const char *)pData,NULL,10); // Blocknummer lesen
+
+ // Naechstes Anfangszeichen wieder restaurieren:
+ pData[nLen] = cNext;
+ if (!m_pMemoStream || !WriteMemo(rRow.get()[nPos]->get(), nBlockNo))
+ break;
+
+ ByteString aStr;
+ ByteString aBlock(ByteString::CreateFromInt32(nBlockNo));
+ aStr.Expand(static_cast<sal_uInt16>(nLen - aBlock.Len()), '0' );
+ aStr += aBlock;
+ // Zeichen kopieren:
+ memset(pData,' ',nLen); // Zuruecksetzen auf NULL
+ memcpy(pData, aStr.GetBuffer(), nLen);
+ } break;
+ default:
+ {
+ memset(pData,' ',nLen); // Zuruecksetzen auf NULL
+
+ ::rtl::OUString sStringToWrite( rRow.get()[nPos]->getValue().getString() );
+
+ // convert the string, using the connection's encoding
+ ::rtl::OString sEncoded;
+
+ DBTypeConversion::convertUnicodeStringToLength( sStringToWrite, sEncoded, nLen, m_eEncoding );
+ memcpy( pData, sEncoded.getStr(), sEncoded.getLength() );
+
+ }
+ break;
+ }
+ }
+ catch( SQLException& )
+ {
+ throw;
+ }
+ catch ( Exception& ) { bHadError = sal_True; }
+
+ if ( bHadError )
+ {
+ m_pColumns->getByIndex(i) >>= xCol;
+ OSL_ENSURE( xCol.is(), "ODbaseTable::UpdateBuffer column is null!" );
+ if ( xCol.is() )
+ xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMN_VALUE,
+ "$columnname$", aColName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ // Und weiter ...
+ nByteOffset += nLen;
+ OSL_ENSURE( nByteOffset <= m_nBufferSize ,"ByteOffset > m_nBufferSize!");
+ }
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::WriteMemo(ORowSetValue& aVariable, ULONG& rBlockNr)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteMemo" );
+ // wird die BlockNr 0 vorgegeben, wird der block ans Ende gehaengt
+ ULONG nSize = 0;
+ ::rtl::OString aStr;
+ ::com::sun::star::uno::Sequence<sal_Int8> aValue;
+ BYTE nHeader[4];
+ const bool bBinary = aVariable.getTypeKind() == DataType::LONGVARBINARY && m_aMemoHeader.db_typ == MemoFoxPro;
+ if ( bBinary )
+ {
+ aValue = aVariable.getSequence();
+ nSize = aValue.getLength();
+ }
+ else
+ {
+ nSize = DBTypeConversion::convertUnicodeString( aVariable.getString(), aStr, m_eEncoding );
+ }
+
+ // Anhaengen oder ueberschreiben
+ BOOL bAppend = rBlockNr == 0;
+
+ if (!bAppend)
+ {
+ switch (m_aMemoHeader.db_typ)
+ {
+ case MemodBaseIII: // dBase III-Memofeld, endet mit 2 * Ctrl-Z
+ bAppend = nSize > (512 - 2);
+ break;
+ case MemoFoxPro:
+ case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe
+ {
+ char sHeader[4];
+ m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size);
+ m_pMemoStream->SeekRel(4L);
+ m_pMemoStream->Read(sHeader,4);
+
+ ULONG nOldSize;
+ if (m_aMemoHeader.db_typ == MemoFoxPro)
+ nOldSize = ((((unsigned char)sHeader[0]) * 256 +
+ (unsigned char)sHeader[1]) * 256 +
+ (unsigned char)sHeader[2]) * 256 +
+ (unsigned char)sHeader[3];
+ else
+ nOldSize = ((((unsigned char)sHeader[3]) * 256 +
+ (unsigned char)sHeader[2]) * 256 +
+ (unsigned char)sHeader[1]) * 256 +
+ (unsigned char)sHeader[0] - 8;
+
+ // passt die neue Laenge in die belegten Bloecke
+ ULONG nUsedBlocks = ((nSize + 8) / m_aMemoHeader.db_size) + (((nSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0),
+ nOldUsedBlocks = ((nOldSize + 8) / m_aMemoHeader.db_size) + (((nOldSize + 8) % m_aMemoHeader.db_size > 0) ? 1 : 0);
+ bAppend = nUsedBlocks > nOldUsedBlocks;
+ }
+ }
+ }
+
+ if (bAppend)
+ {
+ ULONG nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ // letzten block auffuellen
+ rBlockNr = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0);
+
+ m_pMemoStream->SetStreamSize(rBlockNr * m_aMemoHeader.db_size);
+ m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ }
+ else
+ {
+ m_pMemoStream->Seek(rBlockNr * m_aMemoHeader.db_size);
+ }
+
+ switch (m_aMemoHeader.db_typ)
+ {
+ case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z
+ {
+ const char cEOF = (char) DBF_EOL;
+ nSize++;
+ m_pMemoStream->Write( aStr.getStr(), aStr.getLength() );
+ (*m_pMemoStream) << cEOF << cEOF;
+ } break;
+ case MemoFoxPro:
+ case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe
+ {
+ if ( MemodBaseIV == m_aMemoHeader.db_typ )
+ (*m_pMemoStream) << (BYTE)0xFF
+ << (BYTE)0xFF
+ << (BYTE)0x08;
+ else
+ (*m_pMemoStream) << (BYTE)0x00
+ << (BYTE)0x00
+ << (BYTE)0x00;
+
+ UINT32 nWriteSize = nSize;
+ if (m_aMemoHeader.db_typ == MemoFoxPro)
+ {
+ if ( bBinary )
+ (*m_pMemoStream) << (BYTE) 0x00; // Picture
+ else
+ (*m_pMemoStream) << (BYTE) 0x01; // Memo
+ for (int i = 4; i > 0; nWriteSize >>= 8)
+ nHeader[--i] = (BYTE) (nWriteSize % 256);
+ }
+ else
+ {
+ (*m_pMemoStream) << (BYTE) 0x00;
+ nWriteSize += 8;
+ for (int i = 0; i < 4; nWriteSize >>= 8)
+ nHeader[i++] = (BYTE) (nWriteSize % 256);
+ }
+
+ m_pMemoStream->Write(nHeader,4);
+ if ( bBinary )
+ m_pMemoStream->Write( aValue.getConstArray(), aValue.getLength() );
+ else
+ m_pMemoStream->Write( aStr.getStr(), aStr.getLength() );
+ m_pMemoStream->Flush();
+ }
+ }
+
+
+ // Schreiben der neuen Blocknummer
+ if (bAppend)
+ {
+ ULONG nStreamSize = m_pMemoStream->Seek(STREAM_SEEK_TO_END);
+ m_aMemoHeader.db_next = (nStreamSize / m_aMemoHeader.db_size) + ((nStreamSize % m_aMemoHeader.db_size) > 0 ? 1 : 0);
+
+ // Schreiben der neuen Blocknummer
+ m_pMemoStream->Seek(0L);
+ (*m_pMemoStream) << m_aMemoHeader.db_next;
+ m_pMemoStream->Flush();
+ }
+ return sal_True;
+}
+
+// -----------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL ODbaseTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::alterColumnByName" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+
+ Reference<XDataDescriptorFactory> xOldColumn;
+ m_pColumns->getByName(colName) >>= xOldColumn;
+
+ alterColumn(m_pColumns->findColumn(colName)-1,descriptor,xOldColumn);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODbaseTable::alterColumnByIndex( sal_Int32 index, const Reference< XPropertySet >& descriptor ) throw(SQLException, ::com::sun::star::lang::IndexOutOfBoundsException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::alterColumnByIndex" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+
+ if(index < 0 || index >= m_pColumns->getCount())
+ throw IndexOutOfBoundsException(::rtl::OUString::valueOf(index),*this);
+
+ Reference<XDataDescriptorFactory> xOldColumn;
+ m_pColumns->getByIndex(index) >>= xOldColumn;
+ alterColumn(index,descriptor,xOldColumn);
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::alterColumn(sal_Int32 index,
+ const Reference< XPropertySet >& descriptor ,
+ const Reference< XDataDescriptorFactory >& xOldColumn )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::alterColumn" );
+ if(index < 0 || index >= m_pColumns->getCount())
+ throw IndexOutOfBoundsException(::rtl::OUString::valueOf(index),*this);
+
+ ODbaseTable* pNewTable = NULL;
+ try
+ {
+ OSL_ENSURE(descriptor.is(),"ODbaseTable::alterColumn: descriptor can not be null!");
+ // creates a copy of the the original column and copy all properties from descriptor in xCopyColumn
+ Reference<XPropertySet> xCopyColumn;
+ if(xOldColumn.is())
+ xCopyColumn = xOldColumn->createDataDescriptor();
+ else
+ xCopyColumn = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+
+ ::comphelper::copyProperties(descriptor,xCopyColumn);
+
+ // creates a temp file
+
+ String sTempName = createTempFile();
+
+ pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection));
+ Reference<XPropertySet> xHoldTable = pNewTable;
+ pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName)));
+ Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);
+ OSL_ENSURE(xAppend.is(),"ODbaseTable::alterColumn: No XAppend interface!");
+
+ // copy the structure
+ sal_Int32 i=0;
+ for(;i < index;++i)
+ {
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByIndex(i) >>= xProp;
+ Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
+ Reference<XPropertySet> xCpy;
+ if(xColumn.is())
+ xCpy = xColumn->createDataDescriptor();
+ else
+ xCpy = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+ ::comphelper::copyProperties(xProp,xCpy);
+ xAppend->appendByDescriptor(xCpy);
+ }
+ ++i; // now insert our new column
+ xAppend->appendByDescriptor(xCopyColumn);
+
+ for(;i < m_pColumns->getCount();++i)
+ {
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByIndex(i) >>= xProp;
+ Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
+ Reference<XPropertySet> xCpy;
+ if(xColumn.is())
+ xCpy = xColumn->createDataDescriptor();
+ else
+ xCpy = new OColumn(getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+ ::comphelper::copyProperties(xProp,xCpy);
+ xAppend->appendByDescriptor(xCpy);
+ }
+
+ // construct the new table
+ if(!pNewTable->CreateImpl())
+ {
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_ALTERABLE,
+ "$columnname$", ::comphelper::getString(descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+
+ pNewTable->construct();
+
+ // copy the data
+ copyData(pNewTable,0);
+
+ // now drop the old one
+ if( DropImpl() ) // we don't want to delete the memo columns too
+ {
+ // rename the new one to the old one
+ pNewTable->renameImpl(m_Name);
+ // release the temp file
+ pNewTable = NULL;
+ ::comphelper::disposeComponent(xHoldTable);
+ }
+ else
+ {
+ pNewTable = NULL;
+ }
+ FileClose();
+ construct();
+ if(m_pColumns)
+ m_pColumns->refresh();
+
+ }
+ catch(const SQLException&)
+ {
+ throw;
+ }
+ catch(const Exception&)
+ {
+ OSL_ENSURE(0,"ODbaseTable::alterColumn: Exception occured!");
+ throw;
+ }
+}
+// -----------------------------------------------------------------------------
+Reference< XDatabaseMetaData> ODbaseTable::getMetaData() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getMetaData" );
+ return getConnection()->getMetaData();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODbaseTable::rename( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::rename" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OTableDescriptor_BASE::rBHelper.bDisposed);
+ if(m_pTables && m_pTables->hasByName(newName))
+ throw ElementExistException(newName,*this);
+
+
+ renameImpl(newName);
+
+ ODbaseTable_BASE::rename(newName);
+
+ construct();
+ if(m_pColumns)
+ m_pColumns->refresh();
+}
+namespace
+{
+ void renameFile(OConnection* _pConenction,const ::rtl::OUString& oldName,
+ const ::rtl::OUString& newName,const String& _sExtension)
+ {
+ String aName = ODbaseTable::getEntry(_pConenction,oldName);
+ if(!aName.Len())
+ {
+ ::rtl::OUString aIdent = _pConenction->getContent()->getIdentifier()->getContentIdentifier();
+ if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) )
+ aIdent += ::rtl::OUString::createFromAscii("/");
+ aIdent += oldName;
+ aName = aIdent;
+ }
+ INetURLObject aURL;
+ aURL.SetURL(aName);
+
+ aURL.setExtension( _sExtension );
+ String sNewName(newName);
+ sNewName.AppendAscii(".");
+ sNewName += _sExtension;
+
+ try
+ {
+ Content aContent(aURL.GetMainURL(INetURLObject::NO_DECODE),Reference<XCommandEnvironment>());
+
+ Sequence< PropertyValue > aProps( 1 );
+ aProps[0].Name = ::rtl::OUString::createFromAscii("Title");
+ aProps[0].Handle = -1; // n/a
+ aProps[0].Value = makeAny( ::rtl::OUString(sNewName) );
+ Sequence< Any > aValues;
+ aContent.executeCommand( rtl::OUString::createFromAscii( "setPropertyValues" ),makeAny(aProps) ) >>= aValues;
+ if(aValues.getLength() && aValues[0].hasValue())
+ throw Exception();
+ }
+ catch(Exception&)
+ {
+ throw ElementExistException(newName,NULL);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODbaseTable::renameImpl( const ::rtl::OUString& newName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::container::ElementExistException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getEntry" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ FileClose();
+
+
+ renameFile(m_pConnection,m_Name,newName,m_pConnection->getExtension());
+ if ( HasMemoFields() )
+ { // delete the memo fields
+ String sExt = String::CreateFromAscii("dbt");
+ renameFile(m_pConnection,m_Name,newName,sExt);
+ }
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::addColumn(const Reference< XPropertySet >& _xNewColumn)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::addColumn" );
+ String sTempName = createTempFile();
+
+ ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection));
+ Reference< XPropertySet > xHold = pNewTable;
+ pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName)));
+ {
+ Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);
+ sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ // copy the structure
+ for(sal_Int32 i=0;i < m_pColumns->getCount();++i)
+ {
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByIndex(i) >>= xProp;
+ Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
+ Reference<XPropertySet> xCpy;
+ if(xColumn.is())
+ xCpy = xColumn->createDataDescriptor();
+ else
+ {
+ xCpy = new OColumn(bCase);
+ ::comphelper::copyProperties(xProp,xCpy);
+ }
+
+ xAppend->appendByDescriptor(xCpy);
+ }
+ Reference<XPropertySet> xCpy = new OColumn(bCase);
+ ::comphelper::copyProperties(_xNewColumn,xCpy);
+ xAppend->appendByDescriptor(xCpy);
+ }
+
+ // construct the new table
+ if(!pNewTable->CreateImpl())
+ {
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_ADDABLE,
+ "$columnname$", ::comphelper::getString(_xNewColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+
+ BOOL bAlreadyDroped = FALSE;
+ try
+ {
+ pNewTable->construct();
+ // copy the data
+ copyData(pNewTable,pNewTable->m_pColumns->getCount());
+ // drop the old table
+ if(DropImpl())
+ {
+ bAlreadyDroped = TRUE;
+ pNewTable->renameImpl(m_Name);
+ // release the temp file
+ }
+ xHold = pNewTable = NULL;
+
+ FileClose();
+ construct();
+ if(m_pColumns)
+ m_pColumns->refresh();
+ }
+ catch(const SQLException&)
+ {
+ // here we know that the old table wasn't droped before
+ if(!bAlreadyDroped)
+ xHold = pNewTable = NULL;
+
+ throw;
+ }
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::dropColumn(sal_Int32 _nPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::dropColumn" );
+ String sTempName = createTempFile();
+
+ ODbaseTable* pNewTable = new ODbaseTable(m_pTables,static_cast<ODbaseConnection*>(m_pConnection));
+ Reference< XPropertySet > xHold = pNewTable;
+ pNewTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(::rtl::OUString(sTempName)));
+ {
+ Reference<XAppend> xAppend(pNewTable->getColumns(),UNO_QUERY);
+ sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ // copy the structure
+ for(sal_Int32 i=0;i < m_pColumns->getCount();++i)
+ {
+ if(_nPos != i)
+ {
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByIndex(i) >>= xProp;
+ Reference<XDataDescriptorFactory> xColumn(xProp,UNO_QUERY);
+ Reference<XPropertySet> xCpy;
+ if(xColumn.is())
+ xCpy = xColumn->createDataDescriptor();
+ else
+ {
+ xCpy = new OColumn(bCase);
+ ::comphelper::copyProperties(xProp,xCpy);
+ }
+ xAppend->appendByDescriptor(xCpy);
+ }
+ }
+ }
+
+ // construct the new table
+ if(!pNewTable->CreateImpl())
+ {
+ xHold = pNewTable = NULL;
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_DROP,
+ "$position$", ::rtl::OUString::valueOf(_nPos)
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ pNewTable->construct();
+ // copy the data
+ copyData(pNewTable,_nPos);
+ // drop the old table
+ if(DropImpl())
+ pNewTable->renameImpl(m_Name);
+ // release the temp file
+
+ xHold = pNewTable = NULL;
+
+ FileClose();
+ construct();
+}
+// -----------------------------------------------------------------------------
+String ODbaseTable::createTempFile()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::createTempFile" );
+ ::rtl::OUString aIdent = m_pConnection->getContent()->getIdentifier()->getContentIdentifier();
+ if ( aIdent.lastIndexOf('/') != (aIdent.getLength()-1) )
+ aIdent += ::rtl::OUString::createFromAscii("/");
+ String sTempName(aIdent);
+ String sExt;
+ sExt.AssignAscii(".");
+ sExt += m_pConnection->getExtension();
+
+ String sName(m_Name);
+ TempFile aTempFile(sName,&sExt,&sTempName);
+ if(!aTempFile.IsValid())
+ getConnection()->throwGenericSQLException(STR_COULD_NOT_ALTER_TABLE,*this);
+
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ aURL.SetURL(aTempFile.GetURL());
+
+ String sNewName(aURL.getName());
+ sNewName.Erase(sNewName.Len() - sExt.Len());
+ return sNewName;
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::copyData(ODbaseTable* _pNewTable,sal_Int32 _nPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::copyData" );
+ sal_Int32 nPos = _nPos + 1; // +1 because we always have the bookmark clumn as well
+ OValueRefRow aRow = new OValueRefVector(m_pColumns->getCount());
+ OValueRefRow aInsertRow;
+ if(_nPos)
+ {
+ aInsertRow = new OValueRefVector(_pNewTable->m_pColumns->getCount());
+ ::std::for_each(aInsertRow->get().begin(),aInsertRow->get().end(),TSetRefBound(sal_True));
+ }
+ else
+ aInsertRow = aRow;
+
+ // we only have to bind the values which we need to copy into the new table
+ ::std::for_each(aRow->get().begin(),aRow->get().end(),TSetRefBound(sal_True));
+ if(_nPos && (_nPos < (sal_Int32)aRow->get().size()))
+ (aRow->get())[nPos]->setBound(sal_False);
+
+
+ sal_Bool bOk = sal_True;
+ sal_Int32 nCurPos;
+ OValueRefVector::Vector::iterator aIter;
+ for(sal_uInt32 nRowPos = 0; nRowPos < m_aHeader.db_anz;++nRowPos)
+ {
+ bOk = seekRow( IResultSetHelper::BOOKMARK, nRowPos+1, nCurPos );
+ if ( bOk )
+ {
+ bOk = fetchRow( aRow, m_aColumns.getBody(), sal_True, sal_True);
+ if ( bOk && !aRow->isDeleted() ) // copy only not deleted rows
+ {
+ // special handling when pos == 0 then we don't have to distinguish between the two rows
+ if(_nPos)
+ {
+ aIter = aRow->get().begin()+1;
+ sal_Int32 nCount = 1;
+ for(OValueRefVector::Vector::iterator aInsertIter = aInsertRow->get().begin()+1; aIter != aRow->get().end() && aInsertIter != aInsertRow->get().end();++aIter,++nCount)
+ {
+ if(nPos != nCount)
+ {
+ (*aInsertIter)->setValue( (*aIter)->getValue() );
+ ++aInsertIter;
+ }
+ }
+ }
+ bOk = _pNewTable->InsertRow(*aInsertRow,sal_True,_pNewTable->m_pColumns);
+ OSL_ENSURE(bOk,"Row could not be inserted!");
+ }
+ else
+ OSL_ENSURE(bOk,"Row could not be fetched!");
+ }
+ else
+ {
+ OSL_ASSERT(0);
+ }
+ } // for(sal_uInt32 nRowPos = 0; nRowPos < m_aHeader.db_anz;++nRowPos)
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::throwInvalidDbaseFormat()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::throwInvalidDbaseFormat" );
+ FileClose();
+ // no dbase file
+
+ const ::rtl::OUString sError( getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_SQL_NAME_ERROR,
+ "$filename$", getEntry(m_pConnection,m_Name)
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::refreshHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::refreshHeader" );
+ if ( m_aHeader.db_anz == 0 )
+ readHeader();
+}
+//------------------------------------------------------------------
+sal_Bool ODbaseTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::seekRow" );
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ OSL_ENSURE(m_pFileStream,"ODbaseTable::seekRow: FileStream is NULL!");
+
+ sal_uInt32 nNumberOfRecords = (sal_uInt32)m_aHeader.db_anz;
+ sal_uInt32 nTempPos = m_nFilePos;
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nFilePos;
+ break;
+ case IResultSetHelper::PRIOR:
+ if (m_nFilePos > 0)
+ --m_nFilePos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 1;
+ break;
+ case IResultSetHelper::LAST:
+ m_nFilePos = nNumberOfRecords;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nFilePos = (((sal_Int32)m_nFilePos) + nOffset < 0) ? 0L
+ : (sal_uInt32)(((sal_Int32)m_nFilePos) + nOffset);
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = (sal_uInt32)nOffset;
+ break;
+ }
+
+ if (m_nFilePos > (sal_Int32)nNumberOfRecords)
+ m_nFilePos = (sal_Int32)nNumberOfRecords + 1;
+
+ if (m_nFilePos == 0 || m_nFilePos == (sal_Int32)nNumberOfRecords + 1)
+ goto Error;
+ else
+ {
+ sal_uInt16 nEntryLen = m_aHeader.db_slng;
+
+ OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
+ sal_Int32 nPos = m_aHeader.db_kopf + (sal_Int32)(m_nFilePos-1) * nEntryLen;
+
+ ULONG nLen = m_pFileStream->Seek(nPos);
+ if (m_pFileStream->GetError() != ERRCODE_NONE)
+ goto Error;
+
+ nLen = m_pFileStream->Read((char*)m_pBuffer, nEntryLen);
+ if (m_pFileStream->GetError() != ERRCODE_NONE)
+ goto Error;
+ }
+ goto End;
+
+Error:
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::PRIOR:
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ case IResultSetHelper::NEXT:
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::RELATIVE:
+ if (nOffset > 0)
+ m_nFilePos = nNumberOfRecords + 1;
+ else if (nOffset < 0)
+ m_nFilePos = 0;
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_nFilePos = nTempPos; // vorherige Position
+ }
+ // aStatus.Set(SDB_STAT_NO_DATA_FOUND);
+ return sal_False;
+
+End:
+ nCurPos = m_nFilePos;
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::ReadMemo(ULONG nBlockNo, ORowSetValue& aVariable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::ReadMemo" );
+ BOOL bIsText = TRUE;
+ // SdbConnection* pConnection = GetConnection();
+
+ m_pMemoStream->Seek(nBlockNo * m_aMemoHeader.db_size);
+ switch (m_aMemoHeader.db_typ)
+ {
+ case MemodBaseIII: // dBase III-Memofeld, endet mit Ctrl-Z
+ {
+ const char cEOF = (char) DBF_EOL;
+ ByteString aBStr;
+ static char aBuf[514];
+ aBuf[512] = 0; // sonst kann der Zufall uebel mitspielen
+ BOOL bReady = sal_False;
+
+ do
+ {
+ m_pMemoStream->Read(&aBuf,512);
+
+ USHORT i = 0;
+ while (aBuf[i] != cEOF && ++i < 512)
+ ;
+ bReady = aBuf[i] == cEOF;
+
+ aBuf[i] = 0;
+ aBStr += aBuf;
+
+ } while (!bReady && !m_pMemoStream->IsEof() && aBStr.Len() < STRING_MAXLEN);
+
+ ::rtl::OUString aStr(aBStr.GetBuffer(), aBStr.Len(),m_eEncoding);
+ aVariable = aStr;
+
+ } break;
+ case MemoFoxPro:
+ case MemodBaseIV: // dBase IV-Memofeld mit Laengenangabe
+ {
+ char sHeader[4];
+ m_pMemoStream->Read(sHeader,4);
+ // Foxpro stores text and binary data
+ if (m_aMemoHeader.db_typ == MemoFoxPro)
+ {
+// if (((BYTE)sHeader[0]) != 0 || ((BYTE)sHeader[1]) != 0 || ((BYTE)sHeader[2]) != 0)
+// {
+//// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
+//// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
+//// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
+//// aStatus.Set(SDB_STAT_ERROR,
+//// String::CreateFromAscii("01000"),
+//// aStatus.CreateErrorMessage(aText),
+//// 0, String() );
+// return sal_False;
+// }
+//
+ bIsText = sHeader[3] != 0;
+ }
+ else if (((BYTE)sHeader[0]) != 0xFF || ((BYTE)sHeader[1]) != 0xFF || ((BYTE)sHeader[2]) != 0x08)
+ {
+// String aText = String(SdbResId(STR_STAT_IResultSetHelper::INVALID));
+// aText.SearchAndReplace(String::CreateFromAscii("%%d"),m_pMemoStream->GetFileName());
+// aText.SearchAndReplace(String::CreateFromAscii("%%t"),aStatus.TypeToString(MEMO));
+// aStatus.Set(SDB_STAT_ERROR,
+// String::CreateFromAscii("01000"),
+// aStatus.CreateErrorMessage(aText),
+// 0, String() );
+ return sal_False;
+ }
+
+ sal_uInt32 nLength(0);
+ (*m_pMemoStream) >> nLength;
+
+ if (m_aMemoHeader.db_typ == MemodBaseIV)
+ nLength -= 8;
+
+ if ( nLength )
+ {
+ if ( bIsText )
+ {
+ // char cChar;
+ ::rtl::OUStringBuffer aStr;
+ while ( nLength > STRING_MAXLEN )
+ {
+ ByteString aBStr;
+ aBStr.Expand(STRING_MAXLEN);
+ m_pMemoStream->Read(aBStr.AllocBuffer(STRING_MAXLEN),STRING_MAXLEN);
+ aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding));
+ nLength -= STRING_MAXLEN;
+ }
+ if ( nLength > 0 )
+ {
+ ByteString aBStr;
+ aBStr.Expand(static_cast<xub_StrLen>(nLength));
+ m_pMemoStream->Read(aBStr.AllocBuffer(static_cast<xub_StrLen>(nLength)),nLength);
+ // aBStr.ReleaseBufferAccess();
+ aStr.append(::rtl::OUString(aBStr.GetBuffer(),aBStr.Len(), m_eEncoding));
+ }
+ if ( aStr.getLength() )
+ aVariable = aStr.makeStringAndClear();
+ } // if ( bIsText )
+ else
+ {
+ ::com::sun::star::uno::Sequence< sal_Int8 > aData(nLength);
+ m_pMemoStream->Read(aData.getArray(),nLength);
+ aVariable = aData;
+ }
+ } // if ( nLength )
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void ODbaseTable::AllocBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::AllocBuffer" );
+ UINT16 nSize = m_aHeader.db_slng;
+ OSL_ENSURE(nSize > 0, "Size too small");
+
+ if (m_nBufferSize != nSize)
+ {
+ delete m_pBuffer;
+ m_pBuffer = NULL;
+ }
+
+ // Falls noch kein Puffer vorhanden: allozieren:
+ if (m_pBuffer == NULL && nSize)
+ {
+ m_nBufferSize = nSize;
+ m_pBuffer = new BYTE[m_nBufferSize+1];
+ }
+}
+// -----------------------------------------------------------------------------
+BOOL ODbaseTable::WriteBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::WriteBuffer" );
+ OSL_ENSURE(m_nFilePos >= 1,"SdbDBFCursor::FileFetchRow: ungueltige Record-Position");
+
+ // Auf gewuenschten Record positionieren:
+ long nPos = m_aHeader.db_kopf + (long)(m_nFilePos-1) * m_aHeader.db_slng;
+ m_pFileStream->Seek(nPos);
+ return m_pFileStream->Write((char*) m_pBuffer, m_aHeader.db_slng) > 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODbaseTable::getCurrentLastPos() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "dbase", "Ocke.Janssen@sun.com", "ODbaseTable::getCurrentLastPos" );
+ return m_aHeader.db_anz;
+}
diff --git a/connectivity/source/drivers/dbase/DTables.cxx b/connectivity/source/drivers/dbase/DTables.cxx
new file mode 100644
index 000000000000..ad89446c3916
--- /dev/null
+++ b/connectivity/source/drivers/dbase/DTables.cxx
@@ -0,0 +1,144 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DTables.hxx"
+#include "dbase/DTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include "dbase/DCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "resource/dbase_res.hrc"
+#include "connectivity/dbexception.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType ODbaseTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ ODbaseTable* pRet = new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+
+ sdbcx::ObjectType xRet = pRet;
+ pRet->construct();
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void ODbaseTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<ODbaseCatalog*>(&m_rParent)->refreshTables();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > ODbaseTables::createDescriptor()
+{
+ return new ODbaseTable(this,(ODbaseConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection());
+}
+typedef connectivity::sdbcx::OCollection ODbaseTables_BASE_BASE;
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType ODbaseTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ Reference<XUnoTunnel> xTunnel(descriptor,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
+ if(pTable)
+ {
+ pTable->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME),makeAny(_rForName));
+ try
+ {
+ if(!pTable->CreateImpl())
+ throw SQLException();
+ }
+ catch(SQLException&)
+ {
+ throw;
+ }
+ catch(Exception&)
+ {
+ throw SQLException();
+ }
+ }
+ }
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void ODbaseTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XUnoTunnel> xTunnel;
+ try
+ {
+ xTunnel.set(getObject(_nPos),UNO_QUERY);
+ }
+ catch(const Exception&)
+ {
+ if(ODbaseTable::Drop_Static(ODbaseTable::getEntry(static_cast<OFileCatalog&>(m_rParent).getConnection(),_sElementName),sal_False,NULL))
+ return;
+ }
+
+ if ( xTunnel.is() )
+ {
+ ODbaseTable* pTable = reinterpret_cast< ODbaseTable* >( xTunnel->getSomething(ODbaseTable::getUnoTunnelImplementationId()) );
+ if(pTable)
+ pTable->DropImpl();
+ }
+ else
+ {
+ const ::rtl::OUString sError( static_cast<OFileCatalog&>(m_rParent).getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_TABLE_NOT_DROP,
+ "$tablename$", _sElementName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, NULL );
+ }
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODbaseTables::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ typedef sdbcx::OCollection OTables_BASE;
+ return OTables_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/dbase/Dservices.cxx b/connectivity/source/drivers/dbase/Dservices.cxx
new file mode 100644
index 000000000000..831329a1feba
--- /dev/null
+++ b/connectivity/source/drivers/dbase/Dservices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/DDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::dbase;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/dbase/dbase.mxp.map b/connectivity/source/drivers/dbase/dbase.mxp.map
new file mode 100644
index 000000000000..c5b4377b04c3
--- /dev/null
+++ b/connectivity/source/drivers/dbase/dbase.mxp.map
@@ -0,0 +1,173 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_vec_delete
+___builtin_vec_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+_terminate__Fv
+dyld_stub_binding_helper
+rest_world
+save_world
+___builtin_new
+___eh_rtime_match
+___tf9bad_alloc
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+_getPropertySetInfo__Q312connectivity5dbase15ODbaseResultSet
+_release__Q312connectivity5dbase15ODbaseResultSet
+_acquire__Q312connectivity5dbase15ODbaseResultSet
+__._Q312connectivity5dbase15ODbaseResultSet
+__._Q312connectivity5dbase15ODbaseStatement
+__._Q312connectivity5dbase23ODbasePreparedStatement
+_IsText__Q312connectivity5dbase7ONDXKeyl
+_Write__CQ312connectivity5dbase8ONDXNodeR8SvStreamRCQ312connectivity5dbase8ONDXPage
+_Read__Q312connectivity5dbase8ONDXNodeR8SvStreamRQ312connectivity5dbase11ODbaseIndex
+_Merge__Q312connectivity5dbase8ONDXPageUsGQ312connectivity5dbase11ONDXPagePtr
+_Remove__Q312connectivity5dbase8ONDXPageUs
+_SearchAndReplace__Q312connectivity5dbase8ONDXPageRCQ312connectivity5dbase7ONDXKeyRB1
+_Search__Q312connectivity5dbase8ONDXPageRCQ312connectivity5dbase7ONDXKey
+_FindPos__CQ312connectivity5dbase8ONDXPageRCQ312connectivity5dbase7ONDXKey
+_ReleaseFull__Q312connectivity5dbase8ONDXPageUc
+_Append__Q312connectivity5dbase8ONDXPageRQ312connectivity5dbase8ONDXNode
+_Split__Q312connectivity5dbase8ONDXPageRB0
+_Insert__Q312connectivity5dbase8ONDXPageUsRQ312connectivity5dbase8ONDXNode
+_IsFull__CQ312connectivity5dbase8ONDXPage
+___vc__CQ312connectivity5dbase8ONDXPageUs
+___ls__Q212connectivity5dbaseR8SvStreamRCQ312connectivity5dbase8ONDXPage
+__._Q312connectivity5dbase8ONDXPage
+_GetFirstKey__Q312connectivity5dbase14OIndexIteratorPQ312connectivity5dbase8ONDXPageRCQ312connectivity4file8OOperand
+_GetCompare__Q312connectivity5dbase14OIndexIteratorUc
+_GetLike__Q312connectivity5dbase14OIndexIteratorUc
+_GetNull__Q312connectivity5dbase14OIndexIteratorUc
+_GetNotNull__Q312connectivity5dbase14OIndexIteratorUc
+_GetNextKey__Q312connectivity5dbase14OIndexIterator
+_Find__Q312connectivity5dbase14OIndexIteratorUc
+_refreshTables__Q312connectivity5dbase13ODbaseCatalog
+__._Q312connectivity5dbase18UStringDescription
+___Q312connectivity5dbase18UStringDescriptionPFv_PCc
+__._Q312connectivity5dbase11ODbaseIndex
+_release__Q312connectivity5dbase11ODbaseIndex
+_acquire__Q312connectivity5dbase11ODbaseIndex
+_createINFEntry__Q312connectivity5dbase11ODbaseIndex
+_getEntry__Q312connectivity5dbase11ODbaseIndex
+___ls__Q212connectivity5dbaseR8SvStreamRQ312connectivity5dbase11ODbaseIndex
+_Release__Q312connectivity5dbase11ODbaseIndexUc
+_ConvertToKey__Q312connectivity5dbase11ODbaseIndexPQ312connectivity5dbase7ONDXKeyUlRCQ312connectivity4file12ORowSetValue
+_openIndexFile__Q312connectivity5dbase11ODbaseIndex
+__._Q312connectivity5dbase11ODbaseTable
+_WriteMemo__Q312connectivity5dbase11ODbaseTableRQ312connectivity4file12ORowSetValueRUl
+_isUniqueByColumnName__Q312connectivity5dbase11ODbaseTableRCQ23rtl8OUString
+_WriteBuffer__Q312connectivity5dbase11ODbaseTable
+_UpdateBuffer__Q312connectivity5dbase11ODbaseTableRQ312connectivity4file12OValueVectorGQ23vost4ORef1ZB1RCQ53com3sun4star3unot9Reference1ZQ53com3sun4star9container12XIndexAccess
+_CreateMemoFile__Q312connectivity5dbase11ODbaseTableRC13INetURLObject
+_CreateFile__Q312connectivity5dbase11ODbaseTableRC13INetURLObjectRUc
+_ReadMemo__Q312connectivity5dbase11ODbaseTableUlRQ312connectivity4file12ORowSetValue
+_refreshIndexes__Q312connectivity5dbase11ODbaseTable
+_refreshColumns__Q312connectivity5dbase11ODbaseTable
+_AllocBuffer__Q312connectivity5dbase11ODbaseTable
+_fillColumns__Q312connectivity5dbase11ODbaseTable
+_ReadMemoHeader__Q312connectivity5dbase11ODbaseTable
+_readHeader__Q312connectivity5dbase11ODbaseTable
+_getPropertySetInfo__Q312connectivity4file26ODatabaseMetaDataResultSet
+_release__Q312connectivity4file26ODatabaseMetaDataResultSet
+_acquire__Q312connectivity4file26ODatabaseMetaDataResultSet
+_getPropertySetInfo__Q312connectivity4file10OResultSet
+_release__Q312connectivity4file10OResultSet
+_acquire__Q312connectivity4file10OResultSet
+_scanParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRQ24_STLt6vector2ZPB1ZQ24_STLt9allocator1ZPB1
+_AddParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star5beans12XPropertySet
+_SetAssignValue__Q312connectivity4file10OResultSetRC6Stringn1UcUl
+_ParseAssignValues__Q312connectivity4file10OResultSetRCQ24_STLt6vector2Z6StringZQ24_STLt9allocator1ZB2PQ212connectivity13OSQLParseNodeUs
+_getUnoTunnelImplementationId__Q312connectivity4file10OResultSet
+_setOrderbyColumn__Q312connectivity4file10OResultSetUsPQ212connectivity13OSQLParseNoden1
+_CreateKeySet__Q312connectivity4file14OFILESortIndex
+___Q312connectivity4file14OFILESortIndexPCQ312connectivity4file8OKeyTypePCUclUs
+_anylizeSQL__Q312connectivity4file10OResultSet
+_GetAssignValues__Q312connectivity4file10OResultSet
+_moveAbsolute__Q312connectivity4file10OResultSetlUc
+_ExecuteRow__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUcn2
+_AddKeyValue__Q312connectivity4file14OFILESortIndexPQ312connectivity4file13OFILEKeyValue
+_GetOrderbyKeyValue__Q312connectivity4file10OResultSetGQ23vost4ORef1ZQ312connectivity4file12OValueVector
+_evaluate__Q312connectivity4file10OResultSet
+_SkipDeleted__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUc
+__._Q312connectivity4file14OFILESortIndex
+_construct__Q312connectivity4file10OResultSet
+_isCount__CQ312connectivity4file10OResultSet
+__._Q312connectivity4file18UStringDescription
+___Q312connectivity4file18UStringDescriptionPFv_PCc
+_disposing__Q312connectivity4file15OStatement_Base
+_acquire__Q312connectivity4file15OStatement_Base
+__._Q312connectivity4file16OStatement_BASE2
+__._Q312connectivity4file10OStatement
+_disposeResultSet__Q312connectivity4file15OStatement_Base
+_getImplementationName_Static__Q312connectivity4file11OFileDriver
+_operate__CQ312connectivity4file8OOp_LIKEPCQ312connectivity4file8OOperandn1
+_operate__CQ312connectivity4file10OOp_ISNULLPCQ312connectivity4file8OOperandn1
+_IsOf__Q312connectivity4file12ONumOperatorPFv_Pv
+_StaticType__Q312connectivity4file12ONumOperator
+_IsOf__Q312connectivity4file11OOp_COMPAREPFv_Pv
+_IsOf__Q312connectivity4file11OOp_NOTLIKEPFv_Pv
+_StaticType__Q312connectivity4file11OOp_NOTLIKE
+_IsOf__Q312connectivity4file8OOp_LIKEPFv_Pv
+_IsOf__Q312connectivity4file13OOp_ISNOTNULLPFv_Pv
+_IsOf__Q312connectivity4file10OOp_ISNULLPFv_Pv
+_IsOf__Q312connectivity4file6OOp_ORPFv_Pv
+_StaticType__Q312connectivity4file6OOp_OR
+_IsOf__Q312connectivity4file7OOp_ANDPFv_Pv
+_StaticType__Q312connectivity4file7OOp_AND
+_IsOf__Q312connectivity4file13OBoolOperatorPFv_Pv
+_IsOf__Q312connectivity4file9OOperatorPFv_Pv
+_IsOf__Q312connectivity4file14OOperandResultPFv_Pv
+_IsOf__Q312connectivity4file13OOperandConstPFv_Pv
+_IsOf__Q312connectivity4file13OOperandValuePFv_Pv
+_StaticType__Q312connectivity4file13OOperandValue
+_IsOf__Q312connectivity4file13OOperandParamPFv_Pv
+_IsOf__Q312connectivity4file16OFILEOperandAttrPFv_Pv
+_StaticType__Q312connectivity4file16OFILEOperandAttr
+_IsOf__Q312connectivity4file12OOperandAttrPFv_Pv
+_IsOf__Q312connectivity4file11OOperandRowPFv_Pv
+_StaticType__Q312connectivity4file11OOperandRow
+_IsOf__Q312connectivity4file8OOperandPFv_Pv
+_IsOf__Q312connectivity4file5OCodePFv_Pv
+_StaticType__Q312connectivity4file5OCode
+_execute_Operand__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_ISNULL__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_LIKE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_COMPARE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/dbase/dbase.xcu b/connectivity/source/drivers/dbase/dbase.xcu
new file mode 100755
index 000000000000..f5de1d53ab0e
--- /dev/null
+++ b/connectivity/source/drivers/dbase/dbase.xcu
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:dbase:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.dbase.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">dBASE</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="ShowDeleted" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="EnableSQL92Check" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FileSystemBased" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="MediaType" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>application/dbase</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/dbase/dbase.xml b/connectivity/source/drivers/dbase/dbase.xml
new file mode 100644
index 000000000000..b2a1bc2b803c
--- /dev/null
+++ b/connectivity/source/drivers/dbase/dbase.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Ocke Jannsen</author>
+ <name>com.sun.star.comp.sdbc.dbase.ODriver</name>
+ <description>This library implements the database driver for dBase file format.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>file</runtime-module-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/dbase/dindexnode.cxx b/connectivity/source/drivers/dbase/dindexnode.cxx
new file mode 100644
index 000000000000..9a8905b6a6ba
--- /dev/null
+++ b/connectivity/source/drivers/dbase/dindexnode.cxx
@@ -0,0 +1,1056 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "dbase/dindexnode.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <osl/thread.h>
+#include "dbase/DIndex.hxx"
+#include <tools/debug.hxx>
+#include "diagnose_ex.h"
+
+#include <algorithm>
+
+
+using namespace connectivity;
+using namespace connectivity::dbase;
+using namespace connectivity::file;
+using namespace com::sun::star::sdbc;
+// -----------------------------------------------------------------------------
+ONDXKey::ONDXKey(UINT32 nRec)
+ :nRecord(nRec)
+{
+}
+// -----------------------------------------------------------------------------
+ONDXKey::ONDXKey(const ORowSetValue& rVal, sal_Int32 eType, UINT32 nRec)
+ : ONDXKey_BASE(eType)
+ , nRecord(nRec)
+ , xValue(rVal)
+{
+}
+// -----------------------------------------------------------------------------
+ONDXKey::ONDXKey(const rtl::OUString& aStr, UINT32 nRec)
+ : ONDXKey_BASE(::com::sun::star::sdbc::DataType::VARCHAR)
+ ,nRecord(nRec)
+{
+ if (aStr.getLength())
+ {
+ xValue = aStr;
+ xValue.setBound(sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+
+ONDXKey::ONDXKey(double aVal, UINT32 nRec)
+ : ONDXKey_BASE(::com::sun::star::sdbc::DataType::DOUBLE)
+ ,nRecord(nRec)
+ ,xValue(aVal)
+{
+}
+// -----------------------------------------------------------------------------
+
+//==================================================================
+// Index Seite
+//==================================================================
+ONDXPage::ONDXPage(ODbaseIndex& rInd, sal_uInt32 nPos, ONDXPage* pParent)
+ :nPagePos(nPos)
+ ,bModified(FALSE)
+ ,nCount(0)
+ ,aParent(pParent)
+ ,rIndex(rInd)
+ ,ppNodes(NULL)
+{
+ sal_uInt16 nT = rIndex.getHeader().db_maxkeys;
+ ppNodes = new ONDXNode[nT];
+}
+
+//------------------------------------------------------------------
+ONDXPage::~ONDXPage()
+{
+ delete[] ppNodes;
+ // delete aParent;
+ // delete aChild;
+}
+//------------------------------------------------------------------
+void ONDXPage::QueryDelete()
+{
+ // Ablegen im GarbageCollector
+ if (IsModified() && rIndex.m_pFileStream)
+ (*rIndex.m_pFileStream) << *this;
+
+ bModified = FALSE;
+ if (rIndex.UseCollector())
+ {
+ if (aChild.Is())
+ aChild->Release(FALSE);
+
+ for (USHORT i = 0; i < rIndex.getHeader().db_maxkeys;i++)
+ {
+ if (ppNodes[i].GetChild().Is())
+ ppNodes[i].GetChild()->Release(FALSE);
+
+ ppNodes[i] = ONDXNode();
+ }
+ RestoreNoDelete();
+
+ nCount = 0;
+ aParent.Clear();
+ rIndex.Collect(this);
+ }
+ else
+ SvRefBase::QueryDelete();
+}
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXPage::GetChild(ODbaseIndex* pIndex)
+{
+ if (!aChild.Is() && pIndex)
+ {
+ aChild = rIndex.CreatePage(aChild.GetPagePos(),this,aChild.HasPage());
+ }
+ return aChild;
+}
+
+//------------------------------------------------------------------
+USHORT ONDXPage::FindPos(const ONDXKey& rKey) const
+{
+ // sucht nach Platz fuer den vorgegeben key auf einer Seite
+ USHORT i = 0;
+ while (i < nCount && rKey > ((*this)[i]).GetKey())
+ i++;
+
+ return i;
+}
+
+//------------------------------------------------------------------
+BOOL ONDXPage::Find(const ONDXKey& rKey)
+{
+ // sucht den vorgegeben key
+ // Besonderheit: gelangt der Algorithmus ans Ende
+ // wird immer die aktuelle Seite und die Knotenposition vermerkt
+ // auf die die Bedingung <= zutrifft
+ // dieses findet beim Insert besondere Beachtung
+ USHORT i = 0;
+ while (i < nCount && rKey > ((*this)[i]).GetKey())
+ i++;
+
+ BOOL bResult = FALSE;
+
+ if (!IsLeaf())
+ {
+ // weiter absteigen
+ ONDXPagePtr aPage = (i==0) ? GetChild(&rIndex) : ((*this)[i-1]).GetChild(&rIndex, this);
+ bResult = aPage.Is() && aPage->Find(rKey);
+ }
+ else if (i == nCount)
+ {
+ rIndex.m_aCurLeaf = this;
+ rIndex.m_nCurNode = i - 1;
+ bResult = FALSE;
+ }
+ else
+ {
+ bResult = rKey == ((*this)[i]).GetKey();
+ rIndex.m_aCurLeaf = this;
+ rIndex.m_nCurNode = bResult ? i : i - 1;
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------
+BOOL ONDXPage::Insert(ONDXNode& rNode, sal_uInt32 nRowsLeft)
+{
+ // beim Erzeugen eines Index koennen auch mehrere Knoten eingefuegt werden
+ // diese sin dann aufsteigend sortiert
+ BOOL bAppend = nRowsLeft > 0;
+ if (IsFull())
+ {
+ BOOL bResult = TRUE;
+ ONDXNode aSplitNode;
+ if (bAppend)
+ aSplitNode = rNode;
+ else
+ {
+ // merken des letzten Knotens
+ aSplitNode = (*this)[nCount-1];
+ if(rNode.GetKey() <= aSplitNode.GetKey())
+ {
+
+ // und damit habe ich im folgenden praktisch eine Node weniger
+ if (IsLeaf() && this == &rIndex.m_aCurLeaf)
+ {
+ // geht davon aus, dass der Knoten, auf dem die Bedingung (<=)
+ // zutrifft, als m_nCurNode gesetzt ist
+ --nCount; // (sonst bekomme ich u.U. Assertions und GPFs - 60593)
+ bResult = Insert(rIndex.m_nCurNode + 1, rNode);
+ }
+ else // Position unbekannt
+ {
+ USHORT nPos = NODE_NOTFOUND;
+ while (++nPos < nCount && rNode.GetKey() > ((*this)[nPos]).GetKey()) ;
+
+ --nCount; // (sonst bekomme ich u.U. Assertions und GPFs - 60593)
+ bResult = Insert(nPos, rNode);
+ }
+
+ // konnte der neue Knoten eingefuegt werden
+ if (!bResult)
+ {
+ nCount++;
+ aSplitNode = rNode;
+ }
+ }
+ else
+ aSplitNode = rNode;
+ }
+
+ sal_uInt32 nNewPagePos = rIndex.GetPageCount();
+ sal_uInt32 nNewPageCount = nNewPagePos + 1;
+
+ // Herausgeloesten Knoten beim Vater einfuegen
+ if (!HasParent())
+ {
+ // Kein Vater, dann neue Wurzel
+ ONDXPagePtr aNewRoot = rIndex.CreatePage(nNewPagePos + 1);
+ aNewRoot->SetChild(this);
+
+ rIndex.m_aRoot = aNewRoot;
+ rIndex.SetRootPos(nNewPagePos + 1);
+ rIndex.SetPageCount(++nNewPageCount);
+ }
+
+ // neues blatt erzeugen und Seite aufteilen
+ ONDXPagePtr aNewPage = rIndex.CreatePage(nNewPagePos,aParent);
+ rIndex.SetPageCount(nNewPageCount);
+
+ // wieviele Knoten weren noch eingefuegt
+ // kommen noch ausreichend, dann koennen die Seiten bis zum Rand vollgestopft werden
+
+ ONDXNode aInnerNode;
+ if (!IsLeaf() || nRowsLeft < (sal_uInt32)(rIndex.GetMaxNodes() / 2))
+ aInnerNode = Split(*aNewPage);
+ else
+ {
+ aInnerNode = (*this)[nCount - 1];
+ //aInnerNode = aSplitNode;
+
+ // Knoten zeigt auf neue Seite
+ aInnerNode.SetChild(aNewPage);
+
+ // innere Knoten haben keine Recordnummer
+ if (rIndex.isUnique())
+ aInnerNode.GetKey().ResetRecord();
+
+ // neue Seite zeigt nun auf Seite des herausgeloesten Knoten
+ if (!IsLeaf())
+ aNewPage->SetChild(aInnerNode.GetChild());
+ }
+
+ aNewPage->Append(aSplitNode);
+ ONDXPagePtr aTempParent = aParent;
+ if (IsLeaf())
+ {
+ rIndex.m_aCurLeaf = aNewPage;
+ rIndex.m_nCurNode = rIndex.m_aCurLeaf->Count() - 1;
+
+ // Freigeben nicht benoetigter Seiten, danach besteht keine Referenz
+ // mehr auf die Seite, danach kann 'this' nicht mehr gueltig sein!!!
+ ReleaseFull();
+ }
+
+ // Einfuegen des herausgeloesten Knotens
+ return aTempParent->Insert(aInnerNode);
+ }
+ else // Seite einfach weiter auffuellen
+ {
+ if (bAppend)
+ {
+ if (IsLeaf())
+ rIndex.m_nCurNode = nCount - 1;
+ return Append(rNode);
+ }
+ else
+ {
+ USHORT nNodePos = FindPos(rNode.GetKey());
+ if (IsLeaf())
+ rIndex.m_nCurNode = nNodePos;
+
+ return Insert(nNodePos, rNode);
+ }
+ }
+}
+
+//------------------------------------------------------------------
+BOOL ONDXPage::Insert(USHORT nPos, ONDXNode& rNode)
+{
+ USHORT nMaxCount = rIndex.getHeader().db_maxkeys;
+ if (nPos >= nMaxCount)
+ return FALSE;
+
+ if (nCount)
+ {
+ ++nCount;
+ // nach rechts verschieben
+ for (USHORT i = std::min((USHORT)(nMaxCount-1), (USHORT)(nCount-1)); nPos < i; --i)
+ (*this)[i] = (*this)[i-1];
+ }
+ else
+ if (nCount < nMaxCount)
+ nCount++;
+
+ // einfuegen an der Position
+ ONDXNode& rInsertNode = (*this)[nPos];
+ rInsertNode = rNode;
+ if (rInsertNode.GetChild().Is())
+ {
+ rInsertNode.GetChild()->SetParent(this);
+ rNode.GetChild()->SetParent(this);
+ }
+
+ bModified = TRUE;
+
+ return TRUE;
+}
+
+//------------------------------------------------------------------
+BOOL ONDXPage::Append(ONDXNode& rNode)
+{
+ DBG_ASSERT(!IsFull(), "kein Append moeglich");
+ return Insert(nCount, rNode);
+}
+//------------------------------------------------------------------
+void ONDXPage::Release(BOOL bSave)
+{
+ // freigeben der Pages
+ if (aChild.Is())
+ aChild->Release(bSave);
+
+ // Pointer freigeben
+ aChild.Clear();
+
+ for (USHORT i = 0; i < rIndex.getHeader().db_maxkeys;i++)
+ {
+ if (ppNodes[i].GetChild())
+ ppNodes[i].GetChild()->Release(bSave);
+
+ ppNodes[i].GetChild().Clear();
+ }
+ aParent = NULL;
+}
+//------------------------------------------------------------------
+void ONDXPage::ReleaseFull(BOOL bSave)
+{
+ ONDXPagePtr aTempParent = aParent;
+ Release(bSave);
+
+ if (aTempParent.Is())
+ {
+ // Freigeben nicht benoetigter Seiten, danach besteht keine Referenz
+ // mehr auf die Seite, danach kann 'this' nicht mehr gueltig sein!!!
+ USHORT nParentPos = aTempParent->Search(this);
+ if (nParentPos != NODE_NOTFOUND)
+ (*aTempParent)[nParentPos].GetChild().Clear();
+ else
+ aTempParent->GetChild().Clear();
+ }
+}
+//------------------------------------------------------------------
+BOOL ONDXPage::Delete(USHORT nNodePos)
+{
+ if (IsLeaf())
+ {
+ // Letztes Element wird geloescht
+ if (nNodePos == (nCount - 1))
+ {
+ ONDXNode aNode = (*this)[nNodePos];
+
+ // beim Parent muss nun der KeyValue ausgetauscht werden
+ if (HasParent())
+ aParent->SearchAndReplace(aNode.GetKey(),
+ (*this)[nNodePos-1].GetKey());
+ }
+ }
+
+ // Loeschen des Knoten
+ Remove(nNodePos);
+
+ // Unterlauf
+ if (HasParent() && nCount < (rIndex.GetMaxNodes() / 2))
+ {
+ // Feststellen, welcher Knoten auf die Seite zeigt
+ USHORT nParentNodePos = aParent->Search(this);
+ // letzte Element auf Vaterseite
+ // -> zusammenlegen mit vorletzter Seite
+ if (nParentNodePos == (aParent->Count() - 1))
+ {
+ if (!nParentNodePos)
+ // zusammenlegen mit linken nachbarn
+ Merge(nParentNodePos,aParent->GetChild(&rIndex));
+ else
+ Merge(nParentNodePos,(*aParent)[nParentNodePos-1].GetChild(&rIndex,aParent));
+ }
+ // sonst Seite mit naechster Seite zusammenlegen
+ else
+ {
+ // zusammenlegen mit rechten nachbarn
+ Merge(nParentNodePos + 1,((*aParent)[nParentNodePos + 1].GetChild(&rIndex,aParent)));
+ nParentNodePos++;
+ }
+ if (HasParent() && !(*aParent)[nParentNodePos].HasChild())
+ aParent->Delete(nParentNodePos);
+/*
+ // letzte Element auf Vaterseite
+ // -> zusammenlegen mit vorletzter Seite
+ if (nParentNodePos == (aParent->Count() - 1))
+ {
+ if (!nParentNodePos)
+ // zusammenlegen mit linken nachbarn
+ Merge(nParentNodePos,aParent->GetChild(&rIndex));
+ else
+ Merge(nParentNodePos,(*aParent)[nParentNodePos-1].GetChild(&rIndex,aParent));
+ }
+ // sonst Seite mit naechster Seite zusammenlegen
+ else if(nParentNodePos != NODE_NOTFOUND)
+ {
+ // zusammenlegen mit rechten nachbarn
+ Merge(nParentNodePos + 1,((*aParent)[nParentNodePos + 1].GetChild(&rIndex,aParent)));
+ nParentNodePos++;
+ }
+ else // Sonderbehandlung
+ {
+ // Page ist aChild Page vom Parent => erste Page aus ppNodes an aChild anhaengen
+ Merge(0,(*aParent)[0].GetChild(&rIndex,aParent));
+ nParentNodePos = 0;
+ }
+
+ if (HasParent() && !(*aParent)[nParentNodePos].HasChild())
+ aParent->Delete(nParentNodePos);
+*/
+
+ }
+ else if (IsRoot())
+ // Sicherstellen das die Position der Wurzel festgehalten wird
+ rIndex.SetRootPos(nPagePos);
+ return TRUE;
+}
+
+
+//------------------------------------------------------------------
+ONDXNode ONDXPage::Split(ONDXPage& rPage)
+{
+ DBG_ASSERT(IsFull(), "Falsches Splitting");
+ /* Aufteilen einer Seite auf zwei
+ Blatt:
+ Seite 1 behaelt (n - (n/2))
+ Seite 2 erhaelt (n/2)
+ Knoten n/2 wird dupliziert
+ Innerer Knoten:
+ Seite 1 behaelt (n+1)/2
+ Seite 2 erhaelt (n/2-1)
+ Knoten ((n+1)/2 + 1) : wird herausgenommen
+ */
+ ONDXNode aResultNode;
+ if (IsLeaf())
+ {
+ for (USHORT i = (nCount - (nCount / 2)), j = 0 ; i < nCount; i++)
+ rPage.Insert(j++,(*this)[i]);
+
+ // dieser Knoten enthaelt einen Schluessel der noch einmal im Tree vorkommt
+ // und ersetzt werden muss
+ ONDXNode aLastNode = (*this)[nCount - 1];
+ nCount = nCount - (nCount / 2);
+ aResultNode = (*this)[nCount - 1];
+
+ if (HasParent())
+ aParent->SearchAndReplace(aLastNode.GetKey(),
+ aResultNode.GetKey());
+ }
+ else
+ {
+ for (USHORT i = (nCount + 1) / 2 + 1, j = 0 ; i < nCount; i++)
+ rPage.Insert(j++,(*this)[i]);
+
+ aResultNode = (*this)[(nCount + 1) / 2];
+ nCount = (nCount + 1) / 2;
+
+ // neue Seite zeigt nun auf Seite des herausgeloesten Knoten
+ rPage.SetChild(aResultNode.GetChild());
+ }
+ // Knoten zeigt auf neue Seite
+ aResultNode.SetChild(&rPage);
+
+ // innere Knoten haben keine Recordnummer
+ if (rIndex.isUnique())
+ aResultNode.GetKey().ResetRecord();
+ bModified = TRUE;
+ return aResultNode;
+}
+
+//------------------------------------------------------------------
+void ONDXPage::Merge(USHORT nParentNodePos, ONDXPagePtr xPage)
+{
+ DBG_ASSERT(HasParent(), "kein Vater vorhanden");
+ DBG_ASSERT(nParentNodePos != NODE_NOTFOUND, "Falscher Indexaufbau");
+
+ /* Zusammenlegen zweier Seiten */
+ ONDXNode aResultNode;
+ USHORT nMaxNodes = rIndex.GetMaxNodes(),
+ nMaxNodes_2 = nMaxNodes / 2;
+
+ // Feststellen ob Seite rechter oder linker Nachbar
+ BOOL bRight = ((*xPage)[0].GetKey() > (*this)[0].GetKey()); // TRUE, wenn xPage die rechte Seite ist
+ USHORT nNewCount = (*xPage).Count() + Count();
+
+ if (IsLeaf())
+ {
+ // Bedingung fuers zusammenlegen
+ if (nNewCount < (nMaxNodes_2 * 2))
+ {
+ USHORT nLastNode = bRight ? Count() - 1 : xPage->Count() - 1;
+ if (bRight)
+ {
+ DBG_ASSERT(&xPage != this,"xPage und THIS duerfen nicht gleich sein: Endlosschleife");
+ // alle Knoten aus xPage auf den linken Knoten verschieben (anhaengen)
+ while (xPage->Count())
+ {
+ Append((*xPage)[0]);
+ xPage->Remove(0);
+ }
+ }
+ else
+ {
+ DBG_ASSERT(&xPage != this,"xPage und THIS duerfen nicht gleich sein: Endlosschleife");
+ // xPage ist die linke Page und THIS die rechte
+ while (xPage->Count())
+ {
+ Insert(0,(*xPage)[xPage->Count()-1]);
+ xPage->Remove(xPage->Count()-1);
+ }
+ // alte Position von xPage beim Parent mit this ersetzen
+ if (nParentNodePos)
+ (*aParent)[nParentNodePos-1].SetChild(this,aParent);
+ else // oder als rechten Knoten setzen
+ aParent->SetChild(this);
+ aParent->SetModified(TRUE);
+
+ }
+
+ // Child beziehung beim Vaterknoten aufheben
+ (*aParent)[nParentNodePos].SetChild();
+ // Austauschen des KnotenWertes, nur wenn geaenderte Page
+ // die linke ist, ansonsten werde
+
+ if(aParent->IsRoot() && aParent->Count() == 1)
+ {
+ (*aParent)[0].SetChild();
+ aParent->ReleaseFull();
+ aParent = NULL;
+ rIndex.SetRootPos(nPagePos);
+ rIndex.m_aRoot = this;
+ SetModified(TRUE);
+ }
+ else
+ aParent->SearchAndReplace((*this)[nLastNode].GetKey(),(*this)[nCount-1].GetKey());
+
+ xPage->SetModified(FALSE);
+ xPage->ReleaseFull(); // wird nicht mehr benoetigt
+ }
+ // Ausgleichen der Elemente nNewCount >= (nMaxNodes_2 * 2)
+ else
+ {
+ if (bRight)
+ {
+ // alle Knoten aus xPage auf den linken Knoten verschieben (anhaengen)
+ ONDXNode aReplaceNode = (*this)[nCount - 1];
+ while (nCount < nMaxNodes_2)
+ {
+ Append((*xPage)[0]);
+ xPage->Remove(0);
+ }
+ // Austauschen des KnotenWertes: Setzt alten letzten Wert durch den letzten von xPage
+ aParent->SearchAndReplace(aReplaceNode.GetKey(),(*this)[nCount-1].GetKey());
+ }
+ else
+ {
+ // alle Knoten aus this vor die xPage Knoten einfuegen
+ ONDXNode aReplaceNode = (*this)[nCount - 1];
+ while (xPage->Count() < nMaxNodes_2)
+ {
+ xPage->Insert(0,(*this)[nCount-1]);
+ Remove(nCount-1);
+ }
+ // Austauschen des KnotenWertes
+ aParent->SearchAndReplace(aReplaceNode.GetKey(),(*this)[Count()-1].GetKey());
+ }
+ }
+ }
+ else // !IsLeaf()
+ {
+ // Bedingung fuers zusammenlegen
+ if (nNewCount < nMaxNodes_2 * 2)
+ {
+ if (bRight)
+ {
+ DBG_ASSERT(&xPage != this,"xPage und THIS duerfen nicht gleich sein: Endlosschleife");
+ // Vaterknoten wird mit integriert
+ // erhaelt zunaechst Child von xPage
+ (*aParent)[nParentNodePos].SetChild(xPage->GetChild(),aParent);
+ Append((*aParent)[nParentNodePos]);
+ for (USHORT i = 0 ; i < xPage->Count(); i++)
+ Append((*xPage)[i]);
+ }
+ else
+ {
+ DBG_ASSERT(&xPage != this,"xPage und THIS duerfen nicht gleich sein: Endlosschleife");
+ // Vaterknoten wird mit integriert
+ // erhaelt zunaechst Child
+ (*aParent)[nParentNodePos].SetChild(GetChild(),aParent); // Parent merkt sich mein Child
+ Insert(0,(*aParent)[nParentNodePos]); // Node vom Parent bei mir einfuegen
+ while (xPage->Count())
+ {
+ Insert(0,(*xPage)[xPage->Count()-1]);
+ xPage->Remove(xPage->Count()-1);
+ }
+ SetChild(xPage->GetChild());
+
+ if (nParentNodePos)
+ (*aParent)[nParentNodePos-1].SetChild(this,aParent);
+ else
+ aParent->SetChild(this);
+ }
+
+ // danach wird der Vaterknoten zurueckgesetzt
+ (*aParent)[nParentNodePos].SetChild();
+ aParent->SetModified(TRUE);
+
+ if(aParent->IsRoot() && aParent->Count() == 1)
+ {
+ (*aParent).SetChild();
+ aParent->ReleaseFull();
+ aParent = NULL;
+ rIndex.SetRootPos(nPagePos);
+ rIndex.m_aRoot = this;
+ SetModified(TRUE);
+ }
+ else if(nParentNodePos)
+ // Austauschen des KnotenWertes
+ // beim Append wird der Bereich erweitert, beim INsert verweist der alte Knoten von xPage auf this
+ // deshalb muss der Knoten auch hier aktualisiert werden
+ aParent->SearchAndReplace((*aParent)[nParentNodePos-1].GetKey(),(*aParent)[nParentNodePos].GetKey());
+
+ xPage->SetModified(FALSE);
+ xPage->ReleaseFull();
+ }
+ // Ausgleichen der Elemente
+ else
+ {
+ if (bRight)
+ {
+ while (nCount < nMaxNodes_2)
+ {
+ (*aParent)[nParentNodePos].SetChild(xPage->GetChild(),aParent);
+ Append((*aParent)[nParentNodePos]);
+ (*aParent)[nParentNodePos] = (*xPage)[0];
+ xPage->Remove(0);
+ }
+ xPage->SetChild((*aParent)[nParentNodePos].GetChild());
+ (*aParent)[nParentNodePos].SetChild(xPage,aParent);
+ }
+ else
+ {
+ while (nCount < nMaxNodes_2)
+ {
+ (*aParent)[nParentNodePos].SetChild(GetChild(),aParent);
+ Insert(0,(*aParent)[nParentNodePos]);
+ (*aParent)[nParentNodePos] = (*xPage)[xPage->Count()-1];
+ xPage->Remove(xPage->Count()-1);
+ }
+ SetChild((*aParent)[nParentNodePos].GetChild());
+ (*aParent)[nParentNodePos].SetChild(this,aParent);
+
+ }
+ aParent->SetModified(TRUE);
+ }
+ }
+}
+//==================================================================
+// ONDXNode
+//==================================================================
+
+//------------------------------------------------------------------
+void ONDXNode::Read(SvStream &rStream, ODbaseIndex& rIndex)
+{
+ rStream >> aKey.nRecord; // schluessel
+
+ if (rIndex.getHeader().db_keytype)
+ {
+ double aDbl;
+ rStream >> aDbl;
+ aKey = ONDXKey(aDbl,aKey.nRecord);
+ }
+ else
+ {
+ ByteString aBuf;
+ USHORT nLen = rIndex.getHeader().db_keylen;
+ char* pStr = aBuf.AllocBuffer(nLen+1);
+
+ rStream.Read(pStr,nLen);
+ pStr[nLen] = 0;
+ aBuf.ReleaseBufferAccess();
+ aBuf.EraseTrailingChars();
+
+ // aKey = ONDXKey((aBuf,rIndex.GetDBFConnection()->GetCharacterSet()) ,aKey.nRecord);
+ aKey = ONDXKey(::rtl::OUString(aBuf.GetBuffer(),aBuf.Len(),rIndex.m_pTable->getConnection()->getTextEncoding()) ,aKey.nRecord);
+ }
+ rStream >> aChild;
+}
+
+union NodeData
+{
+ double aDbl;
+ char aData[128];
+} aNodeData;
+//------------------------------------------------------------------
+void ONDXNode::Write(SvStream &rStream, const ONDXPage& rPage) const
+{
+ const ODbaseIndex& rIndex = rPage.GetIndex();
+ if (!rIndex.isUnique() || rPage.IsLeaf())
+ rStream << (sal_uInt32)aKey.nRecord; // schluessel
+ else
+ rStream << (sal_uInt32)0; // schluessel
+
+ if (rIndex.getHeader().db_keytype) // double
+ {
+ if (aKey.getValue().isNull())
+ {
+ memset(aNodeData.aData,0,rIndex.getHeader().db_keylen);
+ rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
+ }
+ else
+ rStream << (double) aKey.getValue();
+ }
+ else
+ {
+ memset(aNodeData.aData,0x20,rIndex.getHeader().db_keylen);
+ if (!aKey.getValue().isNull())
+ {
+ ::rtl::OUString sValue = aKey.getValue();
+ ByteString aText(sValue.getStr(), rIndex.m_pTable->getConnection()->getTextEncoding());
+ strncpy(aNodeData.aData,aText.GetBuffer(),std::min(rIndex.getHeader().db_keylen, aText.Len()));
+ }
+ rStream.Write((BYTE*)aNodeData.aData,rIndex.getHeader().db_keylen);
+ }
+ rStream << aChild;
+}
+
+
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXNode::GetChild(ODbaseIndex* pIndex, ONDXPage* pParent)
+{
+ if (!aChild.Is() && pIndex)
+ {
+ aChild = pIndex->CreatePage(aChild.GetPagePos(),pParent,aChild.HasPage());
+ }
+ return aChild;
+}
+
+//==================================================================
+// ONDXKey
+//==================================================================
+//------------------------------------------------------------------
+BOOL ONDXKey::IsText(sal_Int32 eType)
+{
+ return eType == DataType::VARCHAR || eType == DataType::CHAR;
+}
+
+//------------------------------------------------------------------
+StringCompare ONDXKey::Compare(const ONDXKey& rKey) const
+{
+ // DBG_ASSERT(is(), "Falscher Indexzugriff");
+ StringCompare eResult;
+
+ if (getValue().isNull())
+ {
+ if (rKey.getValue().isNull() || (rKey.IsText(getDBType()) && !rKey.getValue().getString().getLength()))
+ eResult = COMPARE_EQUAL;
+ else
+ eResult = COMPARE_LESS;
+ }
+ else if (rKey.getValue().isNull())
+ {
+ if (getValue().isNull() || (IsText(getDBType()) && !getValue().getString().getLength()))
+ eResult = COMPARE_EQUAL;
+ else
+ eResult = COMPARE_GREATER;
+ }
+ else if (IsText(getDBType()))
+ {
+ INT32 nRes = getValue().getString().compareTo(rKey.getValue());
+ eResult = (nRes > 0) ? COMPARE_GREATER : (nRes == 0) ? COMPARE_EQUAL : COMPARE_LESS;
+ }
+ else
+ {
+ double m = getValue(),n = rKey.getValue();
+ eResult = (m > n) ? COMPARE_GREATER : (n == m) ? COMPARE_EQUAL : COMPARE_LESS;
+ }
+
+ // Record vergleich, wenn Index !Unique
+ if (eResult == COMPARE_EQUAL && nRecord && rKey.nRecord)
+ eResult = (nRecord > rKey.nRecord) ? COMPARE_GREATER :
+ (nRecord == rKey.nRecord) ? COMPARE_EQUAL : COMPARE_LESS;
+
+ return eResult;
+}
+// -----------------------------------------------------------------------------
+void ONDXKey::setValue(const ORowSetValue& _rVal)
+{
+ xValue = _rVal;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& ONDXKey::getValue() const
+{
+ return xValue;
+}
+// -----------------------------------------------------------------------------
+SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPagePtr& rPage)
+{
+ rStream >> rPage.nPagePos;
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPagePtr& rPage)
+{
+ rStream << rPage.nPagePos;
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+//==================================================================
+// ONDXPagePtr
+//==================================================================
+//------------------------------------------------------------------
+ONDXPagePtr::ONDXPagePtr(const ONDXPagePtr& rRef)
+ :ONDXPageRef(rRef)
+ ,nPagePos(rRef.nPagePos)
+{
+}
+
+//------------------------------------------------------------------
+ONDXPagePtr::ONDXPagePtr(ONDXPage* pRefPage)
+ :ONDXPageRef(pRefPage)
+ ,nPagePos(0)
+{
+ if (pRefPage)
+ nPagePos = pRefPage->GetPagePos();
+}
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXPagePtr::operator=(const ONDXPagePtr& rRef)
+{
+ ONDXPageRef::operator=(rRef);
+ nPagePos = rRef.nPagePos;
+ return *this;
+}
+
+//------------------------------------------------------------------
+ONDXPagePtr& ONDXPagePtr::operator= (ONDXPage* pRef)
+{
+ ONDXPageRef::operator=(pRef);
+ nPagePos = (pRef) ? pRef->GetPagePos() : 0;
+ return *this;
+}
+// -----------------------------------------------------------------------------
+static UINT32 nValue;
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator >> (SvStream &rStream, ONDXPage& rPage)
+{
+ rStream.Seek(rPage.GetPagePos() * PAGE_SIZE);
+ rStream >> nValue >> rPage.aChild;
+ rPage.nCount = USHORT(nValue);
+
+// DBG_ASSERT(rPage.nCount && rPage.nCount < rPage.GetIndex().GetMaxNodes(), "Falscher Count");
+ for (USHORT i = 0; i < rPage.nCount; i++)
+ rPage[i].Read(rStream, rPage.GetIndex());
+ return rStream;
+}
+
+//------------------------------------------------------------------
+SvStream& connectivity::dbase::operator << (SvStream &rStream, const ONDXPage& rPage)
+{
+ // Seite existiert noch nicht
+ ULONG nSize = (rPage.GetPagePos() + 1) * PAGE_SIZE;
+ if (nSize > rStream.Seek(STREAM_SEEK_TO_END))
+ {
+ rStream.SetStreamSize(nSize);
+ rStream.Seek(rPage.GetPagePos() * PAGE_SIZE);
+
+ char aEmptyData[PAGE_SIZE];
+ memset(aEmptyData,0x00,PAGE_SIZE);
+ rStream.Write((BYTE*)aEmptyData,PAGE_SIZE);
+ }
+ ULONG nCurrentPos = rStream.Seek(rPage.GetPagePos() * PAGE_SIZE);
+ OSL_UNUSED( nCurrentPos );
+
+ nValue = rPage.nCount;
+ rStream << nValue << rPage.aChild;
+
+ USHORT i = 0;
+ for (; i < rPage.nCount; i++)
+ rPage[i].Write(rStream, rPage);
+
+ // check if we have to fill the stream with '\0'
+ if(i < rPage.rIndex.getHeader().db_maxkeys)
+ {
+ ULONG nTell = rStream.Tell() % PAGE_SIZE;
+ USHORT nBufferSize = rStream.GetBufferSize();
+ ULONG nRemainSize = nBufferSize - nTell;
+ char* pEmptyData = new char[nRemainSize];
+ memset(pEmptyData,0x00,nRemainSize);
+ rStream.Write((BYTE*)pEmptyData,nRemainSize);
+ rStream.Seek(nTell);
+ delete [] pEmptyData;
+ }
+ return rStream;
+}
+// -----------------------------------------------------------------------------
+#if OSL_DEBUG_LEVEL > 1
+//------------------------------------------------------------------
+void ONDXPage::PrintPage()
+{
+ DBG_TRACE4("\nSDB: -----------Page: %d Parent: %d Count: %d Child: %d-----",
+ nPagePos, HasParent() ? aParent->GetPagePos() : 0 ,nCount, aChild.GetPagePos());
+
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ ONDXNode rNode = (*this)[i];
+ ONDXKey& rKey = rNode.GetKey();
+ if (!IsLeaf())
+ rNode.GetChild(&rIndex, this);
+
+ if (rKey.getValue().isNull())
+ {
+ DBG_TRACE2("SDB: [%d,NULL,%d]",rKey.GetRecord(), rNode.GetChild().GetPagePos());
+ }
+ else if (rIndex.getHeader().db_keytype)
+ {
+ DBG_TRACE3("SDB: [%d,%f,%d]",rKey.GetRecord(), rKey.getValue().getDouble(),rNode.GetChild().GetPagePos());
+ }
+ else
+ {
+ DBG_TRACE3("SDB: [%d,%s,%d]",rKey.GetRecord(), (const char* )ByteString(rKey.getValue().getString().getStr(), rIndex.m_pTable->getConnection()->getTextEncoding()).GetBuffer(),rNode.GetChild().GetPagePos());
+ }
+ }
+ DBG_TRACE("SDB: -----------------------------------------------\n");
+ if (!IsLeaf())
+ {
+#if OSL_DEBUG_LEVEL > 1
+ GetChild(&rIndex)->PrintPage();
+ for (USHORT i = 0; i < nCount; i++)
+ {
+ ONDXNode rNode = (*this)[i];
+ rNode.GetChild(&rIndex,this)->PrintPage();
+ }
+#endif
+ }
+ DBG_TRACE("SDB: ===============================================\n");
+}
+#endif
+// -----------------------------------------------------------------------------
+BOOL ONDXPage::IsFull() const
+{
+ return Count() == rIndex.getHeader().db_maxkeys;
+}
+// -----------------------------------------------------------------------------
+//------------------------------------------------------------------
+USHORT ONDXPage::Search(const ONDXKey& rSearch)
+{
+ // binare Suche spaeter
+ USHORT i = NODE_NOTFOUND;
+ while (++i < Count())
+ if ((*this)[i].GetKey() == rSearch)
+ break;
+
+ return (i < Count()) ? i : NODE_NOTFOUND;
+}
+
+//------------------------------------------------------------------
+USHORT ONDXPage::Search(const ONDXPage* pPage)
+{
+ USHORT i = NODE_NOTFOUND;
+ while (++i < Count())
+ if (((*this)[i]).GetChild() == pPage)
+ break;
+
+ // wenn nicht gefunden, dann wird davon ausgegangen, dass die Seite selbst
+ // auf die Page zeigt
+ return (i < Count()) ? i : NODE_NOTFOUND;
+}
+// -----------------------------------------------------------------------------
+// laeuft rekursiv
+void ONDXPage::SearchAndReplace(const ONDXKey& rSearch,
+ ONDXKey& rReplace)
+{
+ OSL_ENSURE(rSearch != rReplace,"Invalid here:rSearch == rReplace");
+ if (rSearch != rReplace)
+ {
+ USHORT nPos = NODE_NOTFOUND;
+ ONDXPage* pPage = this;
+
+ while (pPage && (nPos = pPage->Search(rSearch)) == NODE_NOTFOUND)
+ pPage = pPage->aParent;
+
+ if (pPage)
+ {
+ (*pPage)[nPos].GetKey() = rReplace;
+ pPage->SetModified(TRUE);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+ONDXNode& ONDXPage::operator[] (USHORT nPos)
+{
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+ return ppNodes[nPos];
+}
+
+//------------------------------------------------------------------
+const ONDXNode& ONDXPage::operator[] (USHORT nPos) const
+{
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+ return ppNodes[nPos];
+}
+// -----------------------------------------------------------------------------
+void ONDXPage::Remove(USHORT nPos)
+{
+ DBG_ASSERT(nCount > nPos, "falscher Indexzugriff");
+
+ for (USHORT i = nPos; i < (nCount-1); i++)
+ (*this)[i] = (*this)[i+1];
+
+ nCount--;
+ bModified = TRUE;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/dbase/exports.dxp b/connectivity/source/drivers/dbase/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/dbase/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/dbase/makefile.mk b/connectivity/source/drivers/dbase/makefile.mk
new file mode 100644
index 000000000000..f855cf1f4554
--- /dev/null
+++ b/connectivity/source/drivers/dbase/makefile.mk
@@ -0,0 +1,129 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=dbase
+
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/DCode.obj \
+ $(SLO)$/DResultSet.obj \
+ $(SLO)$/DStatement.obj \
+ $(SLO)$/DPreparedStatement.obj \
+ $(SLO)$/dindexnode.obj \
+ $(SLO)$/DIndexIter.obj \
+ $(SLO)$/DDatabaseMetaData.obj \
+ $(SLO)$/DCatalog.obj \
+ $(SLO)$/DColumns.obj \
+ $(SLO)$/DIndexColumns.obj \
+ $(SLO)$/DIndex.obj \
+ $(SLO)$/DIndexes.obj \
+ $(SLO)$/DTable.obj \
+ $(SLO)$/DTables.obj \
+ $(SLO)$/DConnection.obj \
+ $(SLO)$/Dservices.obj \
+ $(SLO)$/DDriver.obj
+
+EXCEPTIONSFILES=\
+ $(SLO)$/DCode.obj \
+ $(SLO)$/DResultSet.obj \
+ $(SLO)$/DStatement.obj \
+ $(SLO)$/DPreparedStatement.obj \
+ $(SLO)$/dindexnode.obj \
+ $(SLO)$/DIndexIter.obj \
+ $(SLO)$/DDatabaseMetaData.obj \
+ $(SLO)$/DCatalog.obj \
+ $(SLO)$/DColumns.obj \
+ $(SLO)$/DIndexColumns.obj \
+ $(SLO)$/DIndex.obj \
+ $(SLO)$/DIndexes.obj \
+ $(SLO)$/DTables.obj \
+ $(SLO)$/DConnection.obj \
+ $(SLO)$/Dservices.obj \
+ $(SLO)$/DDriver.obj
+
+# [kh] ppc linux gcc compiler problem
+.IF "$(OS)$(COM)$(CPUNAME)"=="LINUXGCCPOWERPC"
+EXCEPTIONSNOOPTFILES= \
+ $(SLO)$/DTable.obj
+.ELSE
+EXCEPTIONSFILES +=\
+ $(SLO)$/DTable.obj
+.ENDIF
+
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBFILELIB)" == ""
+SHL1STDLIBS+= ifile.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(DBASE_TARGET)
+
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/evoab/LCatalog.cxx b/connectivity/source/drivers/evoab/LCatalog.cxx
new file mode 100644
index 000000000000..cffc1e4363ef
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LCatalog.cxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "LCatalog.hxx"
+#include "LConnection.hxx"
+#include "LTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+using namespace connectivity::evoab;
+// -------------------------------------------------------------------------
+OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+void OEvoabCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/evoab/LCatalog.hxx b/connectivity/source/drivers/evoab/LCatalog.hxx
new file mode 100644
index 000000000000..a6b4aa9f6180
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LCatalog.hxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LCATALOG_HXX_
+#define _CONNECTIVITY_EVOAB_LCATALOG_HXX_
+
+#include "file/FCatalog.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabConnection;
+ class OEvoabCatalog : public file::OFileCatalog
+ {
+ public:
+ virtual void refreshTables();
+
+ public:
+ OEvoabCatalog(OEvoabConnection* _pCon);
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LCATALOG_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LColumnAlias.cxx b/connectivity/source/drivers/evoab/LColumnAlias.cxx
new file mode 100644
index 000000000000..f8fbc2f8e991
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LColumnAlias.cxx
@@ -0,0 +1,232 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LColumnAlias.hxx"
+#include "LDriver.hxx"
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include "LConfigAccess.hxx"
+
+using namespace ::connectivity;
+using namespace ::connectivity::evoab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+static const ::rtl::OUString sProgrammaticNames[] =
+{
+ ::rtl::OUString::createFromAscii("FirstName"),
+ ::rtl::OUString::createFromAscii("LastName"),
+ ::rtl::OUString::createFromAscii("DisplayName"),
+ ::rtl::OUString::createFromAscii("NickName"),
+ ::rtl::OUString::createFromAscii("PrimaryEmail"),
+ ::rtl::OUString::createFromAscii("SecondEmail"),
+ ::rtl::OUString::createFromAscii("PreferMailFormat"),
+ ::rtl::OUString::createFromAscii("WorkPhone"),
+ ::rtl::OUString::createFromAscii("HomePhone"),
+ ::rtl::OUString::createFromAscii("FaxNumber"),
+ ::rtl::OUString::createFromAscii("PagerNumber"),
+ ::rtl::OUString::createFromAscii("CellularNumber"),
+ ::rtl::OUString::createFromAscii("HomeAddress"),
+ ::rtl::OUString::createFromAscii("HomeAddress2"),
+ ::rtl::OUString::createFromAscii("HomeCity"),
+ ::rtl::OUString::createFromAscii("HomeState"),
+ ::rtl::OUString::createFromAscii("HomeZipCode"),
+ ::rtl::OUString::createFromAscii("HomeCountry"),
+ ::rtl::OUString::createFromAscii("WorkAddress"),
+ ::rtl::OUString::createFromAscii("WorkAddress2"),
+ ::rtl::OUString::createFromAscii("WorkCity"),
+ ::rtl::OUString::createFromAscii("WorkState"),
+ ::rtl::OUString::createFromAscii("WorkZipCode"),
+ ::rtl::OUString::createFromAscii("WorkCountry"),
+ ::rtl::OUString::createFromAscii("JobTitle"),
+ ::rtl::OUString::createFromAscii("Department"),
+ ::rtl::OUString::createFromAscii("Company"),
+ ::rtl::OUString::createFromAscii("WebPage1"),
+ ::rtl::OUString::createFromAscii("WebPage2"),
+ ::rtl::OUString::createFromAscii("BirthYear"),
+ ::rtl::OUString::createFromAscii("BirthMonth"),
+ ::rtl::OUString::createFromAscii("BirthDay"),
+ ::rtl::OUString::createFromAscii("Notes")
+};
+//------------------------------------------------------------------------------
+OColumnAlias::OColumnAlias()
+{
+ // Initialise m_aAlias with the default values from sProgrammaticNames.
+ initialise();
+
+ // Initialise m_aAlias map with the default values from sProgrammaticNames.
+ setAliasMap();
+}
+//------------------------------------------------------------------
+OColumnAlias::~OColumnAlias()
+{
+}
+//------------------------------------------------------------------
+void OColumnAlias::initialise()
+{
+ m_aAlias.reserve( END - FIRSTNAME + 1 );
+ for (sal_Int32 i(FIRSTNAME); i < END; ++i)
+ {
+ m_aAlias.push_back(sProgrammaticNames[i]);
+ m_aHeadLineNames.push_back(sProgrammaticNames[i]);
+ }
+
+ return;
+}
+//------------------------------------------------------------------
+void OColumnAlias::setAlias(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
+{
+ OSL_TRACE("OColumnAlias::setAlias()entered");
+
+ // open our driver settings config node
+
+ // the config path for our own driver's settings
+ Reference< XPropertySet > xEvoDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() );
+ //Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, mozab::OConnection::getDriverImplementationName() );
+ Reference< XPropertySet > xMozDriverNode = createDriverConfigNode( _rxORB, ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver") );
+ if ( xEvoDriverNode.is() && xMozDriverNode.is() )
+ {
+ try
+ {
+ //=============================================================
+ Reference< XNameAccess > xEvoAliasesNode;
+ Reference< XNameAccess > xMozAliasesNode;
+ xEvoDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xEvoAliasesNode;
+ xMozDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii("ColumnAliases") ) >>= xMozAliasesNode;
+ OSL_ENSURE( xEvoAliasesNode.is(), "OColumnAlias::setAlias: missing the evolution aliases node!" );
+ OSL_ENSURE( xMozAliasesNode.is(), "OColumnAlias::setAlias: missing the mozilla aliases node!" );
+
+ // this is a set of string nodes
+ Sequence< ::rtl::OUString > aColumnProgrammaticNames;
+ //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getElementNames()");
+ if ( xEvoAliasesNode.is() )
+ aColumnProgrammaticNames = xEvoAliasesNode->getElementNames();
+ //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getElementNames()");
+
+ //=============================================================
+ // travel through all the set elements
+ const ::rtl::OUString* pProgrammaticNames = aColumnProgrammaticNames.getConstArray();
+ const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aColumnProgrammaticNames.getLength();
+ ::rtl::OUString sAssignedAlias;
+ ::rtl::OUString sHeadLineName;
+
+ for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames )
+ {
+ //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammaticNames = %s\n", ((OUtoCStr(*pProgrammaticNames)) ? (OUtoCStr(*pProgrammaticNames)):("NULL")) );
+ OSL_ENSURE( m_aAliasMap.end() != m_aAliasMap.find( *pProgrammaticNames ),
+ "OColumnAlias::setAlias: found an invalid programmtic name!" );
+ // if this asserts, somebody stored a programmatic name in the configuration
+ // which is not allowed (i.e. not in the list of known programmatics).
+ //OSL_TRACE("OColumnAlias::setAlias()before xAliasesNode->getByName()");
+
+#if OSL_DEBUG_LEVEL > 0
+ sal_Bool bExtractionSuccess =
+#endif
+ xMozAliasesNode->getByName( *pProgrammaticNames) >>= sAssignedAlias;
+ OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid mozilla config data!" );
+#if OSL_DEBUG_LEVEL > 0
+ bExtractionSuccess =
+#endif
+ xEvoAliasesNode->getByName( *pProgrammaticNames) >>= sHeadLineName;
+ OSL_ENSURE( bExtractionSuccess, "OColumnAlias::setAlias: invalid evolution config data!" );
+ //OSL_TRACE("OColumnAlias::setAlias()after xAliasesNode->getByName()");
+
+ // normalize in case the config data is corrupted
+ // (what we really don't need is an empty alias ...)
+ if ( 0 == sAssignedAlias.getLength() )
+ sAssignedAlias = *pProgrammaticNames;
+ if ( 0 == sHeadLineName.getLength() )
+ sHeadLineName = *pProgrammaticNames;
+ //OSL_TRACE("OColumnAlias::setAlias()::sAssignedAlias = %s\n", ((OUtoCStr(sAssignedAlias)) ? (OUtoCStr(sAssignedAlias)):("NULL")) );
+ //OSL_TRACE("OColumnAlias::setAlias()::sHeadLineName = %s\n", ((OUtoCStr(sHeadLineName)) ? (OUtoCStr(sHeadLineName)):("NULL")) );
+
+ //=============================================================
+ // check the value
+ // look up the programmatic indicated by pProgrammaticNames in the known programmatics
+ const ::rtl::OUString* pProgrammatic = sProgrammaticNames + FIRSTNAME;
+ const ::rtl::OUString* pProgrammaticEnd = sProgrammaticNames + END;
+
+ OSL_ENSURE( (sal_Int32)m_aAlias.size() == pProgrammaticEnd - pProgrammatic,
+ "OColumnAlias::setAlias: aliases vector not yet initialized!" );
+
+ // the destination where we want to remember the alias
+ ::std::vector< ::rtl::OUString >::iterator aAlias = m_aAlias.begin();
+ ::std::vector< ::rtl::OUString >::iterator aHeadLineName = m_aHeadLineNames.begin();
+
+ for ( ; pProgrammatic < pProgrammaticEnd; ++pProgrammatic, ++aAlias, ++aHeadLineName )
+ {
+ //OSL_TRACE("OColumnAlias::setAlias()::*pProgrammatic = %s\n", ((OUtoCStr(*pProgrammatic)) ? (OUtoCStr(*pProgrammatic)):("NULL")) );
+ if ( pProgrammaticNames->equals( *pProgrammatic ) )
+ {
+ // add alias to the vector
+ *aAlias = sAssignedAlias;
+ *aHeadLineName = sHeadLineName;
+ break;
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "OColumnAlias::setAlias: could not read my driver's configuration data!" );
+ }
+ }
+
+ // Initialise m_aAliasMap.
+ setAliasMap();
+
+ return;
+}
+//------------------------------------------------------------------
+const ::std::vector< ::rtl::OUString> & OColumnAlias::getAlias() const
+{
+ return m_aAlias;
+}
+//------------------------------------------------------------------
+const ::std::map< ::rtl::OUString, ::rtl::OUString> & OColumnAlias::getAliasMap() const
+{
+ return m_aAliasMap;
+}
+//------------------------------------------------------------------
+void OColumnAlias::setAliasMap()
+{
+ // Fill the map with the values of m_aAlias
+ // and the sProgrammaticNames array.
+ for (sal_Int32 i(FIRSTNAME); i < END; ++i) {
+ m_aAliasMap[m_aAlias[i]] = m_aHeadLineNames[i];
+ //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAlias[i] = %s\n", ((OUtoCStr(m_aAlias[i])) ? (OUtoCStr(m_aAlias[i])):("NULL")) );
+ //OSL_TRACE("OColumnAlias::setAliasMap()::m_aAliasMap[m_aAlias[i]] = %s\n", ((OUtoCStr(m_aAliasMap[m_aAlias[i]])) ? (OUtoCStr(m_aAliasMap[m_aAlias[i]])):("NULL")) );
+ }
+
+ return;
+}
+//------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab/LColumnAlias.hxx b/connectivity/source/drivers/evoab/LColumnAlias.hxx
new file mode 100644
index 000000000000..374a1d08fedf
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LColumnAlias.hxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_
+#define _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_
+
+#include <unotools/confignode.hxx>
+
+#include <osl/mutex.hxx>
+#include <vector>
+#include <map>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ typedef enum {
+ FIRSTNAME = 0,
+ LASTNAME,
+ DISPLAYNAME,
+ NICKNAME,
+ PRIMARYEMAIL,
+ SECONDEMAIL,
+ PREFERMAILFORMAT,
+ WORKPHONE,
+ HOMEPHONE,
+ FAXNUMBER,
+ PAGERNUMBER,
+ CELLULARNUMBER,
+ HOMEADDRESS,
+ HOMEADDRESS2,
+ HOMECITY,
+ HOMESTATE,
+ HOMEZIPCODE,
+ HOMECOUNTRY,
+ WORKADDRESS,
+ WORKADDRESS2,
+ WORKCITY,
+ WORKSTATE,
+ WORKZIPCODE,
+ WORKCOUNTRY,
+ JOBTITLE,
+ DEPARTMENT,
+ COMPANY,
+ WEBPAGE1,
+ WEBPAGE2,
+ BIRTHYEAR,
+ BIRTHMONTH,
+ BIRTHDAY,
+ NOTES,
+ END
+ } ProgrammaticName;
+
+ class OColumnAlias
+ {
+ /**
+ * m_Alias holds aliases for the evolution addressbook
+ * column names. This member gets initialised during
+ * creation of the connection to the driver.
+ * m_aAlias initialises m_aAliasMap which then can be
+ * used to find the corresponding programmatic name
+ * when an alias is used as a query attribute. Mozilla
+ * expects programmatic names from its clients.
+ *
+ * m_aAlias: vector of aliases used to initialise m_aAliasMap.
+ * m_AliasMap: map of {alias, programmaticname} pairs.
+ *
+ */
+ private:
+ ::std::vector< ::rtl::OUString> m_aAlias;
+ ::std::vector< ::rtl::OUString> m_aHeadLineNames;
+ ::std::map< ::rtl::OUString, ::rtl::OUString> m_aAliasMap;
+ protected:
+ ::osl::Mutex m_aMutex;
+ public:
+ void initialise(void);
+ const ::std::vector< ::rtl::OUString> & getAlias(void) const;
+ const ::std::map< ::rtl::OUString, ::rtl::OUString> & getAliasMap(void) const;
+ void setAlias(const ::com::sun::star::uno::Reference<
+ ::com::sun::star::lang::XMultiServiceFactory > &);
+ private:
+ void setAliasMap(void);
+ public:
+ OColumnAlias(void);
+ ~OColumnAlias(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LCOLUMNALIAS_HXX_
diff --git a/connectivity/source/drivers/evoab/LColumns.cxx b/connectivity/source/drivers/evoab/LColumns.cxx
new file mode 100644
index 000000000000..58f8819da872
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LColumns.cxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "LColumns.hxx"
+#include "LTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::evoab;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ OEvoabTable* pTable = (OEvoabTable*)m_pTable;
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+ sdbcx::ObjectType xRet;
+ if(aIter != aCols->get().end())
+ xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/evoab/LColumns.hxx b/connectivity/source/drivers/evoab/LColumns.hxx
new file mode 100644
index 000000000000..2fe90cc98d66
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LColumns.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_
+#define _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_
+
+#include "file/FColumns.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabColumns : public file::OColumns
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OEvoabColumns(file::OFileTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : file::OColumns(_pTable,_rMutex,_rVector)
+ {}
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LCOLUMNS_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LConfigAccess.cxx b/connectivity/source/drivers/evoab/LConfigAccess.cxx
new file mode 100644
index 000000000000..f2c3050613e4
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LConfigAccess.cxx
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LConfigAccess.hxx"
+#include "LDriver.hxx"
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#include "LDebug.hxx"
+#endif
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+//.........................................................................
+namespace connectivity
+{
+ namespace evoab
+ {
+ //-----------------------------------------------------------------
+ Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName )
+ {
+ OSL_TRACE("createDriverConfigNode()entered");
+
+ Reference< XPropertySet > xNode;
+ try
+ {
+ //=============================================================
+ // create the config provider
+ Reference< XMultiServiceFactory > xConfigProvider(
+ _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" );
+
+ if ( xConfigProvider.is() )
+ {
+ ::rtl::OUString sCompleteNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Office.DataAccess/DriverSettings/" );
+ sCompleteNodePath += _sDriverImplementationName;
+ //sCompleteNodePath += OEvoabConnection::getDriverImplementationName();
+ //sCompleteNodePath += ::rtl::OUString::createFromAscii ("com.sun.star.comp.sdbc.MozabDriver");
+ EVO_TRACE_STRING("createDriverConfigNode()::sCompleteNodePath = %s\n", sCompleteNodePath );
+
+ //=========================================================
+ // arguments for creating the config access
+ Sequence< Any > aArguments(2);
+ // the path to the node to open
+ aArguments[0] <<= PropertyValue(
+ ::rtl::OUString::createFromAscii( "nodepath"),
+ 0,
+ makeAny( sCompleteNodePath ),
+ PropertyState_DIRECT_VALUE
+ );
+ // the depth: -1 means unlimited
+ aArguments[1] <<= PropertyValue(
+ ::rtl::OUString::createFromAscii( "depth"),
+ 0,
+ makeAny( (sal_Int32)-1 ),
+ PropertyState_DIRECT_VALUE
+ );
+
+ //=========================================================
+ // create the access
+ Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
+ aArguments
+ );
+ OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" );
+
+ xNode = xNode.query( xAccess );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "createDriverConfigNode: caught an exception while accessing the driver's config node!" );
+ }
+
+ // outta here
+ return xNode;
+ }
+
+ //-----------------------------------------------------------------
+ namespace
+ {
+ // a private helper to accessing the point where we store the reference
+ // to the factory
+ Reference< XMultiServiceFactory >& accessFactoryStorage( )
+ {
+ static Reference< XMultiServiceFactory > xEvoabServiceFactory;
+ return xEvoabServiceFactory;
+ }
+ }
+
+ //-----------------------------------------------------------------
+ void setEvoabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ accessFactoryStorage( ) = _rxFactory;
+ }
+
+ //-----------------------------------------------------------------
+ const Reference< XMultiServiceFactory >& getEvoabServiceFactory( )
+ {
+ return accessFactoryStorage( );
+ }
+
+ //-----------------------------------------------------------------
+ ::rtl::OUString getFullPathExportingCommand( Reference< XMultiServiceFactory > _rxORB )
+ {
+ ::rtl::OUString sFullPathExportingCommand;
+
+ //Reference< XMultiServiceFactory > xFactory = getEvoabServiceFactory();
+ //OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
+ OSL_ENSURE( _rxORB.is(), "getFullPathExportingCommand: invalid service factory!" );
+ if ( _rxORB.is() )
+ {
+ try
+ {
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB, OEvoabDriver::getImplementationName_Static() );
+ Reference< XPropertySet > xEvoPrefsNode;
+ if ( xDriverNode.is() )
+ xDriverNode->getPropertyValue( ::rtl::OUString::createFromAscii( "EvolutionPreferences" ) ) >>= xEvoPrefsNode;
+ OSL_ENSURE( xEvoPrefsNode.is(), "getFullPathExportingCommand: could not access the node for the evolution preferences!" );
+ if ( xEvoPrefsNode.is() )
+ xEvoPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii( "FullPathExportingCommand" ) ) >>= sFullPathExportingCommand;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "getFullPathExportingCommand: caught an exception!" );
+ }
+ }
+ return sFullPathExportingCommand;
+ }
+ }
+}
+
+//.........................................................................
diff --git a/connectivity/source/drivers/evoab/LConfigAccess.hxx b/connectivity/source/drivers/evoab/LConfigAccess.hxx
new file mode 100644
index 000000000000..319e5a31fdfd
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LConfigAccess.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_
+#define _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_
+
+// This is the extended version (for use on the SO side of the driver) of MConfigAccess
+// (which is for use on the mozilla side only)
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB, ::rtl::OUString _sDriverImplementationName );
+ ::rtl::OUString getFullPathExportingCommand( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB );
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LCONFIGACCESS_HXX_
diff --git a/connectivity/source/drivers/evoab/LConnection.cxx b/connectivity/source/drivers/evoab/LConnection.cxx
new file mode 100644
index 000000000000..7b75512fd29d
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LConnection.cxx
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LConnection.hxx"
+#include "LDatabaseMetaData.hxx"
+#include "LCatalog.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <tools/urlobj.hxx>
+#include "LPreparedStatement.hxx"
+#include "LStatement.hxx"
+#include <comphelper/extract.hxx>
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vos/process.hxx>
+#include <tools/debug.hxx>
+#include "LDebug.hxx"
+#include "diagnose_ex.h"
+#include <comphelper/sequence.hxx>
+#include <connectivity/dbexception.hxx>
+#include "resource/common_res.hrc"
+
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace vos;
+
+typedef connectivity::file::OConnection OConnection_B;
+
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+::rtl::OUString implGetExceptionMsg( Exception& e, const ::rtl::OUString& aExceptionType_ )
+{
+ ::rtl::OUString aExceptionType = aExceptionType_;
+ if( aExceptionType.getLength() == 0 )
+ aExceptionType = ::rtl::OUString( ::rtl::OUString::createFromAscii("Unknown" ) );
+
+ ::rtl::OUString aTypeLine( ::rtl::OUString::createFromAscii("\nType: " ) );
+ aTypeLine += aExceptionType;
+
+ ::rtl::OUString aMessageLine( ::rtl::OUString::createFromAscii("\nMessage: " ) );
+ aMessageLine += ::rtl::OUString( e.Message );
+
+ ::rtl::OUString aMsg(aTypeLine);
+ aMsg += aMessageLine;
+ return aMsg;
+}
+
+ // Exception type unknown
+::rtl::OUString implGetExceptionMsg( Exception& e )
+{
+ ::rtl::OUString aMsg = implGetExceptionMsg( e, ::rtl::OUString() );
+ return aMsg;
+}
+
+// --------------------------------------------------------------------------------
+OEvoabConnection::OEvoabConnection(OEvoabDriver* _pDriver) : OConnection(_pDriver)
+ ,m_bHeaderLine(sal_True)
+ ,m_cFieldDelimiter(',')
+ ,m_cStringDelimiter('"')
+ ,m_cDecimalDelimiter('.')
+ ,m_cThousandDelimiter(' ')
+{
+ // Initialise m_aColumnAlias.
+ m_aColumnAlias.setAlias(_pDriver->getFactory());
+}
+//-----------------------------------------------------------------------------
+OEvoabConnection::~OEvoabConnection()
+{
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OEvoabConnection, "com.sun.star.sdbc.drivers.evoab.Connection", "com.sun.star.sdbc.Connection")
+
+//-----------------------------------------------------------------------------
+void OEvoabConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::url = %s\n", url );
+
+
+ ::rtl::OUString aCLICommand = getDriver()->getEvoab_CLI_EffectiveCommand();
+ ::rtl::OUString aWorkingDirPath = getDriver()->getWorkingDirPath();
+ ::rtl::OUString aArg1 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS());
+ ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX());
+ aArg2 += aWorkingDirPath;
+ aArg2 += getDriver()->getEvoFolderListFileName();
+ OArgumentList aArgs(2,&aArg1,&aArg2);
+
+ EVO_TRACE_STRING("OEvoabConnection::construct()::aCLICommand = %s\n", aCLICommand );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::aWorkingDirPath = %s\n", aWorkingDirPath );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::aArg1 = %s\n", aArg1 );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::aArg2 = %s\n", aArg2 );
+ OProcess aApp( aCLICommand,aWorkingDirPath);
+ OSL_VERIFY_EQUALS(
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs),
+ OProcess::E_None,
+ "Error at execute evolution-addressbook-export to get VCards");
+
+
+ Sequence<PropertyValue> aDriverParam;
+ ::std::vector<PropertyValue> aParam;
+
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("EnableSQL92Check"), 0, Any(), PropertyState_DIRECT_VALUE));
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(RTL_TEXTENCODING_UTF8);
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("CharSet"), 0,
+ makeAny((*aLookup).getIanaName()), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("Extension"), 0, makeAny(getDriver()->getFileExt()), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("HeaderLine"), 0, makeAny(m_bHeaderLine), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("FieldDelimiter"), 0, makeAny(::rtl::OUString(&m_cFieldDelimiter,1)), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("StringDelimiter"), 0, makeAny(::rtl::OUString(&m_cStringDelimiter,1)), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("DecimalDelimiter"), 0, makeAny(::rtl::OUString(&m_cDecimalDelimiter,1)), PropertyState_DIRECT_VALUE));
+ aParam.push_back(PropertyValue(::rtl::OUString::createFromAscii("ThousandDelimiter"), 0, makeAny(::rtl::OUString(&m_cThousandDelimiter,1)), PropertyState_DIRECT_VALUE));
+
+ // build a new parameter sequence from the original parameters, appended by the new parameters from above
+ PropertyValue *pParams = aParam.empty() ? 0 : &aParam[0];
+ aDriverParam = ::comphelper::concatSequences(
+ info,
+ Sequence< PropertyValue >( pParams, aParam.size() )
+ );
+
+ // transform "sdbc:address:evolution" part of URL to "sdbc:flat:file:///..."
+ //
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aAddrbookURI(url.copy(nLen+1));
+ // Get Scheme
+ nLen = aAddrbookURI.indexOf(':');
+ ::rtl::OUString aAddrbookScheme;
+ if ( nLen == -1 )
+ {
+ // There isn't any subschema: - but could be just subschema
+ if ( aAddrbookURI.getLength() > 0 )
+ {
+ aAddrbookScheme= aAddrbookURI;
+ }
+ else
+ {
+ OSL_TRACE( "No subschema given!!!\n");
+ throwGenericSQLException(STR_URI_SYNTAX_ERROR ,*this);
+ }
+ }
+ else
+ {
+ aAddrbookScheme = aAddrbookURI.copy(0, nLen);
+ }
+
+ EVO_TRACE_STRING("OEvoabConnection::construct()::URI = %s\n", aAddrbookURI );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::Scheme = %s\n", aAddrbookScheme );
+
+ //
+ // Now we have a URI convert it to a Evolution CLI flat file URI
+ //
+ // The Mapping being used is:
+ //
+ // * for Evolution
+ // "sdbc:address:evolution:" -> "sdbc:flat:file:///(file path generated)
+
+ rtl::OUString aEvoFlatURI;
+ if ( aAddrbookScheme.compareToAscii( OEvoabDriver::getSDBC_SCHEME_EVOLUTION() ) == 0 )
+ {
+ aEvoFlatURI = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "sdbc:flat:" ));
+ }
+
+
+ aEvoFlatURI += getDriver()->getWorkingDirURL();
+ EVO_TRACE_STRING("OEvoabConnection::construct()::m_aEvoFlatURI = %s\n", aEvoFlatURI );
+ //setURL(aEvoFlatURI);
+ m_aEvoFlatURI = aEvoFlatURI;
+
+ osl_decrementInterlockedCount( &m_refCount );
+ OConnection::construct(aEvoFlatURI,aDriverParam);
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OEvoabConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OEvoabDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ OEvoabCatalog *pCat = new OEvoabCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+ OEvoabStatement* pStmt = new OEvoabStatement(this);
+
+ Reference< XStatement > xStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement(this);
+ Reference< XPreparedStatement > xStmt = pStmt;
+ pStmt->construct(sql);
+
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab/LConnection.hxx b/connectivity/source/drivers/evoab/LConnection.hxx
new file mode 100644
index 000000000000..8ab673855f4f
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LConnection.hxx
@@ -0,0 +1,78 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LCONNECTION_HXX_
+#define _CONNECTIVITY_EVOAB_LCONNECTION_HXX_
+
+#include "LDriver.hxx"
+#include "file/FConnection.hxx"
+#include "LColumnAlias.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabConnection : public file::OConnection
+ {
+ private:
+ OColumnAlias m_aColumnAlias;
+ sal_Bool m_bHeaderLine; // column names in first row
+ sal_Unicode m_cFieldDelimiter; // look at the name
+ sal_Unicode m_cStringDelimiter; // delimiter for strings m_cStringDelimiter blabla m_cStringDelimiter
+ sal_Unicode m_cDecimalDelimiter; // Dezimal-delimiter (Dezimalpoint)
+ sal_Unicode m_cThousandDelimiter; //
+ rtl::OUString m_aEvoFlatURI;
+
+ public:
+ OEvoabConnection(OEvoabDriver* _pDriver);
+ virtual ~OEvoabConnection();
+
+ virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException);
+
+ // own methods
+ inline const OEvoabDriver* getDriver() const { return static_cast< const OEvoabDriver* >( m_pDriver ); }
+ inline sal_Bool isHeaderLine() const { return m_bHeaderLine; }
+ inline sal_Unicode getFieldDelimiter() const { return m_cFieldDelimiter; }
+ inline sal_Unicode getStringDelimiter() const { return m_cStringDelimiter; }
+ inline sal_Unicode getDecimalDelimiter() const { return m_cDecimalDelimiter; }
+ inline sal_Unicode getThousandDelimiter() const { return m_cThousandDelimiter;}
+ const OColumnAlias& getColumnAlias() const { return m_aColumnAlias; }
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LCONNECTION_HXX_
diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx
new file mode 100644
index 000000000000..6a07a786d3ce
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDatabaseMetaData.cxx
@@ -0,0 +1,391 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LDatabaseMetaData.hxx"
+#include "LConnection.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_
+#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#include <tools/urlobj.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "LFolderList.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <vos/process.hxx>
+#include <osl/process.h>
+#include <tools/debug.hxx>
+#include <map>
+#include <vector>
+
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#include "LDebug.hxx"
+#endif
+#include "diagnose_ex.h"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::evoab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::ucb;
+using namespace osl;
+using namespace vos;
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ static sal_Int32 const s_nCOLUMN_SIZE = 256;
+ static sal_Int32 const s_nDECIMAL_DIGITS = 0;
+ static sal_Int32 const s_nNULLABLE = 1;
+ static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
+ }
+}
+
+OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::CHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)254));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)65535);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DATE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)10);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIME);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)8);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)19);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::BIT);
+ aRow[3] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC"));
+ aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)20);
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("OEvoabDatabaseMetaData::getColumns()::Entered\n");
+ EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::schemaPattern = %s\n", schemaPattern );
+ EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::tableNamePattern = %s\n", tableNamePattern );
+ EVO_TRACE_STRING("OEvoabDatabaseMetaData::getColumns()::columnNamePattern = %s\n", columnNamePattern );
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabBegin = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength();
+ for(;pTabBegin != pTabEnd;++pTabBegin)
+ {
+ if(match(tableNamePattern,*pTabBegin,'\0'))
+ {
+ Reference< XColumnsSupplier> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin));
+ aRow[3] = new ORowSetValueDecorator(*pTabBegin);
+
+ Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i)
+ {
+ if(match(columnNamePattern,*pBegin,'\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(*pBegin);
+
+ ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin));
+ OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+ aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
+ aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
+ aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
+ aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
+
+ switch((sal_Int32)aRow[5]->getValue())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
+ break;
+ default:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
+ }
+ aRow[17] = new ORowSetValueDecorator(i);
+ switch(sal_Int32(aRow[11]->getValue()))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+ break;
+ default:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString());
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:flat:")) + m_pConnection->getURL();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xRef = pResult;
+
+ // check if any type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ sal_Bool bTableFound = sal_True;
+ sal_Int32 nLength = types.getLength();
+ if(nLength)
+ {
+ bTableFound = sal_False;
+
+ const ::rtl::OUString* pBegin = types.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + nLength;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(*pBegin == aTable)
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ }
+ }
+ if(!bTableFound)
+ return xRef;
+
+ OEvoabConnection* pOEvoabConnection = (OEvoabConnection*)m_pConnection;
+ OEvoabFolderList* pFolderList = new OEvoabFolderList( pOEvoabConnection );
+
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ sal_Bool bMoreData = sal_True;
+ ::rtl::OUString aName, aLocation;
+ sal_Int32 nCardsCount;
+
+ pFolderList->initializeRow(3);
+ bMoreData = pFolderList->first();
+ OSL_TRACE("OEvoabDatabaseMetaData::getTables()::first %d\n",bMoreData );
+ do
+ {
+ if(bMoreData)
+ bMoreData = pFolderList->getRow();
+ if(bMoreData)
+ {
+ aLocation = pFolderList->getString(1);
+ aName = pFolderList->getString(2);
+ nCardsCount = pFolderList->getInt(3);
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aLocation = %s\n", aLocation );
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aName = %s\n", aName );
+ OSL_TRACE("OEvoabDatabaseMetaData::getTables()::nCardsCount = %d\n", nCardsCount);
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRows.push_back(aRow);
+
+ ::rtl::OUString aWorkingDir = pOEvoabConnection->getDriver()->getWorkingDirPath();
+ ::rtl::OUString aCLICommand = pOEvoabConnection->getDriver()->getEvoab_CLI_EffectiveCommand();
+ ::rtl::OUString aArg1 = aLocation;
+ ::rtl::OUString aArg2 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX());
+ aArg2 += aWorkingDir;
+ aArg2 += aName;
+ aArg2 += ::rtl::OUString::createFromAscii(".");
+ aArg2 += ::rtl::OUString(pOEvoabConnection->getExtension());
+ ::rtl::OUString aArg3 = ::rtl::OUString::createFromAscii(pOEvoabConnection->getDriver()->getEVOAB_CLI_ARG_OUTPUT_FORMAT());
+
+ OArgumentList aArgs(3,&aArg1,&aArg2,&aArg3);
+
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aCLICommand = %s\n", aCLICommand );
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aWorkingDir = %s\n", aWorkingDir );
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg1 = %s\n", aArg1 );
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg2 = %s\n", aArg2 );
+ EVO_TRACE_STRING( "OEvoabDatabaseMetaData::getTables()::aArg3 = %s\n", aArg3 );
+
+ OProcess aApp( aCLICommand,aWorkingDir);
+ OSL_VERIFY_EQUALS(
+ aApp.execute( (OProcess::TProcessOption)(OProcess::TOption_Hidden | OProcess::TOption_Wait | OProcess::TOption_SearchPath),aArgs),
+ OProcess::E_None,
+ "Error at execute evolution-addressbook-exporter to get VCards" );
+
+ bMoreData = pFolderList->next();
+ }
+ }
+ while ( bMoreData );
+
+ delete pFolderList;
+ pFolderList = NULL;
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
diff --git a/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx b/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx
new file mode 100644
index 000000000000..36bd12a1e631
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDatabaseMetaData.hxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_
+#define _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_
+
+#include "file/FDatabaseMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ //**************************************************************
+ //************ Class: java.sql.DatabaseMetaDataDate
+ //**************************************************************
+
+ class OEvoabDatabaseMetaData : public file::ODatabaseMetaData
+ {
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ protected:
+ virtual ~OEvoabDatabaseMetaData();
+ public:
+ OEvoabDatabaseMetaData(file::OConnection* _pCon);
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LDATABASEMETADATA_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LDebug.cxx b/connectivity/source/drivers/evoab/LDebug.cxx
new file mode 100644
index 000000000000..3442d1a09854
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDebug.cxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#include "LDebug.hxx"
+#endif
+#include <osl/diagnose.h>
+
+void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString )
+{
+ ::rtl::OString sByteStringMessage( _rAsciiString.getStr(), _rAsciiString.getLength(), RTL_TEXTENCODING_ASCII_US );
+ if ( !sByteStringMessage.getLength() )
+ sByteStringMessage = "<empty>";
+ OSL_TRACE( _pFormat, sByteStringMessage.getStr() );
+}
diff --git a/connectivity/source/drivers/evoab/LDebug.hxx b/connectivity/source/drivers/evoab/LDebug.hxx
new file mode 100644
index 000000000000..d48bf733b078
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDebug.hxx
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#define CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+
+#include <rtl/ustring.hxx>
+
+#ifdef _DEBUG
+ void evo_traceStringMessage( const sal_Char* _pFormat, const ::rtl::OUString& _rAsciiString );
+
+ #define EVO_TRACE_STRING( pFormat, rAsciiString ) evo_traceStringMessage( pFormat, rAsciiString )
+#else
+ #define EVO_TRACE_STRING( pFormat, rAsciiString ) (void)(0)
+#endif
+
+
+#endif // CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
diff --git a/connectivity/source/drivers/evoab/LDriver.cxx b/connectivity/source/drivers/evoab/LDriver.cxx
new file mode 100644
index 000000000000..d196a27842bf
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDriver.cxx
@@ -0,0 +1,505 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LDriver.hxx"
+#include "LConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "LConfigAccess.hxx"
+#include <osl/file.hxx>
+#include "osl/security.hxx"
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <ucbhelper/content.hxx>
+#include <tools/debug.hxx>
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include "LDebug.hxx"
+
+using namespace osl;
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+
+// --------------------------------------------------------------------------------
+OEvoabDriver::OEvoabDriver(const Reference< XMultiServiceFactory >& _rxFactory) : OFileDriver(_rxFactory)
+ ,m_aTempDir(NULL, sal_True)
+ ,m_aFolderListName(::rtl::OUString::createFromAscii(getEVOAB_FOLDERLIST_FILE_NAME()))
+ ,m_aVersionName(::rtl::OUString::createFromAscii(getEVOAB_VERSION_FILE_NAME()))
+ ,m_aFileExt(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(getEVOAB_META_FILE_EXT())))
+ ,m_bWorkingDirCreated(sal_False)
+ ,m_eSupportedEvoVersion( eUnknown )
+{
+ m_aEvoab_CLI_FullPathCommand = getFullPathExportingCommand(_rxFactory);
+
+ if ( m_aEvoab_CLI_FullPathCommand.getLength() == 0 )
+ m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii(getEVOAB_CLI_FULLPATHCOMMAND());
+ if ( m_aEvoab_CLI_FullPathCommand.copy(0,7) != ::rtl::OUString::createFromAscii("file://") && m_aEvoab_CLI_FullPathCommand.copy(0,1) == ::rtl::OUString::createFromAscii("/"))
+ m_aEvoab_CLI_FullPathCommand = ::rtl::OUString::createFromAscii("file://") + m_aEvoab_CLI_FullPathCommand;
+ m_aEvoab_CLI_EffectiveCommand = m_aEvoab_CLI_FullPathCommand;
+ m_aTempDir.EnableKillingFile();
+
+ EVO_TRACE_STRING("OEvoabDriver::OEvoabDriver()::m_aEvoab_CLI_FullPathCommand = %s", m_aEvoab_CLI_FullPathCommand );
+}
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OEvoabDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii(EVOAB_DRIVER_IMPL_NAME);
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::evoab::OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new OEvoabDriver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OEvoabConnection* pCon = new OEvoabConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_translateProcessErrorMessage( oslProcessError nProcErr)
+ {
+ ::rtl::OUString sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" not executed!."));
+ switch (nProcErr)
+ {
+ case osl_Process_E_None:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed sucessful!"));
+ break;
+ case osl_Process_E_NotFound:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: not found!"));
+ break;
+ case osl_Process_E_NoPermission:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: has no permission!"));
+ break;
+ case osl_Process_E_TimedOut:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: time out!"));
+ break;
+ case osl_Process_E_Unknown:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: unkown reason!"));
+ break;
+ case osl_Process_E_InvalidError:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: invalid error!"));
+ break;
+ default:
+ sProcErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" executed failed: other reason!"));
+ }
+ return sProcErr;
+ }
+ oslProcessError lcl_execute( const ::rtl::OUString& _rCommand, ::rtl::OUString& _rArgument,
+ const ::rtl::OUString& _rWorkingDir, oslProcessOption _nOptions, oslFileHandle& /*[out]*/ _hStdOut )
+ {
+ oslProcessError nError = osl_Process_E_None;
+
+ EVO_TRACE_STRING("LDriver.cxx::lcl_execute: command : %s", _rCommand );
+ EVO_TRACE_STRING("LDriver.cxx::lcl_execute: argument : %s", _rArgument );
+ EVO_TRACE_STRING("LDriver.cxx::lcl_execute: working dir: %s", _rWorkingDir );
+
+ oslProcess hProcess( 0 );
+
+ nError = osl_executeProcess_WithRedirectedIO(
+ _rCommand.pData,
+ &_rArgument.pData,
+ 1,
+ _nOptions,
+ 0,
+ _rWorkingDir.pData,
+ 0,
+ 0,
+ &hProcess,
+ NULL,
+ &_hStdOut,
+ NULL
+ );
+ ::rtl::OUString sError = _rCommand + lcl_translateProcessErrorMessage( nError);
+ EVO_TRACE_STRING( "%s", sError );
+
+ if ( nError == osl_Process_E_None )
+ {
+ TimeValue aFiveSeconds;
+ aFiveSeconds.Seconds = 5;
+ aFiveSeconds.Nanosec = 0;
+ oslProcessError nWaitForProcessError = osl_joinProcessWithTimeout( hProcess, &aFiveSeconds );
+ if ( osl_Process_E_None != nWaitForProcessError )
+ {
+ nError = nWaitForProcessError;
+ // TODO: kill the running process?
+ }
+ osl_freeProcessHandle( hProcess );
+ }
+ return nError;
+ }
+}
+
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ sal_Bool bRet;
+ bRet = sal_False;
+ // here we have to look if we support this url format
+ if(acceptsURL_Stat(url))
+ {
+ if ( m_eSupportedEvoVersion != eUnknown )
+ return m_eSupportedEvoVersion == eTrue ? sal_True : sal_False;
+
+ if(!m_bWorkingDirCreated)
+ {
+ String sTempDirURL = getTempDirURL();
+ //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::sTempDirURL = %s", sTempDirURL );
+
+ ::rtl::OUString aTempDirURL(sTempDirURL);
+ m_aWorkingDirURL = aTempDirURL;
+ m_bWorkingDirCreated = sal_True;
+ }
+
+ ::rtl::OUString aCLICommand = getEvoab_CLI_EffectiveCommand();
+ ::rtl::OUString aWorkingDirURL = getWorkingDirURL();
+ ::rtl::OUString aArgVersion = ::rtl::OUString::createFromAscii(getEVOAB_CLI_ARG_VERSION());
+
+ oslFileHandle hStdout = NULL;
+ oslProcessError nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, 0, hStdout );
+ if(nProcErr != osl_Process_E_None)
+ {
+ if(doesEvoab_CLI_HavePath())
+ aCLICommand = getEvoab_CLI_Command();
+ else
+ aCLICommand = getEvoab_CLI_Path() + getEvoab_CLI_Command();
+ nProcErr = lcl_execute( aCLICommand, aArgVersion, aWorkingDirURL, osl_Process_SEARCHPATH | osl_Process_HIDDEN, hStdout );
+ if ( nProcErr == osl_Process_E_None )
+ m_aEvoab_CLI_EffectiveCommand = aCLICommand;
+ }
+
+ if ( hStdout != NULL )
+ {
+ OSL_ASSERT( hStdout );
+ sal_Char pBuffer[256];
+ sal_uInt64 nBytesRead;
+ oslFileError nFileErr = osl_File_E_None;
+ nFileErr = osl_readFile( hStdout, pBuffer, 256, &nBytesRead);
+ if ( nFileErr != osl_File_E_None )
+ {
+ ::rtl::OUString sErr = translateFileErrorMessage( nFileErr);
+ OSL_ENSURE(false, ::rtl::OUStringToOString( sErr, RTL_TEXTENCODING_ASCII_US ).getStr());
+ }
+ ::rtl::OUString aVersionInfo;
+ if ( nFileErr == osl_File_E_None && nBytesRead > 0 && nBytesRead <= 256)
+ {
+ OSL_TRACE("OEvoabDriver::acceptsURL()::osl_readFile(),nBytesRead = %u",nBytesRead);
+ aVersionInfo =
+ ::rtl::OUString( ( const sal_Char * )pBuffer,
+ (sal_Int32)nBytesRead,
+ RTL_TEXTENCODING_UTF8 );
+ EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aVersionInfo = %s", aVersionInfo );
+ sal_Int32 nIndex = 0;
+ sal_Bool bNumRetrieved = sal_False;
+ ::rtl::OUString aToken;
+ sal_Int32 aVer[4];
+ sal_Int32 i;
+ for ( i = 0; i < 4; i++ )
+ aVer[i] = 0;
+ do
+ {
+ aToken = aVersionInfo.getToken( 0, ' ', nIndex );
+ //OSL_TRACE("OEvoabDriver::acceptsURL()::Token:%d", nIndex );
+ //EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::aToken = %s", aToken );
+ if( aToken.toChar() >= '0' && aToken.toChar() <= '9' )
+ {
+ bNumRetrieved = sal_True;
+ sal_Int32 nIndex1 = 0;
+ ::rtl::OUString aNum;
+ for(i = 0; i < 4 ; i++)
+ {
+ if( nIndex1 >= 0 )
+ {
+ aNum = aToken.getToken( 0, '.', nIndex1);
+ aVer[i] = aNum.toInt32();
+ OSL_TRACE("OEvoabDriver::acceptsURL()::Ver[%u]=%u", i, aVer[i] );
+ }
+ }
+ }
+ }
+ while ( nIndex >= 0 && !bNumRetrieved );
+
+ if((aVer[0]>1)||(aVer[0]==1 && aVer[1]>3)||(aVer[0]==1 && aVer[1]==3 && aVer[2]>2)||(aVer[0]==1 && aVer[1]==3 && aVer[2]==2 && aVer[3]>=99))
+ bRet = sal_True;
+ else
+ bRet = sal_False;
+ }
+ else
+ bRet = sal_False;
+
+ osl_closeFile( hStdout );
+ }
+ m_eSupportedEvoVersion = bRet ? eTrue : eFalse;
+ }
+ EVO_TRACE_STRING("OEvoabDriver::acceptsURL()::return, return value = %s", ::rtl::OUString::valueOf(bRet) );
+ return bRet;
+}
+
+
+// --------------------------------------------------------------------------------
+sal_Bool OEvoabDriver::acceptsURL_Stat( const ::rtl::OUString& url )
+{
+
+ EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", url );
+ // Skip 'sdbc:address: part of URL
+ //
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aAddrbookURI(url.copy(nLen+1));
+
+ // Get Scheme
+ nLen = aAddrbookURI.indexOf(':');
+ ::rtl::OUString aAddrbookScheme;
+ if ( nLen == -1 )
+ {
+ // There isn't any subschema: - but could be just subschema
+ if ( aAddrbookURI.getLength() > 0 )
+ aAddrbookScheme= aAddrbookURI;
+ else if(url == ::rtl::OUString::createFromAscii("sdbc:address:") )
+ return sal_True; // special case here
+ else
+ return sal_False;
+ }
+ else
+ aAddrbookScheme = aAddrbookURI.copy(0, nLen);
+
+
+ EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::URI = %s", aAddrbookURI );
+ EVO_TRACE_STRING("OEvoabDriver::acceptsURL_Stat()::Scheme = %s", aAddrbookScheme );
+
+ return aAddrbookScheme.compareToAscii( getSDBC_SCHEME_EVOLUTION() ) == 0 ;
+}
+// -------------------------------------------------------------------------
+const rtl::OUString OEvoabDriver::getEvoab_CLI_Command() const
+{
+ rtl::OUString aEvoab_CLI_Command;
+ sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/');
+
+ if ( nLen == -1 )
+ aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand;
+ else
+ aEvoab_CLI_Command = m_aEvoab_CLI_FullPathCommand.copy(nLen+1);
+
+ EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Command()::aEvoab_CLI_Command = %s", aEvoab_CLI_Command );
+
+ return aEvoab_CLI_Command;
+}
+// -------------------------------------------------------------------------
+const rtl::OUString OEvoabDriver::getEvoab_CLI_Path() const
+{
+ rtl::OUString aEvoab_CLI_Path;
+ sal_Int32 nLen = m_aEvoab_CLI_FullPathCommand.lastIndexOf('/');
+
+ if ( nLen == -1 )
+ {
+ rtl::OUString aDefault_CLI_FullPathCommand;
+ aDefault_CLI_FullPathCommand = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND()));
+ sal_Int32 nLength = aDefault_CLI_FullPathCommand.lastIndexOf('/');
+ aEvoab_CLI_Path = aDefault_CLI_FullPathCommand.copy(0, nLength+1);
+ }
+ else
+ aEvoab_CLI_Path = m_aEvoab_CLI_FullPathCommand.copy(0, nLen+1);
+ EVO_TRACE_STRING( "OEvoabDriver::getEvoab_CLI_Path()::aEvoab_CLI_Path = %s", aEvoab_CLI_Path );
+
+ return aEvoab_CLI_Path;
+}
+// -------------------------------------------------------------------------
+const rtl::OUString OEvoabDriver::getWorkingDirPath() const
+{
+ ::rtl::OUString aWorkingDirPath;
+ if(m_bWorkingDirCreated)
+ osl::File::getSystemPathFromFileURL( m_aWorkingDirURL, aWorkingDirPath );
+ return aWorkingDirPath;
+}
+// -------------------------------------------------------------------------
+const String OEvoabDriver::getEvoFolderListFileURL() const
+{
+
+ ::rtl::OUString aEvoFolderListFileURL;
+ aEvoFolderListFileURL = getWorkingDirURL() + getEvoFolderListFileName();
+
+ EVO_TRACE_STRING("OEvoabDriver::getEvoFolderListFileURL(): aEvoFolderListFileURL = %s", aEvoFolderListFileURL );
+ return aEvoFolderListFileURL.getStr();
+}
+
+// -------------------------------------------------------------------------
+String OEvoabDriver::getTempDirURL() const
+{
+ ::rtl::OUString aTempDirURL;
+ aTempDirURL = m_aTempDir.GetURL();
+ if((aTempDirURL.lastIndexOf( '/')) != (aTempDirURL.getLength( ) - 1))
+ aTempDirURL += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/"));
+
+ EVO_TRACE_STRING("OEvoabDriver::getTempDirURL(): aTempDirURL = %s", aTempDirURL );
+ return aTempDirURL.getStr();
+}
+//-------------------------------------------------------------------------
+sal_Bool OEvoabDriver::fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir) const
+{
+ ::ucbhelper::Content aCheckExistence;
+ sal_Bool bExists = sal_False;
+ try
+ {
+ aCheckExistence = ::ucbhelper::Content(_rURL, Reference< XCommandEnvironment >());
+ if(_bIsDir)
+ bExists = aCheckExistence.isFolder();
+ else
+ bExists = aCheckExistence.isDocument();
+ }
+ catch(const Exception&) { }
+ return bExists;
+}
+
+// -----------------------------------------------------------------------------
+const sal_Char* OEvoabDriver::getSDBC_SCHEME_EVOLUTION()
+{
+ static const sal_Char* SDBC_SCHEME_EVOLUTION = EVOAB_EVOLUTION_SCHEMA;
+ return SDBC_SCHEME_EVOLUTION;
+}
+const sal_Char* OEvoabDriver::getEVOAB_FOLDERLIST_FILE_NAME()
+{
+ static const sal_Char* EVOAB_FOLDERLIST_FILE_NAME = "FolderList";
+ return EVOAB_FOLDERLIST_FILE_NAME;
+}
+const sal_Char* OEvoabDriver::getEVOAB_VERSION_FILE_NAME()
+{
+ static const sal_Char* EVOAB_VERSION_FILE_NAME = "EvoVersion";
+ return EVOAB_VERSION_FILE_NAME;
+}
+const sal_Char* OEvoabDriver::getEVOAB_META_FILE_EXT()
+{
+ static const sal_Char* EVOAB_META_FILE_EXT = "csv";
+ return EVOAB_META_FILE_EXT;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_FULLPATHCOMMAND()
+{
+ static const sal_Char* EVOAB_CLI_FULLPATHCOMMAND = "file:///home/evoab/extra/share/evolution/*/tools/evolution-addressbook-export";
+ return EVOAB_CLI_FULLPATHCOMMAND;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_LIST_FOLDERS()
+{
+ static const sal_Char* EVOAB_CLI_ARG_LIST_FOLDERS = "-l";
+ return EVOAB_CLI_ARG_LIST_FOLDERS;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX()
+{
+ static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX = "--output=";
+ return EVOAB_CLI_ARG_OUTPUT_FILE_PREFIX;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_FORMAT()
+{
+ static const sal_Char* EVOAB_CLI_ARG_OUTPUT_FORMAT = "--format=csv";
+ return EVOAB_CLI_ARG_OUTPUT_FORMAT;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_VERSION()
+{
+ static const sal_Char* EVOAB_CLI_ARG_VERSION = "--version";
+ return EVOAB_CLI_ARG_VERSION;
+}
+const sal_Char* OEvoabDriver::getEVOAB_CLI_ARG_OUTPUT_REDIRECT()
+{
+ static const sal_Char* EVOAB_CLI_ARG_OUTPUT_REDIRECT = ">";
+ return EVOAB_CLI_ARG_OUTPUT_REDIRECT;
+}
+rtl::OUString OEvoabDriver::translateFileErrorMessage( oslFileError nFileErr)
+{
+ ::rtl::OUString sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" no file operation!."));
+ switch (nFileErr)
+ {
+ case osl_File_E_None:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation succeeded!"));
+ break;
+ case osl_File_E_INVAL:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: the format of the parameters was not valid!"));
+ break;
+ case osl_File_E_INTR:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: function call was interrupted!"));
+ break;
+ case osl_File_E_IO:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: I/O errors!"));
+ break;
+ case osl_File_E_ISDIR:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: is a directory!"));
+ break;
+ case osl_File_E_BADF:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad file!"));
+ break;
+ case osl_File_E_FAULT:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: bad address!"));
+ break;
+ case osl_File_E_AGAIN:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: operation would block!"));
+ break;
+ case osl_File_E_NOLINK:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: link has been severed!"));
+ break;
+ default:
+ sFileErr = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" File operation failed: other reason!"));
+ }
+ return sFileErr;
+}
+// -----------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL OEvoabDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( !acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( !acceptsURL(url) )
+ return Sequence< DriverPropertyInfo >();
+}
diff --git a/connectivity/source/drivers/evoab/LDriver.hxx b/connectivity/source/drivers/evoab/LDriver.hxx
new file mode 100644
index 000000000000..e708eabb8671
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LDriver.hxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LDRIVER_HXX_
+#define _CONNECTIVITY_EVOAB_LDRIVER_HXX_
+
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "file/FDriver.hxx"
+#include <unotools/tempfile.hxx>
+#include <osl/file.h>
+#include <osl/process.h>
+
+#define EVOAB_EVOLUTION_SCHEMA "evolution"
+#define EVOAB_LDAP_SCHEMA "ldap"
+#define EVOAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.evoab.OEvoabDriver"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ class OEvoabDriver : public file::OFileDriver
+ {
+ private:
+ enum MaybeVoidBool
+ {
+ eUnknown,
+ eTrue,
+ eFalse
+ };
+ ::utl::TempFile m_aTempDir;
+ rtl::OUString m_aFolderListName;
+ rtl::OUString m_aVersionName;
+ rtl::OUString m_aFileExt;
+ rtl::OUString m_aWorkingDirURL;
+ rtl::OUString m_aEvoab_CLI_EffectiveCommand;
+ rtl::OUString m_aEvoab_CLI_FullPathCommand;
+ sal_Bool m_bWorkingDirCreated;
+ MaybeVoidBool m_eSupportedEvoVersion;
+
+ sal_Bool fileExists(const ::rtl::OUString& _rURL, sal_Bool _bIsDir=sal_False) const;
+
+ public:
+ OEvoabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ inline rtl::OUString getEvoFolderListName() const { return m_aFolderListName;}
+ inline rtl::OUString getFileExt() const { return m_aFileExt;}
+ inline rtl::OUString getEvoFolderListFileName() const { return m_aFolderListName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;}
+ inline rtl::OUString getEvoVersionFileName() const { return m_aVersionName + ::rtl::OUString::createFromAscii(".") + m_aFileExt;}
+ inline rtl::OUString getWorkingDirURL() const { return m_aWorkingDirURL;}
+ inline rtl::OUString getEvoab_CLI_FullPathCommand() const { return m_aEvoab_CLI_FullPathCommand;}
+ inline rtl::OUString getEvoab_CLI_EffectiveCommand() const { return m_aEvoab_CLI_EffectiveCommand;}
+ inline sal_Bool doesEvoab_CLI_HavePath() const { return m_aEvoab_CLI_FullPathCommand.lastIndexOf('/')!=-1;}
+ const rtl::OUString getEvoab_CLI_Command() const;
+ const rtl::OUString getEvoab_CLI_Path() const;
+ const rtl::OUString getWorkingDirPath() const;
+ const String getEvoFolderListFileURL() const;
+ String getTempDirURL() const;
+
+ // XInterface
+ ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+
+ // static methods
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static sal_Bool acceptsURL_Stat( const ::rtl::OUString& url );
+ static ::rtl::OUString translateProcessErrorMessage( oslProcessError nProcErr);
+ static ::rtl::OUString translateFileErrorMessage( oslFileError nFileErr);
+ static const sal_Char* getSDBC_SCHEME_EVOLUTION();
+ static const sal_Char* getEVOAB_FOLDERLIST_FILE_NAME();
+ static const sal_Char* getEVOAB_VERSION_FILE_NAME();
+ static const sal_Char* getEVOAB_META_FILE_EXT();
+ static const sal_Char* getEVOAB_CLI_FULLPATHCOMMAND();
+ static const sal_Char* getEVOAB_CLI_ARG_LIST_FOLDERS();
+ static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FILE_PREFIX();
+ static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_FORMAT();
+ static const sal_Char* getEVOAB_CLI_ARG_VERSION();
+ static const sal_Char* getEVOAB_CLI_ARG_OUTPUT_REDIRECT();
+
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_EVOAB_LDRIVER_HXX_
diff --git a/connectivity/source/drivers/evoab/LFolderList.cxx b/connectivity/source/drivers/evoab/LFolderList.cxx
new file mode 100644
index 000000000000..1a42ef028c54
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LFolderList.cxx
@@ -0,0 +1,563 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <ctype.h>
+#include <algorithm>
+#include "LFolderList.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <svl/converter.hxx>
+#include "LConnection.hxx"
+#include "LColumns.hxx"
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/math.hxx>
+#include <stdio.h> //sprintf
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include "LDriver.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <unotools/configmgr.hxx>
+#include <i18npool/mslangid.hxx>
+#include "connectivity/dbconversion.hxx"
+#include <comphelper/types.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/debug.hxx>
+#include "connectivity/dbexception.hxx"
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#include "LDebug.hxx"
+#endif
+#include <unotools/syslocale.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+void OEvoabFolderList::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
+{
+ BOOL bRead = TRUE;
+
+ QuotedTokenizedString aHeaderLine;
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+
+ // read first row
+ QuotedTokenizedString aFirstLine;
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding());
+
+ while(bRead && !aFirstLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding());
+ }
+ // use first row as headerline because we need the number of columns
+ aHeaderLine = aFirstLine;
+
+ // column count
+ xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+
+ if(!m_aColumns.isValid())
+ m_aColumns = new OSQLColumns();
+ else
+ m_aColumns->get().clear();
+
+ m_aTypes.clear();
+ m_aPrecisions.clear();
+ m_aScales.clear();
+ // reserve some space
+ m_aColumns->get().reserve(nFieldCount);
+ m_aTypes.reserve(nFieldCount);
+ m_aPrecisions.reserve(nFieldCount);
+ m_aScales.reserve(nFieldCount);
+
+ sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale);
+ // read description
+ sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aColumnName;
+ ::rtl::OUString aTypeName;
+ ::comphelper::UStringMixEqual aCase(bCase);
+ xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine2 = 0;
+ for (xub_StrLen i = 0; i < nFieldCount; i++)
+ {
+
+ // no column name so ...
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+
+ sal_Int32 eType;
+ UINT16 nPrecision = 0;
+ UINT16 nScale = 0;
+
+ BOOL bNumeric = FALSE;
+ ULONG nIndex = 0;
+
+ // first without fielddelimiter
+ String aField;
+ aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0');
+ if (aField.Len() == 0 ||
+ (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0)))
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ String aField2;
+ if ( pConnection->getStringDelimiter() != '\0' )
+ aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+ else
+ aField2 = aField;
+
+ if (aField2.Len() == 0)
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ bNumeric = TRUE;
+ xub_StrLen nDot = 0;
+ for (xub_StrLen j = 0; j < aField2.Len(); j++)
+ {
+ sal_Unicode c = aField2.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if ((!cDecimalDelimiter || c != cDecimalDelimiter) &&
+ (!cThousandDelimiter || c != cThousandDelimiter) &&
+ !aCharClass.isDigit(aField2,j))
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ if (cDecimalDelimiter && c == cDecimalDelimiter)
+ {
+ nPrecision = 15; // we have an decimal value
+ nScale = 2;
+ nDot++;
+ }
+ }
+
+ if (nDot > 1) // if there is more than one dot it isn't a number
+ bNumeric = FALSE;
+ if (bNumeric && cThousandDelimiter)
+ {
+ // Ist der Trenner richtig angegeben?
+ String aValue = aField2.GetToken(0,cDecimalDelimiter);
+ for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4)
+ {
+ sal_Unicode c = aValue.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if (c == cThousandDelimiter && j)
+ continue;
+ else
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ }
+ }
+
+ // jetzt koennte es noch ein Datumsfeld sein
+ if (!bNumeric)
+ {
+ try
+ {
+ nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ sal_Int32 nFlags = 0;
+ if (bNumeric)
+ {
+ if (cDecimalDelimiter)
+ {
+ if(nPrecision)
+ {
+ eType = DataType::DECIMAL;
+ aTypeName = ::rtl::OUString::createFromAscii("DECIMAL");
+ }
+ else
+ {
+ eType = DataType::DOUBLE;
+ aTypeName = ::rtl::OUString::createFromAscii("DOUBLE");
+ }
+ }
+ else
+ eType = DataType::INTEGER;
+ nFlags = ColumnSearch::BASIC;
+ }
+ else
+ {
+
+ switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex))
+ {
+ case NUMBERFORMAT_DATE:
+ eType = DataType::DATE;
+ aTypeName = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case NUMBERFORMAT_DATETIME:
+ eType = DataType::TIMESTAMP;
+ aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ case NUMBERFORMAT_TIME:
+ eType = DataType::TIME;
+ aTypeName = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ default:
+ eType = DataType::VARCHAR;
+ nPrecision = 0; // nyi: Daten koennen aber laenger sein!
+ nScale = 0;
+ aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
+ };
+ nFlags |= ColumnSearch::CHAR;
+ }
+
+ // check if the columname already exists
+ String aAlias(aColumnName);
+ OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ sal_Int32 nExprCnt = 0;
+ while(aFind != m_aColumns->get().end())
+ {
+ (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt);
+ aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ }
+
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(),
+ ColumnValue::NULLABLE,
+ nPrecision,
+ nScale,
+ eType,
+ sal_False,
+ sal_False,
+ sal_False,
+ bCase);
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->get().push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nScale);
+ }
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+}
+// -------------------------------------------------------------------------
+DBG_NAME( OEvoabFolderList );
+OEvoabFolderList::OEvoabFolderList(OEvoabConnection* _pConnection)
+ :m_nFilePos(0)
+ ,m_pFileStream(NULL)
+ ,m_pConnection(_pConnection)
+ ,m_bIsNull(sal_False)
+{
+ DBG_CTOR( OEvoabFolderList, NULL );
+ m_aColumns = new OSQLColumns();
+
+ construct();
+}
+// -----------------------------------------------------------------------------
+void OEvoabFolderList::construct()
+{
+ SvtSysLocale aLocale;
+ ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale());
+ Sequence< ::com::sun::star::uno::Any > aArg(1);
+ aArg[0] <<= aAppLocale;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY);
+ m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY);
+ m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier);
+
+ INetURLObject aURL;
+ aURL.SetURL(m_pConnection->getDriver()->getEvoFolderListFileURL());
+
+ String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ EVO_TRACE_STRING("OJ::construct()::aFileName = %s\n", aFileName );
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+
+ if(!m_pFileStream)
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+
+ if(m_pFileStream)
+ {
+ m_pFileStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = m_pFileStream->Tell();
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
+ nSize > 100000 ? 16384 :
+ nSize > 10000 ? 4096 : 1024);
+ OSL_TRACE("OEvoabFolderList::construct()::m_pFileStream->Tell() = %d\n", nSize );
+
+ fillColumns(aAppLocale);
+ }
+}
+
+
+//------------------------------------------------------------------
+sal_Bool OEvoabFolderList::fetchRow(OValueRow _rRow,const OSQLColumns & _rCols)
+{
+ (_rRow->get())[0] = m_nFilePos; // the "bookmark"
+
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ // Felder:
+ xub_StrLen nStartPos = 0;
+ String aStr;
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i)
+ {
+ m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+ //OSL_TRACE("OEvoabFolderList::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) );
+
+ if (aStr.Len() == 0)
+ (_rRow->get())[i+1].setNull();
+ else
+ {
+ // length depending on the data type
+ sal_Int32 nType = m_aTypes[i];
+ switch(nType)
+ {
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ double nRes = 0.0;
+ try
+ {
+ nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr);
+ Reference<XPropertySet> xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY);
+ com::sun::star::util::Date aDate;
+ xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate;
+
+ switch(nType)
+ {
+ case DataType::DATE:
+ (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate));
+ break;
+ case DataType::TIMESTAMP:
+ (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate));
+ break;
+ default:
+ (_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes));
+ }
+ }
+ catch(Exception&)
+ {
+ (_rRow->get())[i+1].setNull();
+ }
+ } break;
+ case DataType::DOUBLE:
+ case DataType::INTEGER:
+ case DataType::DECIMAL: // #99178# OJ
+ case DataType::NUMERIC:
+ {
+ sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aStrConverted;
+
+ OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER ||
+ !cDecimalDelimiter && nType == DataType::INTEGER,
+ "FalscherTyp");
+
+ // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln:
+ for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ {
+ if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter)
+ aStrConverted += '.';
+ else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it
+ break; // #99189# OJ
+ else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter)
+ {
+ // weglassen
+ }
+ else
+ aStrConverted += aStr.GetChar(j) ;
+ }
+ double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL);
+
+ // #99178# OJ
+ if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType )
+ (_rRow->get())[i+1] = String::CreateFromDouble(nVal);
+ else
+ (_rRow->get())[i+1] = nVal;
+ } break;
+
+ default:
+ {
+ // Wert als String in Variable der Row uebernehmen
+ (_rRow->get())[i+1] = aStr;
+ }
+ break;
+ }
+ }
+ }
+ return sal_True;
+}
+
+
+//------------------------------------------------------------------
+sal_Bool OEvoabFolderList::seekRow(IResultSetHelper::Movement eCursorPosition)
+{
+ //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ if ( !m_pFileStream )
+ return sal_False;
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ //OSL_TRACE("OEvoabFolderList::seekRow()::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ // run through
+
+ case IResultSetHelper::NEXT:
+ m_pFileStream->Seek(m_nFilePos);
+
+ if (m_pFileStream->IsEof())
+ {
+ OSL_TRACE( "OEvoabFolderList::seekRow: EOF /before/ reading the line." );
+ return sal_False;
+ }
+
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ {
+ OSL_TRACE( "OEvoabFolderList::seekRow: EOF /after/ reading the line." );
+ if ( !m_aCurrentLine.Len() )
+ {
+ OSL_TRACE( "OEvoabFolderList::seekRow: empty line read." );
+ return sal_False;
+ }
+ }
+ m_nFilePos = m_pFileStream->Tell();
+ break;
+
+ default:
+ OSL_ENSURE( sal_False, "OEvoabFolderList::seekRow: unsupported positioning!" );
+ break;
+ }
+
+ //OSL_TRACE("OEvoabFolderList::seekRow()::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+SvStream* OEvoabFolderList::createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode)
+{
+ utl::UcbLockBytesHandler* p_null_dummy=NULL;
+ SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, p_null_dummy);
+ if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
+ {
+ delete pReturn;
+ pReturn = NULL;
+ }
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& OEvoabFolderList::getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ checkIndex( _nColumnIndex );
+
+ m_bIsNull = (m_aRow->get())[_nColumnIndex].isNull();
+ return (m_aRow->get())[_nColumnIndex];
+}
+// -----------------------------------------------------------------------------
+void OEvoabFolderList::checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ if ( _nColumnIndex <= 0 || _nColumnIndex >= (sal_Int32)m_aRow->get().size() ) {
+// ::dbtools::throwInvalidIndexException();
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabFolderList::getString( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue(_nColumnIndex);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabFolderList::getInt( sal_Int32 _nColumnIndex ) throw(SQLException, RuntimeException)
+{
+ return getValue( _nColumnIndex );
+}
+// -----------------------------------------------------------------------------
+void OEvoabFolderList::initializeRow(sal_Int32 _nColumnCount)
+{
+ if(!m_aRow.isValid())
+ {
+ m_aRow = new OValueVector(_nColumnCount);
+ (m_aRow->get())[0].setBound(sal_True);
+ ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False));
+ }
+ //OSL_TRACE("OEvoabFolderList::initializeRow()::_nColumnCount = %d\n", _nColumnCount);
+
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabFolderList::first( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bSuccess = seekRow(IResultSetHelper::FIRST);
+
+ EVO_TRACE_STRING("OEvoabFolderList::first(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) );
+ return bSuccess;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabFolderList::next( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bSuccess = seekRow(IResultSetHelper::NEXT);
+
+ EVO_TRACE_STRING("OEvoabFolderList::next(): returning %s\n", ::rtl::OUString::valueOf(bSuccess) );
+ return bSuccess;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OEvoabFolderList::getRow( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bRet = fetchRow(m_aRow,getTableColumns().getBody());
+ EVO_TRACE_STRING("OEvoabFolderList::getRow()::fetchRow() = %s\n", ::rtl::OUString::valueOf(bRet) );
+
+ return bRet;
+}
diff --git a/connectivity/source/drivers/evoab/LFolderList.hxx b/connectivity/source/drivers/evoab/LFolderList.hxx
new file mode 100644
index 000000000000..2941cb6bd20f
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LFolderList.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_
+#define _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_
+
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <tools/urlobj.hxx>
+#include "LTable.hxx"
+#include "TResultSetHelper.hxx"
+
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ //==================================================================
+ // Ableitung von String mit ueberladenen GetToken/GetTokenCount-Methoden
+ // Speziell fuer FLAT FILE-Format: Strings koennen gequotet sein
+ //==================================================================
+
+ class OEvoabConnection;
+
+ class OEvoabFolderList
+ {
+ // maps a row postion to a file position
+ ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset
+ ::std::vector<sal_Int32> m_aPrecisions; // same as aboth
+ ::std::vector<sal_Int32> m_aScales;
+ QuotedTokenizedString m_aCurrentLine;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter;
+ sal_Int32 m_nFilePos; // aktuelle IResultSetHelper::Movement
+ SvStream* m_pFileStream;
+ OEvoabConnection* m_pConnection;
+ ::vos::ORef<OSQLColumns> m_aColumns;
+ OValueRow m_aRow;
+ sal_Bool m_bIsNull;
+
+ private:
+ void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
+ BOOL CreateFile(const INetURLObject& aFile, BOOL& bCreateMemo);
+
+ sal_Bool fetchRow(OValueRow _rRow,const OSQLColumns& _rCols);
+ sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition);
+
+ public:
+
+ OEvoabFolderList( OEvoabConnection* _pConnection);
+
+ OEvoabConnection* getConnection() const { return m_pConnection;}
+ ::vos::ORef<OSQLColumns> getTableColumns() const {return m_aColumns;}
+ void construct(); // can throw any exception
+ static SvStream* createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode);
+ void initializeRow(sal_Int32 _nColumnCount);
+ void checkIndex(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException);
+ const ORowSetValue& getValue(sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException);
+ ::rtl::OUString SAL_CALL getString( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 SAL_CALL getInt( sal_Int32 _nColumnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LEVOABFOLDERLIST_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LNoException.cxx b/connectivity/source/drivers/evoab/LNoException.cxx
new file mode 100644
index 000000000000..2fefbafb7a94
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LNoException.cxx
@@ -0,0 +1,324 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LTable.hxx"
+#include "LConnection.hxx"
+
+using namespace connectivity;
+using namespace connectivity::evoab;
+
+//------------------------------------------------------------------
+xub_StrLen OEvoabString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const
+{
+ if ( !Len() )
+ return 0;
+
+ xub_StrLen nTokCount = 1;
+ BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token?
+ BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = 0; i < Len(); i++ )
+ {
+ if (bStart)
+ {
+ bStart = FALSE;
+ // Erstes Zeichen ein String-Delimiter?
+ if ((*this).GetChar(i) == cStrDel)
+ {
+ bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings!
+ continue; // dieses Zeichen ueberlesen!
+ }
+ }
+
+ if (bInString) {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( (*this).GetChar(i) == cStrDel )
+ {
+ if ((i+1 < Len()) && ((*this).GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ i++; // kein String-Ende, naechstes Zeichen ueberlesen.
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ }
+ }
+ } else {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( (*this).GetChar(i) == cTok )
+ {
+ nTokCount++;
+ bStart = TRUE;
+ }
+ }
+ }
+ //OSL_TRACE("OEvoabString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) );
+
+ return nTokCount;
+}
+
+//------------------------------------------------------------------
+void OEvoabString::GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel ) const
+{
+ _rStr.Erase();
+ xub_StrLen nLen = Len();
+ if ( nLen )
+ {
+ BOOL bInString = (nStartPos < nLen) && ((*this).GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Erstes Zeichen ein String-Delimiter?
+ if (bInString )
+ ++nStartPos; // dieses Zeichen ueberlesen!
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ {
+ if (bInString)
+ {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( (*this).GetChar(i) == cStrDel )
+ {
+ if ((i+1 < nLen) && ((*this).GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ ++i; // kein String-Ende, naechstes Zeichen ueberlesen.
+
+ _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ }
+ }
+ else
+ {
+ _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String
+ }
+
+ }
+ else
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok
+ if ( (*this).GetChar(i) == cTok )
+ {
+ // Vorzeitiger Abbruch der Schleife moeglich, denn
+ // wir haben, was wir wollten.
+ nStartPos = i+1;
+ break;
+ }
+ else
+ {
+ _rStr += (*this).GetChar(i); // Zeichen gehoert zum Resultat-String
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OEvoabTable::refreshIndexes()
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool OEvoabTable::checkHeaderLine()
+{
+ if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine())
+ {
+ BOOL bRead2;
+ do
+ {
+ bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding());
+ }
+ while(bRead2 && !m_aCurrentLine.Len());
+
+ m_nFilePos = m_pFileStream->Tell();
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ }
+ return sal_True;
+}
+//------------------------------------------------------------------
+sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ if ( !m_pFileStream )
+ return sal_False;
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ m_nRowPos = 1;
+ // run through
+ case IResultSetHelper::NEXT:
+ if(eCursorPosition != IResultSetHelper::FIRST)
+ ++m_nRowPos;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ {
+ m_nMaxRowCount = m_nRowPos;
+ return sal_False;
+ }
+
+ m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos));
+
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ {
+ m_nMaxRowCount = m_nRowPos;
+ return sal_False;
+ }
+ nCurPos = m_pFileStream->Tell();
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ if(m_nRowPos > 0)
+ {
+ m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else
+ m_nRowPos = 0;
+
+ break;
+
+ break;
+ case IResultSetHelper::LAST:
+ if(m_nMaxRowCount)
+ {
+ m_nFilePos = m_aRowToFilePos.rbegin()->second;
+ m_nRowPos = m_aRowToFilePos.rbegin()->first;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else
+ {
+ while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row
+ // now I know all
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::RELATIVE:
+ if(nOffset > 0)
+ {
+ for(sal_Int32 i = 0;i<nOffset;++i)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else if(nOffset < 0)
+ {
+ for(sal_Int32 i = nOffset;i;++i)
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ {
+ if(nOffset < 0)
+ nOffset = m_nRowPos + nOffset;
+ ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset);
+ if(aIter != m_aRowToFilePos.end())
+ {
+ m_nFilePos = aIter->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table
+ {
+ m_nRowPos = m_nMaxRowCount;
+ return sal_False;
+ }
+ else
+ {
+ aIter = m_aRowToFilePos.upper_bound(nOffset);
+ if(aIter == m_aRowToFilePos.end())
+ {
+ m_nRowPos = m_aRowToFilePos.rbegin()->first;
+ nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second;
+ while(m_nRowPos != nOffset)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else
+ {
+ --aIter;
+ m_nRowPos = aIter->first;
+ m_nFilePos = aIter->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ }
+ }
+
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_pFileStream->Seek(nOffset);
+ if (m_pFileStream->IsEof())
+ return sal_False;
+
+ m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG)
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ break;
+ }
+
+ //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.cxx b/connectivity/source/drivers/evoab/LPreparedStatement.cxx
new file mode 100644
index 000000000000..028b26cb37c7
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LPreparedStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LPreparedStatement.hxx"
+#include "LResultSet.hxx"
+
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OEvoabPreparedStatement::createResultSet()
+{
+ return new OEvoabResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbc.driver.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
diff --git a/connectivity/source/drivers/evoab/LPreparedStatement.hxx b/connectivity/source/drivers/evoab/LPreparedStatement.hxx
new file mode 100644
index 000000000000..98ababa5e098
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LPreparedStatement.hxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_
+
+#include "file/FPreparedStatement.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OConnection;
+ class OEvoabPreparedStatement : public file::OPreparedStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OEvoabPreparedStatement( file::OConnection* _pConnection) : file::OPreparedStatement( _pConnection){};
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_EVOAB_LPREPAREDSTATEMENT_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LResultSet.cxx b/connectivity/source/drivers/evoab/LResultSet.cxx
new file mode 100644
index 000000000000..014d20ab4465
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LResultSet.cxx
@@ -0,0 +1,190 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include "LResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// using namespace com::sun::star::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OEvoabResultSet::OEvoabResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.evoab.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OEvoabResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if(rType == ::getCppuType((const Reference<XDeleteRows>*)0) || rType == ::getCppuType((const Reference<XResultSetUpdate>*)0)
+ || rType == ::getCppuType((const Reference<XRowUpdate>*)0))
+ return Any();
+
+ Any aRet = OResultSet::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OEvoabResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException)
+{
+ Sequence< Type > aTypes = OResultSet::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XDeleteRows>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XResultSetUpdate>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRowUpdate>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ Sequence< Type > aRet(pTypes, aOwnTypes.size());
+ return ::comphelper::concatSequences(aRet,OEvoabResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OEvoabResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False);
+
+ return relative(rows);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ return (lhs == rhs) ? 0 : 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ return comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OEvoabResultSet::getInfoHelper()
+{
+ return *OEvoabResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::acquire() throw()
+{
+ OEvoabResultSet_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::release() throw()
+{
+ OEvoabResultSet_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/evoab/LResultSet.hxx b/connectivity/source/drivers/evoab/LResultSet.hxx
new file mode 100644
index 000000000000..dc92169ec923
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LResultSet.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LRESULTSET_HXX_
+#define _CONNECTIVITY_EVOAB_LRESULTSET_HXX_
+
+#include "file/FResultSet.hxx"
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabResultSet;
+ // these typedef's are only necessary for the compiler
+ typedef ::cppu::ImplHelper1< ::com::sun::star::sdbcx::XRowLocate> OEvoabResultSet_BASE;
+ typedef file::OResultSet OEvoabResultSet_BASE2;
+ typedef ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet> OEvoabResultSet_BASE3;
+
+
+ class OEvoabResultSet : public OEvoabResultSet_BASE2,
+ public OEvoabResultSet_BASE,
+ public OEvoabResultSet_BASE3
+ {
+ sal_Bool m_bBookmarkable;
+ protected:
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OEvoabResultSet( file::OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif //_CONNECTIVITY_EVOAB_LRESULTSET_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LServices.cxx b/connectivity/source/drivers/evoab/LServices.cxx
new file mode 100644
index 000000000000..4ae9d4b9113b
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LServices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::evoab;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ OEvoabDriver::getImplementationName_Static(),
+ OEvoabDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ OEvoabDriver::getImplementationName_Static(),
+ OEvoabDriver::getSupportedServiceNames_Static(),
+ OEvoabDriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/evoab/LStatement.cxx b/connectivity/source/drivers/evoab/LStatement.cxx
new file mode 100644
index 000000000000..aacd54a590ba
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LStatement.hxx"
+#include "LResultSet.hxx"
+
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OEvoabStatement::createResultSet()
+{
+ return new OEvoabResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OEvoabStatement,"com.sun.star.sdbc.driver.evoab.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/evoab/LStatement.hxx b/connectivity/source/drivers/evoab/LStatement.hxx
new file mode 100644
index 000000000000..1e3b7fd6d10d
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LStatement.hxx
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_
+#define _CONNECTIVITY_EVOAB_LSTATEMENT_HXX_
+
+#include "file/FStatement.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OConnection;
+ class OEvoabStatement : public file::OStatement
+ {
+ protected:
+ virtual file::OResultSet* createResultSet();
+ public:
+ OEvoabStatement( file::OConnection* _pConnection) : file::OStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif //_CONNECTIVITY_EVOAB_LSTATEMENT_HXX_
diff --git a/connectivity/source/drivers/evoab/LTable.cxx b/connectivity/source/drivers/evoab/LTable.cxx
new file mode 100644
index 000000000000..6239765afe25
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LTable.cxx
@@ -0,0 +1,870 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <ctype.h>
+#include "LTable.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#ifndef _COM_SUN_STAR_SQLC_XROW_HPP_
+//#include <com/sun/star/sdbc/XRow.hpp>
+#endif
+#include <svl/converter.hxx>
+#include "LConnection.hxx"
+#include "LColumns.hxx"
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/math.hxx>
+#include <stdio.h> //sprintf
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include "LDriver.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <unotools/configmgr.hxx>
+#include <i18npool/mslangid.hxx>
+#include "connectivity/dbconversion.hxx"
+#include <comphelper/types.hxx>
+#include <unotools/syslocale.hxx>
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#include "LDebug.hxx"
+#endif
+#include <map>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+void OEvoabTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
+{
+ BOOL bRead = TRUE;
+
+ QuotedTokenizedString aHeaderLine;
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ if (pConnection->isHeaderLine())
+ {
+ while(bRead && !aHeaderLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,pConnection->getTextEncoding());
+ }
+ }
+
+ // read first row
+ QuotedTokenizedString aFirstLine;
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding());
+
+ if (!pConnection->isHeaderLine() || !aHeaderLine.Len())
+ {
+ while(bRead && !aFirstLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,pConnection->getTextEncoding());
+ }
+ // use first row as headerline because we need the number of columns
+ aHeaderLine = aFirstLine;
+ }
+ // column count
+ xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+
+ if(!m_aColumns.isValid())
+ m_aColumns = new OSQLColumns();
+ else
+ m_aColumns->get().clear();
+
+ m_aTypes.clear();
+ m_aPrecisions.clear();
+ m_aScales.clear();
+ // reserve some space
+ m_aColumnRawNames.reserve(nFieldCount);
+ m_aColumns->get().reserve(nFieldCount);
+ m_aTypes.reserve(nFieldCount);
+ m_aPrecisions.reserve(nFieldCount);
+ m_aScales.reserve(nFieldCount);
+
+ sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale);
+ // read description
+ sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aColumnName;
+ ::rtl::OUString aTypeName;
+ ::comphelper::UStringMixEqual aCase(bCase);
+ xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine2 = 0;
+ for (xub_StrLen i = 0; i < nFieldCount; i++)
+ {
+ if (pConnection->isHeaderLine())
+ {
+ aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+ }
+ else
+ {
+ // no column name so ...
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+ }
+ //OSL_TRACE("OEvoabTable::aColumnName = %s\n", ((OUtoCStr(::rtl::OUString(aColumnName))) ? (OUtoCStr(::rtl::OUString(aColumnName))):("NULL")) );
+
+ sal_Int32 eType;
+ UINT16 nPrecision = 0;
+ UINT16 nScale = 0;
+
+ BOOL bNumeric = FALSE;
+ ULONG nIndex = 0;
+
+ // first without fielddelimiter
+ String aField;
+ aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,pConnection->getFieldDelimiter(),'\0');
+ //OSL_TRACE("OEvoabTable::aField = %s\n", ((OUtoCStr(::rtl::OUString(aField))) ? (OUtoCStr(::rtl::OUString(aField))):("NULL")) );
+
+ if (aField.Len() == 0 ||
+ (pConnection->getStringDelimiter() && pConnection->getStringDelimiter() == aField.GetChar(0)))
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ String aField2;
+ if ( pConnection->getStringDelimiter() != '\0' )
+ aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+ else
+ aField2 = aField;
+
+ //OSL_TRACE("OEvoabTable::aField2 = %s\n", ((OUtoCStr(::rtl::OUString(aField2))) ? (OUtoCStr(::rtl::OUString(aField2))):("NULL")) );
+
+ if (aField2.Len() == 0)
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ bNumeric = TRUE;
+ xub_StrLen nDot = 0;
+ for (xub_StrLen j = 0; j < aField2.Len(); j++)
+ {
+ sal_Unicode c = aField2.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if ((!cDecimalDelimiter || c != cDecimalDelimiter) &&
+ (!cThousandDelimiter || c != cThousandDelimiter) &&
+ !aCharClass.isDigit(aField2,j))
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ if (cDecimalDelimiter && c == cDecimalDelimiter)
+ {
+ nPrecision = 15; // we have an decimal value
+ nScale = 2;
+ nDot++;
+ }
+ }
+
+ if (nDot > 1) // if there is more than one dot it isn't a number
+ bNumeric = FALSE;
+ if (bNumeric && cThousandDelimiter)
+ {
+ // Ist der Trenner richtig angegeben?
+ String aValue = aField2.GetToken(0,cDecimalDelimiter);
+ for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4)
+ {
+ sal_Unicode c = aValue.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if (c == cThousandDelimiter && j)
+ continue;
+ else
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ }
+ }
+
+ // jetzt koennte es noch ein Datumsfeld sein
+ if (!bNumeric)
+ {
+ try
+ {
+ nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ sal_Int32 nFlags = 0;
+ if (bNumeric)
+ {
+ if (cDecimalDelimiter)
+ {
+ if(nPrecision)
+ {
+ eType = DataType::DECIMAL;
+ aTypeName = ::rtl::OUString::createFromAscii("DECIMAL");
+ }
+ else
+ {
+ eType = DataType::DOUBLE;
+ aTypeName = ::rtl::OUString::createFromAscii("DOUBLE");
+ }
+ }
+ else
+ eType = DataType::INTEGER;
+ nFlags = ColumnSearch::BASIC;
+ }
+ else
+ {
+
+ switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex))
+ {
+ case NUMBERFORMAT_DATE:
+ eType = DataType::DATE;
+ aTypeName = ::rtl::OUString::createFromAscii("DATE");
+ break;
+ case NUMBERFORMAT_DATETIME:
+ eType = DataType::TIMESTAMP;
+ aTypeName = ::rtl::OUString::createFromAscii("TIMESTAMP");
+ break;
+ case NUMBERFORMAT_TIME:
+ eType = DataType::TIME;
+ aTypeName = ::rtl::OUString::createFromAscii("TIME");
+ break;
+ default:
+ eType = DataType::VARCHAR;
+ nPrecision = 0; // nyi: Daten koennen aber laenger sein!
+ nScale = 0;
+ aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
+ };
+ nFlags |= ColumnSearch::CHAR;
+ }
+
+ // check if the columname already exists
+ String aAlias(aColumnName);
+ OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ sal_Int32 nExprCnt = 0;
+ while(aFind != m_aColumns->get().end())
+ {
+ (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt);
+ aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ }
+
+ m_aColumnRawNames.push_back(::rtl::OUString(aAlias));
+
+ //~ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(),
+ //~ ColumnValue::NULLABLE,
+ //~ nPrecision,
+ //~ nScale,
+ //~ eType,
+ //~ sal_False,
+ //~ sal_False,
+ //~ sal_False,
+ //~ bCase);
+ //~ Reference< XPropertySet> xCol = pColumn;
+ //~ m_aColumns->push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nScale);
+ }
+ setColumnAliases();
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+}
+// -------------------------------------------------------------------------
+OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection) : OEvoabTable_BASE(_pTables,_pConnection)
+{
+
+}
+// -------------------------------------------------------------------------
+OEvoabTable::OEvoabTable(sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OEvoabTable_BASE(_pTables,_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_nRowPos(0)
+ ,m_nMaxRowCount(0)
+{
+ //~ OSL_TRACE("OEvoabTable::(in constructor)_Name = %s\n", ((OUtoCStr(_Name)) ? (OUtoCStr(_Name)):("NULL")) );
+ //~ OSL_TRACE("OEvoabTable::(in constructor)_Type = %s\n", ((OUtoCStr(_Type)) ? (OUtoCStr(_Type)):("NULL")) );
+ //~ OSL_TRACE("OEvoabTable::(in constructor)_Description = %s\n", ((OUtoCStr(_Description)) ? (OUtoCStr(_Description)):("NULL")) );
+ //~ OSL_TRACE("OEvoabTable::(in constructor)_SchemaName = %s\n", ((OUtoCStr(_SchemaName)) ? (OUtoCStr(_SchemaName)):("NULL")) );
+ //~ OSL_TRACE("OEvoabTable::(in constructor)_CatalogName = %s\n", ((OUtoCStr(_CatalogName)) ? (OUtoCStr(_CatalogName)):("NULL")) );
+}
+// -----------------------------------------------------------------------------
+void OEvoabTable::construct()
+{
+ SvtSysLocale aLocale;
+ ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale());
+ Sequence< ::com::sun::star::uno::Any > aArg(1);
+ aArg[0] <<= aAppLocale;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY);
+ m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY);
+ m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier);
+
+ INetURLObject aURL;
+ aURL.SetURL(getEntry());
+
+ if(aURL.getExtension() != rtl::OUString(m_pConnection->getExtension()))
+ aURL.setExtension(m_pConnection->getExtension());
+
+ String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+
+ if(!m_pFileStream)
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+
+ if(m_pFileStream)
+ {
+ OSL_TRACE("OEvoabTable::construct()::m_pFileStream created\n" );
+ m_pFileStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = m_pFileStream->Tell();
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
+ nSize > 100000 ? 16384 :
+ nSize > 10000 ? 4096 : 1024);
+ OSL_TRACE("OEvoabTable::construct()::m_pFileStream->Tell() = %d\n", nSize );
+
+ fillColumns(aAppLocale);
+
+ refreshColumns();
+ }
+}
+// -------------------------------------------------------------------------
+String OEvoabTable::getEntry()
+{
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet();
+ Reference< XRow> xRow(xDir,UNO_QUERY);
+ ::rtl::OUString sName;
+ ::rtl::OUString sExt;
+
+ INetURLObject aURL;
+ xDir->beforeFirst();
+ static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/"));
+ while(xDir->next())
+ {
+ sName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = m_pConnection->getURL() + s_sSeparator + sName;
+ aURL.SetSmartURL( sUrl );
+
+ // cut the extension
+ sExt = aURL.getExtension();
+
+ // name and extension have to coincide
+ if ( m_pConnection->matchesExtension( sExt ) )
+ {
+ sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString());
+ if ( sName == m_Name )
+ {
+ Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY );
+ sURL = xContentAccess->queryContentIdentifierString();
+ break;
+ }
+ }
+ }
+ xDir->beforeFirst(); // move back to before first record
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT(0);
+ }
+ return sURL.getStr();
+}
+// -------------------------------------------------------------------------
+void OEvoabTable::refreshColumns()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+ aVector.reserve(m_aColumns->get().size());
+
+ for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OEvoabColumns(this,m_aMutex,aVector);
+
+ OSL_TRACE("OEvoabTable::refreshColumns()::end\n" );
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabTable::disposing(void)
+{
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aColumns = NULL;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OEvoabTable::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRename>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OEvoabTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ Any aRet = OTable_TYPEDEF::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OEvoabTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OEvoabTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OEvoabTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Bool OEvoabTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData)
+{
+ *(_rRow->get())[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ // Felder:
+ xub_StrLen nStartPos = 0;
+ String aStr;
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ for (sal_Int32 i = 0; aIter != _rCols.get().end();++aIter, ++i)
+ {
+ m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,pConnection->getFieldDelimiter(),pConnection->getStringDelimiter());
+ //OSL_TRACE("OEvoabTable::fetchRow()::aStr = %s\n", ((OUtoCStr(::rtl::OUString(aStr))) ? (OUtoCStr(::rtl::OUString(aStr))):("NULL")) );
+
+ if (aStr.Len() == 0)
+ (_rRow->get())[i+1]->setNull();
+ else
+ {
+ // Laengen je nach Datentyp:
+ sal_Int32 nLen,
+ nType = 0;
+ if(bIsTable)
+ {
+ nLen = m_aPrecisions[i];
+ nType = m_aTypes[i];
+ }
+ else
+ {
+ Reference< XPropertySet> xColumn = *aIter;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ switch(nType)
+ {
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ double nRes = 0.0;
+ try
+ {
+ nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr);
+ Reference<XPropertySet> xProp(m_xNumberFormatter->getNumberFormatsSupplier()->getNumberFormatSettings(),UNO_QUERY);
+ com::sun::star::util::Date aDate;
+ xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= aDate;
+
+ switch(nType)
+ {
+ case DataType::DATE:
+ *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,aDate));
+ break;
+ case DataType::TIMESTAMP:
+ *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,aDate));
+ break;
+ default:
+ *(_rRow->get())[i+1] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes));
+ }
+ }
+ catch(Exception&)
+ {
+ (_rRow->get())[i+1]->setNull();
+ }
+ } break;
+ case DataType::DOUBLE:
+ case DataType::INTEGER:
+ case DataType::DECIMAL: // #99178# OJ
+ case DataType::NUMERIC:
+ {
+ sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aStrConverted;
+
+ OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER ||
+ !cDecimalDelimiter && nType == DataType::INTEGER,
+ "FalscherTyp");
+
+ // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln:
+ for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ {
+ if (cDecimalDelimiter && aStr.GetChar(j) == cDecimalDelimiter)
+ aStrConverted += '.';
+ else if ( aStr.GetChar(j) == '.' ) // special case, if decimal seperator isn't '.' we have to vut the string after it
+ break; // #99189# OJ
+ else if (cThousandDelimiter && aStr.GetChar(j) == cThousandDelimiter)
+ {
+ // weglassen
+ }
+ else
+ aStrConverted += aStr.GetChar(j) ;
+ }
+ double nVal = ::rtl::math::stringToDouble(aStrConverted.GetBuffer(),',','.',NULL,NULL);
+
+ // #99178# OJ
+ if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType )
+ *(_rRow->get())[i+1] = ORowSetValue(String::CreateFromDouble(nVal));
+ else
+ *(_rRow->get())[i+1] = nVal;
+ } break;
+
+ default:
+ {
+ // Wert als String in Variable der Row uebernehmen
+ *(_rRow->get())[i+1] = ORowSetValue(aStr);
+ }
+ break;
+ }
+ }
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OEvoabTable::setColumnAliases()
+{
+
+ size_t nSize = m_aColumnRawNames.size();
+ if(nSize == 0 || m_aPrecisions.size() != nSize || m_aScales.size() != nSize || m_aTypes.size() != nSize)
+ return sal_False;
+ m_aColumns->get().clear();
+ m_aColumns->get().reserve(nSize);
+ ::rtl::OUString aColumnReadName;
+ ::rtl::OUString aColumnHeadlineName;
+ ::rtl::OUString aColumnDisplayName;
+ ::rtl::OUString aColumnFinalName;
+ String sColumnFinalName;
+
+ const TStringVector& colAliasNames = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAlias();
+ const ::std::map< ::rtl::OUString, ::rtl::OUString > & colMap = ((OEvoabConnection*)m_pConnection)->getColumnAlias().getAliasMap();
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ for(size_t i = 0;i < nSize; ++i)
+ {
+ aColumnReadName = m_aColumnRawNames[i];
+ //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnReadName = %s\n", ((OUtoCStr(aColumnReadName)) ? (OUtoCStr(aColumnReadName)):("NULL")) );
+ sal_Bool bFound = sal_False;
+ for ( size_t j = 0; j < colAliasNames.size(); ++j )
+ {
+ aColumnDisplayName = colAliasNames[j];
+
+ ::std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator aPos = colMap.find( aColumnDisplayName );
+ if ( colMap.end() != aPos )
+ {
+ aColumnHeadlineName = aPos->second;
+ EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", aColumnDisplayName );
+ EVO_TRACE_STRING( "OEvoabTable::getColumnRows()::aColumnHeadlineName= %s\n", aColumnHeadlineName );
+ if(aColumnReadName == aColumnHeadlineName)
+ {
+ //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnHeadlineName = %s\n", ((OUtoCStr(aColumnHeadlineName)) ? (OUtoCStr(aColumnHeadlineName)):("NULL")) );
+ //OSL_TRACE("OEvoabTable::getColumnRows()::aColumnDisplayName = %s\n", ((OUtoCStr(aColumnDisplayName)) ? (OUtoCStr(aColumnDisplayName)):("NULL")) );
+ aColumnFinalName = aColumnDisplayName;
+ bFound = sal_True;
+ //OSL_TRACE("OEvoabTable::getColumnRows()::j = %d\n", j );
+
+ break;
+ }
+ }
+ else
+ OSL_ENSURE( sal_False, "OEvoabTable::setColumnAliases: did not find one of the aliases!" );
+ }
+ if(!bFound)
+ aColumnFinalName = aColumnReadName;
+ sColumnFinalName = aColumnFinalName;
+
+ sal_Bool bCase = getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ ::rtl::OUString aTypeName;
+ aTypeName = ::rtl::OUString::createFromAscii("VARCHAR");
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn(sColumnFinalName,aTypeName,::rtl::OUString(),
+ ColumnValue::NULLABLE,
+ m_aPrecisions[i],
+ m_aScales[i],
+ m_aTypes[i],
+ sal_False,
+ sal_False,
+ sal_False,
+ bCase);
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->get().push_back(xCol);
+ }
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OEvoabTable::refreshIndexes()
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool OEvoabTable::checkHeaderLine()
+{
+ if (m_nFilePos == 0 && ((OEvoabConnection*)m_pConnection)->isHeaderLine())
+ {
+ BOOL bRead2;
+ do
+ {
+ bRead2 = m_pFileStream->ReadByteStringLine(m_aCurrentLine,m_pConnection->getTextEncoding());
+ }
+ while(bRead2 && !m_aCurrentLine.Len());
+
+ m_nFilePos = m_pFileStream->Tell();
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ }
+ return sal_True;
+}
+//------------------------------------------------------------------
+sal_Bool OEvoabTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ //OSL_TRACE("OEvoabTable::(before SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ if ( !m_pFileStream )
+ return sal_False;
+ OEvoabConnection* pConnection = (OEvoabConnection*)m_pConnection;
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ //OSL_TRACE("OEvoabTable::(before SeekRow,m_pFileStriam Exist)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::FIRST:
+ m_nFilePos = 0;
+ m_nRowPos = 1;
+ // run through
+ case IResultSetHelper::NEXT:
+ if(eCursorPosition != IResultSetHelper::FIRST)
+ ++m_nRowPos;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ {
+ m_nMaxRowCount = m_nRowPos;
+ return sal_False;
+ }
+
+ m_aRowToFilePos.insert(::std::map<sal_Int32,sal_Int32>::value_type(m_nRowPos,m_nFilePos));
+
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ {
+ m_nMaxRowCount = m_nRowPos;
+ return sal_False;
+ }
+ nCurPos = m_pFileStream->Tell();
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ if(m_nRowPos > 0)
+ {
+ m_nFilePos = m_aRowToFilePos.find(m_nRowPos)->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else
+ m_nRowPos = 0;
+
+ break;
+ case IResultSetHelper::LAST:
+ if(m_nMaxRowCount)
+ {
+ m_nFilePos = m_aRowToFilePos.rbegin()->second;
+ m_nRowPos = m_aRowToFilePos.rbegin()->first;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else
+ {
+ while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row
+ // now I know all
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::RELATIVE:
+ if(nOffset > 0)
+ {
+ for(sal_Int32 i = 0;i<nOffset;++i)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else if(nOffset < 0)
+ {
+ for(sal_Int32 i = nOffset;i;++i)
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ {
+ if(nOffset < 0)
+ nOffset = m_nRowPos + nOffset;
+ ::std::map<sal_Int32,sal_Int32>::const_iterator aIter = m_aRowToFilePos.find(nOffset);
+ if(aIter != m_aRowToFilePos.end())
+ {
+ m_nFilePos = aIter->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table
+ {
+ m_nRowPos = m_nMaxRowCount;
+ return sal_False;
+ }
+ else
+ {
+ aIter = m_aRowToFilePos.upper_bound(nOffset);
+ if(aIter == m_aRowToFilePos.end())
+ {
+ m_nRowPos = m_aRowToFilePos.rbegin()->first;
+ nCurPos = m_nFilePos = m_aRowToFilePos.rbegin()->second;
+ while(m_nRowPos != nOffset)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else
+ {
+ --aIter;
+ m_nRowPos = aIter->first;
+ m_nFilePos = aIter->second;
+ m_pFileStream->Seek(m_nFilePos);
+ if (m_pFileStream->IsEof() || !checkHeaderLine())
+ return sal_False;
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ }
+ }
+ }
+
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_pFileStream->Seek(nOffset);
+ if (m_pFileStream->IsEof())
+ return sal_False;
+
+ m_nFilePos = m_pFileStream->Tell(); // Byte-Position in der Datei merken (am ZeilenANFANG)
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,pConnection->getTextEncoding());
+ if (m_pFileStream->IsEof())
+ return sal_False;
+ nCurPos = m_pFileStream->Tell();
+ break;
+ }
+
+ //OSL_TRACE("OEvoabTable::(after SeekRow)m_aCurrentLine = %d\n", ((OUtoCStr(::rtl::OUString(m_aCurrentLine))) ? (OUtoCStr(::rtl::OUString(m_aCurrentLine))):("NULL")) );
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab/LTable.hxx b/connectivity/source/drivers/evoab/LTable.hxx
new file mode 100644
index 000000000000..6261aec2d0ac
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LTable.hxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LTABLE_HXX_
+#define _CONNECTIVITY_EVOAB_LTABLE_HXX_
+
+#include "file/FTable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <tools/urlobj.hxx>
+#include "file/quotedstring.hxx"
+#include <vector>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ typedef file::OFileTable OEvoabTable_BASE;
+ class OEvoabConnection;
+
+ typedef ::std::map< ::rtl::OUString,
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNamed>, comphelper::UStringMixLess > OContainer;
+
+ class OEvoabTable : public OEvoabTable_BASE
+ {
+ private:
+ // maps a row postion to a file position
+ ::std::map<sal_Int32,sal_Int32> m_aRowToFilePos;
+ ::std::vector<sal_Int32> m_aTypes; // holds all type for columns just to avoid to ask the propertyset
+ ::std::vector<sal_Int32> m_aPrecisions; // same as aboth
+ ::std::vector<sal_Int32> m_aScales;
+ QuotedTokenizedString m_aCurrentLine;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatter > m_xNumberFormatter;
+ sal_Int32 m_nRowPos;
+ sal_Int32 m_nMaxRowCount; // will be set if stream is once eof
+ ::std::vector< ::rtl::OUString> m_aColumnRawNames;
+ sal_Bool setColumnAliases();
+ void fillColumns(const ::com::sun::star::lang::Locale& _aLocale);
+ sal_Bool checkHeaderLine();
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet> isUniqueByColumnName(const ::rtl::OUString& _rColName);
+
+ public:
+ virtual void refreshColumns();
+ virtual void refreshIndexes();
+
+ public:
+ // DECLARE_CTY_DEFAULTS( OFlatTable_BASE);
+ OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection);
+ OEvoabTable( sdbcx::OCollection* _pTables,OEvoabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description = ::rtl::OUString(),
+ const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
+ const ::rtl::OUString& _CatalogName = ::rtl::OUString()
+ );
+
+ void construct(); // can throw any exception
+
+ virtual sal_Bool seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos);
+ virtual sal_Bool fetchRow(OValueRefRow& _rRow,const OSQLColumns& _rCols, sal_Bool bIsTable,sal_Bool bRetrieveData);
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL disposing(void);
+
+ // com::sun::star::lang::XUnoTunnel
+ virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& aIdentifier ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< sal_Int8 > getUnoTunnelImplementationId();
+
+ String getEntry();
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LTABLE_HXX_
+
diff --git a/connectivity/source/drivers/evoab/LTables.cxx b/connectivity/source/drivers/evoab/LTables.cxx
new file mode 100644
index 000000000000..da880e8793c9
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LTables.cxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "LTables.hxx"
+#include "LTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace connectivity::evoab;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType OEvoabTables::createObject(const ::rtl::OUString& _rName)
+{
+ OEvoabTable* pRet = new OEvoabTable(this,(OEvoabConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+ sdbcx::ObjectType xRet = pRet;
+ pRet->construct();
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/evoab/LTables.hxx b/connectivity/source/drivers/evoab/LTables.hxx
new file mode 100644
index 000000000000..6180493db49e
--- /dev/null
+++ b/connectivity/source/drivers/evoab/LTables.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_LTABLES_HXX_
+#define _CONNECTIVITY_EVOAB_LTABLES_HXX_
+
+#include "file/FTables.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ // namespace ::com::sun::star::sdbcx = ::com::sun::star::sdbcx;
+ typedef file::OTables OEvoabTables_BASE;
+
+ class OEvoabTables : public OEvoabTables_BASE
+ {
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ public:
+ OEvoabTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : OEvoabTables_BASE(_rMetaData,_rParent,_rMutex,_rVector)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_LTABLES_HXX_
+
diff --git a/connectivity/source/drivers/evoab/evoab.xcu b/connectivity/source/drivers/evoab/evoab.xcu
new file mode 100755
index 000000000000..c54c9856cad9
--- /dev/null
+++ b/connectivity/source/drivers/evoab/evoab.xcu
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:evolution:ldap" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Evolution LDAP</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:evolution:groupwise" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Groupwise</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/evoab/evoab.xml b/connectivity/source/drivers/evoab/evoab.xml
new file mode 100644
index 000000000000..8ed16719ae0e
--- /dev/null
+++ b/connectivity/source/drivers/evoab/evoab.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Xibei(Berry) Jia</author>
+ <name>com.sun.star.comp.sdbc.evoab.OEvoabDriver</name>
+ <description>This library implements the database driver for evolution address book formats.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>file</runtime-module-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/evoab/exports.dxp b/connectivity/source/drivers/evoab/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/evoab/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/evoab/makefile.mk b/connectivity/source/drivers/evoab/makefile.mk
new file mode 100644
index 000000000000..c1dbc21cdf1e
--- /dev/null
+++ b/connectivity/source/drivers/evoab/makefile.mk
@@ -0,0 +1,104 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=evoab
+
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/version.mk
+.INCLUDE : $(PRJ)$/makefile.pmk
+
+.IF "$(GUI)"=="UNX"
+
+# --- Files -------------------------------------
+
+EXCEPTIONSFILES=\
+ $(SLO)$/LResultSet.obj \
+ $(SLO)$/LStatement.obj \
+ $(SLO)$/LPreparedStatement.obj \
+ $(SLO)$/LFolderList.obj \
+ $(SLO)$/LConfigAccess.obj \
+ $(SLO)$/LColumnAlias.obj \
+ $(SLO)$/LTable.obj \
+ $(SLO)$/LDatabaseMetaData.obj \
+ $(SLO)$/LCatalog.obj \
+ $(SLO)$/LColumns.obj \
+ $(SLO)$/LTables.obj \
+ $(SLO)$/LConnection.obj \
+ $(SLO)$/LServices.obj \
+ $(SLO)$/LDriver.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/LDebug.obj
+
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+
+# --- Library -----------------------------------
+#SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1TARGET= $(EVOAB_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(TOOLSLIB) \
+ $(SVTOOLLIB) \
+ $(UNOTOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBFILELIB)" == ""
+SHL1STDLIBS+= ifile.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+.ELSE
+dummy:
+ @echo "Nothing to build for GUI $(GUI)"
+.ENDIF
+# --- Targets ----------------------------------
+.INCLUDE : $(PRJ)$/target.pmk
diff --git a/connectivity/source/drivers/evoab2/EApi.cxx b/connectivity/source/drivers/evoab2/EApi.cxx
new file mode 100644
index 000000000000..93bae2790ff0
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/EApi.cxx
@@ -0,0 +1,135 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <rtl/ustring.hxx>
+#include <osl/module.h>
+#include <stdio.h>
+#define DECLARE_FN_POINTERS 1
+#include "EApi.h"
+static const char *eBookLibNames[] = {
+ "libebook-1.2.so.9", // evolution-2.8
+ "libebook-1.2.so.5", // evolution-2.4 and 2.6+
+ "libebook-1.2.so.3", // evolution-2.2
+ "libebook.so.8" // evolution-2.0
+};
+
+typedef void (*SymbolFunc) (void);
+
+#define SYM_MAP(a) { #a, (SymbolFunc *)&a }
+ static struct {
+ const char *sym_name;
+ SymbolFunc *ref_value;
+ } aApiMap[] = {
+ SYM_MAP( e_contact_field_name ),
+ SYM_MAP( e_contact_get ),
+ SYM_MAP( e_contact_get_type ),
+ SYM_MAP( e_contact_field_id ),
+ SYM_MAP( e_source_peek_name ),
+ SYM_MAP( e_source_get_property ),
+ SYM_MAP( e_source_list_peek_groups ),
+ SYM_MAP( e_source_group_peek_sources ),
+ SYM_MAP( e_book_new ),
+ SYM_MAP( e_book_open ),
+ SYM_MAP( e_book_get_uri ),
+ SYM_MAP( e_book_get_source ),
+ SYM_MAP( e_book_get_addressbooks ),
+ SYM_MAP( e_book_get_contacts ),
+ SYM_MAP( e_book_authenticate_user ),
+ SYM_MAP( e_book_query_field_test ),
+ SYM_MAP( e_book_query_and ),
+ SYM_MAP( e_book_query_or ),
+ SYM_MAP( e_book_query_not ),
+ SYM_MAP( e_book_query_ref ),
+ SYM_MAP( e_book_query_unref ),
+ SYM_MAP( e_book_query_from_string ),
+ SYM_MAP( e_book_query_to_string ),
+ SYM_MAP( e_book_query_field_exists ),
+ SYM_MAP( e_source_group_peek_base_uri)
+ };
+#undef SYM_MAP
+
+static bool
+tryLink( oslModule &aModule, const char *pName )
+{
+ for( guint i = 0; i < G_N_ELEMENTS( aApiMap ); i++ )
+ {
+ SymbolFunc aMethod;
+ aMethod = (SymbolFunc) osl_getFunctionSymbol
+ ( aModule, rtl::OUString::createFromAscii ( aApiMap[ i ].sym_name ).pData );
+ if( !aMethod )
+ {
+ fprintf( stderr, "Warning: missing symbol '%s' in '%s'",
+ aApiMap[ i ].sym_name, pName );
+ return false;
+ }
+ * aApiMap[ i ].ref_value = aMethod;
+ }
+ return true;
+}
+
+bool EApiInit()
+{
+ oslModule aModule;
+
+ for( guint j = 0; j < G_N_ELEMENTS( eBookLibNames ); j++ )
+ {
+ aModule = osl_loadModule( rtl::OUString::createFromAscii
+ ( eBookLibNames[ j ] ).pData,
+ SAL_LOADMODULE_DEFAULT );
+ if( aModule)
+ {
+ if ( tryLink( aModule, eBookLibNames[ j ] ) )
+ return true;
+ osl_unloadModule( aModule );
+ }
+ }
+ fprintf( stderr, "Can find no compliant libebook client libraries\n" );
+ return false;
+}
+
+#if 0
+// hjs: SOLARDEF does no longer exist please lookup the required
+// defines in a regular compile line
+/*
+ * Test code - enable &
+ *
+ * Compile with ( after source LinuxIntelEnv.Set.sh )
+ gcc $SOLARDEF -I $SOLARVER/$UPD/$INPATH/inc \
+ -I. `pkg-config --cflags --libs gobject-2.0` \
+ -L $SOLARVER/$UPD/$INPATH/lib -luno_sal -lstdc++ EApi.cxx
+ */
+
+int main( int argc, char **argv)
+{
+ return EApiInit();
+}
+
+#endif
+
diff --git a/connectivity/source/drivers/evoab2/EApi.h b/connectivity/source/drivers/evoab2/EApi.h
new file mode 100644
index 000000000000..7a0584815eed
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/EApi.h
@@ -0,0 +1,143 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_EVOLUTION_API_HXX_
+#define _CONNECTIVITY_EVOAB_EVOLUTION_API_HXX_
+#include <glib-object.h>
+
+// Initializes the API below, returns false if not available
+bool EApiInit();
+
+G_BEGIN_DECLS
+
+// This header defined all the API methods as
+// function pointers instead of real functions
+// this will all evaporate as it is compiled generating
+// no symbol lookups or relocations, but giving code
+// clarity.
+
+// We attempt to define a minimum API that we use:
+
+// e-contact.h
+#ifdef DECLARE_FN_POINTERS
+#define EAPI_EXTERN
+#else
+#define EAPI_EXTERN extern
+#endif
+
+
+typedef void EContact;
+#define E_CONTACT(a) ((EContact *)(a))
+#define E_TYPE_CONTACT (e_contact_get_type())
+typedef int EContactField;
+
+EAPI_EXTERN const char *(*e_contact_field_name) ( EContactField field_id);
+EAPI_EXTERN gpointer (*e_contact_get) (EContact *contact, EContactField field_id);
+EAPI_EXTERN gconstpointer (*e_contact_get_const) (EContact *contact, EContactField field_id);
+// e-source.h
+typedef void ESource;
+#define E_SOURCE(a) ((ESource *)(a))
+EAPI_EXTERN const char *(*e_source_peek_name) (ESource *source);
+EAPI_EXTERN const gchar *(*e_source_get_property) (ESource *source,
+ const gchar *property);
+
+EAPI_EXTERN GType (*e_contact_get_type) (void);
+EAPI_EXTERN EContactField (*e_contact_field_id) (const char *field_name);
+
+// e-source-list.h
+typedef void ESourceList;
+EAPI_EXTERN GSList *(*e_source_list_peek_groups) (ESourceList *list);
+
+// e-source-group.h
+typedef void ESourceGroup;
+#define E_SOURCE_GROUP(a) ((ESourceGroup *)(a))
+
+EAPI_EXTERN GSList *(*e_source_group_peek_sources) (ESourceGroup *group);
+EAPI_EXTERN const char *(*e_source_group_peek_base_uri) (ESourceGroup *group);
+// e-book.h
+typedef enum {
+ E_BOOK_QUERY_IS,
+ E_BOOK_QUERY_CONTAINS,
+ E_BOOK_QUERY_BEGINS_WITH,
+ E_BOOK_QUERY_ENDS_WITH,
+} EBookQueryTest;
+
+typedef void EBook;
+typedef void EBookQuery;
+
+EAPI_EXTERN EBook *(*e_book_new) (ESource *source,
+ GError **error);
+
+EAPI_EXTERN gboolean (*e_book_open) (EBook *book,
+ gboolean only_if_exists,
+ GError **error);
+
+EAPI_EXTERN const char *(*e_book_get_uri) (EBook *book);
+EAPI_EXTERN ESource *(*e_book_get_source)(EBook *book);
+
+EAPI_EXTERN gboolean (*e_book_get_addressbooks) (ESourceList **addressbook_sources,
+ GError **error);
+
+EAPI_EXTERN gboolean (*e_book_get_contacts) (EBook *book,
+ EBookQuery *query,
+ GList **contacts,
+ GError **error);
+
+EAPI_EXTERN gboolean (*e_book_authenticate_user) (EBook *book,
+ const char *user,
+ const char *passwd,
+ const char *auth_method,
+ GError **error);
+
+// e-book-query.h
+EAPI_EXTERN EBookQuery* (*e_book_query_field_exists) (EContactField field);
+EAPI_EXTERN EBookQuery* (*e_book_query_field_test) (EContactField field,
+ EBookQueryTest test,
+ const char *value);
+EAPI_EXTERN EBookQuery* (*e_book_query_and) (int nqs, EBookQuery **qs, gboolean unref);
+EAPI_EXTERN EBookQuery* (*e_book_query_or) (int nqs, EBookQuery **qs, gboolean unref);
+EAPI_EXTERN EBookQuery* (*e_book_query_not) (EBookQuery *q, gboolean unref);
+EAPI_EXTERN EBookQuery* (*e_book_query_ref) (EBookQuery *q);
+EAPI_EXTERN void (*e_book_query_unref) (EBookQuery *q);
+EAPI_EXTERN char* (*e_book_query_to_string) (EBookQuery *q);
+EAPI_EXTERN EBookQuery* (*e_book_query_from_string) (const char *query_string);
+
+typedef struct {
+ char *address_format; /* the two letter country code that
+ determines the format/meaning of the
+ following fields */
+ char *po;
+ char *ext;
+ char *street;
+ char *locality;
+ char *region;
+ char *code;
+ char *country;
+} EContactAddress;
+G_END_DECLS
+#endif
+
diff --git a/connectivity/source/drivers/evoab2/NCatalog.cxx b/connectivity/source/drivers/evoab2/NCatalog.cxx
new file mode 100644
index 000000000000..3417a7549a8f
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NCatalog.cxx
@@ -0,0 +1,100 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NCatalog.hxx"
+#include "NConnection.hxx"
+#include "NTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "NDebug.hxx"
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity::evoab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OEvoabCatalog::OEvoabCatalog(OEvoabConnection* _pCon) :
+ connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_xMetaData(m_pConnection->getMetaData())
+{
+}
+void OEvoabCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+
+ while(xResult->next())
+ {
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OEvoabTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OEvoabCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ try
+ {
+ if (!m_pTables) {
+ refreshTables();
+ }
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return m_pTables;
+}
+
diff --git a/connectivity/source/drivers/evoab2/NCatalog.hxx b/connectivity/source/drivers/evoab2/NCatalog.hxx
new file mode 100644
index 000000000000..c70fc9e934dc
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NCatalog.hxx
@@ -0,0 +1,56 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_CATALOG_HXX_
+#define _CONNECTIVITY_EVOAB_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabConnection;
+ class OEvoabCatalog : public connectivity::sdbcx::OCatalog
+ {
+ OEvoabConnection *m_pConnection;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ public:
+ OEvoabCatalog(OEvoabConnection *_pCon);
+ inline OEvoabConnection* getConnection() const { return m_pConnection; }
+ virtual void refreshTables();
+ virtual void refreshViews() {}
+ virtual void refreshGroups() {}
+ virtual void refreshUsers() {}
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(
+ ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_CATALOG_HXX_
+
diff --git a/connectivity/source/drivers/evoab2/NColumns.cxx b/connectivity/source/drivers/evoab2/NColumns.cxx
new file mode 100644
index 000000000000..d1854e62181d
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NColumns.cxx
@@ -0,0 +1,90 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "NColumns.hxx"
+#include "NTable.hxx"
+#include "NTables.hxx"
+#include "NCatalog.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace connectivity::evoab;
+
+// -------------------------------------------------------------------------
+sdbcx::ObjectType OEvoabColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
+ Any(),
+ m_pTable->getSchema(),
+ m_pTable->getTableName(),
+ _rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+
+ while (xResult->next())
+ {
+ if (xRow->getString(4) == _rName)
+ {
+ OColumn* pRet = new OColumn(
+ _rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False,
+ sal_False,
+ sal_False,
+ sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OEvoabColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
diff --git a/connectivity/source/drivers/evoab2/NColumns.hxx b/connectivity/source/drivers/evoab2/NColumns.hxx
new file mode 100644
index 000000000000..09cebefa7158
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NColumns.hxx
@@ -0,0 +1,57 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_COLUMNS_HXX_
+#define _CONNECTIVITY_EVOAB_COLUMNS_HXX_
+
+#include "NTable.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabColumns : public sdbcx::OCollection
+ {
+ protected:
+ OEvoabTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ OEvoabColumns( OEvoabTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector),
+ m_pTable(_pTable)
+ { }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_EVOAB_COLUMNS_HXX_
diff --git a/connectivity/source/drivers/evoab2/NConnection.cxx b/connectivity/source/drivers/evoab2/NConnection.cxx
new file mode 100644
index 000000000000..0f95aebb75c3
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NConnection.cxx
@@ -0,0 +1,292 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NConnection.hxx"
+#include "NDatabaseMetaData.hxx"
+#include "NCatalog.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <tools/urlobj.hxx>
+#include "NPreparedStatement.hxx"
+#include "NStatement.hxx"
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+#include <comphelper/processfactory.hxx>
+#include <vos/process.hxx>
+#include <tools/debug.hxx>
+#include "NDebug.hxx"
+#include <comphelper/sequence.hxx>
+
+using namespace connectivity::evoab;
+using namespace vos;
+using namespace dbtools;
+
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+::rtl::OUString implGetExceptionMsg( Exception& e, const ::rtl::OUString& aExceptionType_ )
+{
+ ::rtl::OUString aExceptionType = aExceptionType_;
+ if( aExceptionType.getLength() == 0 )
+ aExceptionType = ::rtl::OUString::createFromAscii("Unknown" ) ;
+
+ ::rtl::OUString aTypeLine( RTL_CONSTASCII_USTRINGPARAM("\nType: " ) );
+ aTypeLine += aExceptionType;
+
+ ::rtl::OUString aMessageLine( RTL_CONSTASCII_USTRINGPARAM("\nMessage: " ) );
+ aMessageLine += ::rtl::OUString( e.Message );
+
+ ::rtl::OUString aMsg(aTypeLine);
+ aMsg += aMessageLine;
+ return aMsg;
+}
+
+ // Exception type unknown
+::rtl::OUString implGetExceptionMsg( Exception& e )
+{
+ ::rtl::OUString aMsg = implGetExceptionMsg( e, ::rtl::OUString() );
+ return aMsg;
+}
+
+// --------------------------------------------------------------------------------
+OEvoabConnection::OEvoabConnection( OEvoabDriver& _rDriver )
+ :OSubComponent<OEvoabConnection, OConnection_BASE>( (::cppu::OWeakObject*)(&_rDriver), this )
+ ,m_rDriver(_rDriver)
+ ,m_xCatalog(NULL)
+{
+}
+//-----------------------------------------------------------------------------
+OEvoabConnection::~OEvoabConnection()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if(!isClosed()) {
+ acquire();
+ close();
+ }
+}
+
+//-----------------------------------------------------------------------------
+void SAL_CALL OEvoabConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OEvoabConnection, "com.sun.star.sdbc.drivers.evoab.Connection", "com.sun.star.sdbc.Connection")
+
+//-----------------------------------------------------------------------------
+void OEvoabConnection::construct(const ::rtl::OUString& url, const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ EVO_TRACE_STRING("OEvoabConnection::construct()::url = %s\n", url );
+
+ ::rtl::OUString sPassword;
+ const char* pPwd = "password";
+
+ const PropertyValue *pIter = info.getConstArray();
+ const PropertyValue *pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(!pIter->Name.compareToAscii(pPwd))
+ {
+ pIter->Value >>= sPassword;
+ break;
+ }
+ }
+
+ if (url.equalsAscii("sdbc:address:evolution:groupwise"))
+ setSDBCAddressType(SDBCAddress::EVO_GWISE);
+ else if (url.equalsAscii("sdbc:address:evolution:ldap"))
+ setSDBCAddressType(SDBCAddress::EVO_LDAP);
+ else
+ setSDBCAddressType(SDBCAddress::EVO_LOCAL);
+ setURL(url);
+ setPassword(::rtl::OUStringToOString(sPassword,RTL_TEXTENCODING_UTF8));
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ // when you need to transform SQL92 to you driver specific you can do it here
+ return _sSql;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OEvoabConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OEvoabDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XTablesSupplier > OEvoabConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ OEvoabCatalog *pCat = new OEvoabCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OEvoabConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ OStatement* pStmt = new OStatement(this);
+
+ Reference< XStatement > xStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ OEvoabPreparedStatement* pStmt = new OEvoabPreparedStatement( this );
+ Reference< XPreparedStatement > xStmt = pStmt;
+ pStmt->construct( sql );
+
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+
+Reference< XPreparedStatement > SAL_CALL OEvoabConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw( SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+sal_Bool SAL_CALL OEvoabConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OEvoabConnection::close( ) throw(SQLException, RuntimeException)
+{
+ { // we just dispose us
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OEvoabConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return m_aWarnings.getWarnings();
+}
+void SAL_CALL OEvoabConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ m_aWarnings.clearWarnings();
+}
+//------------------------------------------------------------------------------
+
+void OEvoabConnection::disposing()
+{
+ // we noticed that we should be destroyed in near future so we have to dispose our statements
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OConnection_BASE::disposing();
+ dispose_ChildImpl();
+}
+
+// -------------------------------- stubbed methods ------------------------------------------------
+void SAL_CALL OEvoabConnection::setAutoCommit( sal_Bool /*autoCommit*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setAutoCommit", *this );
+}
+sal_Bool SAL_CALL OEvoabConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+void SAL_CALL OEvoabConnection::commit( ) throw(SQLException, RuntimeException)
+{
+}
+void SAL_CALL OEvoabConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+}
+void SAL_CALL OEvoabConnection::setReadOnly( sal_Bool /*readOnly*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setReadOnly", *this );
+}
+sal_Bool SAL_CALL OEvoabConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+void SAL_CALL OEvoabConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
+}
+
+::rtl::OUString SAL_CALL OEvoabConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+void SAL_CALL OEvoabConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this );
+}
+
+sal_Int32 SAL_CALL OEvoabConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OEvoabConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::getTypeMap", *this );
+ return NULL;
+}
+void SAL_CALL OEvoabConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
diff --git a/connectivity/source/drivers/evoab2/NConnection.hxx b/connectivity/source/drivers/evoab2/NConnection.hxx
new file mode 100644
index 000000000000..50155ca6b613
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NConnection.hxx
@@ -0,0 +1,123 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_CONNECTION_HXX_
+#define _CONNECTIVITY_EVOAB_CONNECTION_HXX_
+
+#include "NDriver.hxx"
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include "OSubComponent.hxx"
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/warningscontainer.hxx"
+#include "TConnection.hxx"
+#include <cppuhelper/weakref.hxx>
+#include <osl/module.h>
+#include "EApi.h"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+
+ namespace SDBCAddress {
+ typedef enum {
+ Unknown = 0,
+ EVO_LOCAL = 1,
+ EVO_LDAP = 2,
+ EVO_GWISE = 3
+ } sdbc_address_type;
+ }
+
+ typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
+
+ class OEvoabConnection :public OConnection_BASE
+ ,public connectivity::OSubComponent<OEvoabConnection, OConnection_BASE>
+ {
+ friend class connectivity::OSubComponent<OEvoabConnection, OConnection_BASE>;
+
+ private:
+ const OEvoabDriver& m_rDriver;
+ SDBCAddress::sdbc_address_type m_eSDBCAddressType;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier >
+ m_xCatalog;
+ ::rtl::OString m_aPassword;
+ ::dbtools::WarningsContainer m_aWarnings;
+
+ virtual ~OEvoabConnection();
+
+ public:
+ OEvoabConnection( OEvoabDriver& _rDriver );
+ virtual void construct(const ::rtl::OUString& _rUrl,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rInfo ) throw( ::com::sun::star::sdbc::SQLException);
+
+ inline rtl::OString getPassword() { return m_aPassword; }
+ inline void setPassword( rtl::OString aStr ) { m_aPassword = aStr; }
+ // own methods
+ inline const OEvoabDriver& getDriver() const { return m_rDriver; }
+
+ SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;}
+ void setSDBCAddressType(SDBCAddress::sdbc_address_type _eSDBCAddressType) {m_eSDBCAddressType = _eSDBCAddressType;}
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > createCatalog();
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_CONNECTION_HXX_
diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx
new file mode 100644
index 000000000000..47517d1d1e4d
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.cxx
@@ -0,0 +1,1192 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NDatabaseMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+
+#include <vector>
+#include <string.h>
+#include "EApi.h"
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace connectivity::evoab;
+using namespace connectivity;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ static sal_Int32 const s_nCOLUMN_SIZE = 256;
+ static sal_Int32 const s_nDECIMAL_DIGITS = 0;
+ static sal_Int32 const s_nNULLABLE = 1;
+ static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
+
+ static ColumnProperty **pFields=NULL;
+ static guint nFields = 0;
+
+ static const char *pBlackList[] =
+ {
+ "id",
+ "list-show-addresses",
+ "address-label-home",
+ "address-label-work",
+ "address-label-other"
+ };
+
+ const SplitEvoColumns* get_evo_addr()
+ {
+ static const SplitEvoColumns evo_addr[] = {
+ {"addr-line1",DEFAULT_ADDR_LINE1},{"addr-line2",DEFAULT_ADDR_LINE2},{"city",DEFAULT_CITY},{"state",DEFAULT_STATE},{"country",DEFAULT_COUNTRY},{"zip",DEFAULT_ZIP},
+ {"work-addr-line1",WORK_ADDR_LINE1},{"work-addr-line2",WORK_ADDR_LINE2},{"work-city",WORK_CITY},{"work-state",WORK_STATE},{"work-country",WORK_COUNTRY},{"work-zip",WORK_ZIP},
+ {"home-addr-line1",HOME_ADDR_LINE1},{"home-addr-line2",HOME_ADDR_LINE2},{"home-addr-City",HOME_CITY},{"home-state",HOME_STATE},{"home-country",HOME_COUNTRY},{"home-zip",HOME_ZIP},
+ {"other-addr-line1",OTHER_ADDR_LINE1},{"other-addr-line2",OTHER_ADDR_LINE2},{"other-addr-city",OTHER_CITY},{"other-addr-state",OTHER_STATE},{"other-addr-country",OTHER_COUNTRY},{"other-addr-zip",OTHER_ZIP}
+ };
+ return evo_addr;
+ }
+
+ static void
+ splitColumn (ColumnProperty **pToBeFields)
+ {
+ const SplitEvoColumns* evo_addr( get_evo_addr() );
+ for (int i = 0; i < OTHER_ZIP; i++)
+ {
+ pToBeFields[nFields] = g_new0(ColumnProperty,1);
+ pToBeFields[nFields]->bIsSplittedValue = true;
+ pToBeFields[nFields]->pField = g_param_spec_ref(g_param_spec_string (evo_addr[i].pColumnName,evo_addr[i].pColumnName,"",NULL,G_PARAM_WRITABLE));
+ nFields++;
+ }
+ }
+
+ static void
+ initFields()
+ {
+ if( !pFields )
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if( !pFields )
+ {
+ guint nProps;
+ ColumnProperty **pToBeFields;
+ GParamSpec **pProps;
+ nFields = 0;
+ pProps = g_object_class_list_properties
+ ( (GObjectClass *) g_type_class_ref( E_TYPE_CONTACT ),
+ &nProps );
+ pToBeFields = g_new0(ColumnProperty *, (nProps + OTHER_ZIP)/* new column(s)*/ );
+ for ( guint i = 0; i < nProps; i++ )
+ {
+ switch (pProps[i]->value_type)
+ {
+ case G_TYPE_STRING:
+ case G_TYPE_BOOLEAN:
+ {
+ bool bAdd = true;
+ const char *pName = g_param_spec_get_name( pProps[i] );
+ for (unsigned int j = 0; j < G_N_ELEMENTS( pBlackList ); j++ )
+ {
+ if( !strcmp( pBlackList[j], pName ) )
+ {
+ bAdd = false;
+ break;
+ }
+ }
+ if( bAdd )
+ {
+ pToBeFields[nFields]= g_new0(ColumnProperty,1);
+ pToBeFields[nFields]->bIsSplittedValue=false;
+ pToBeFields[ nFields++ ]->pField = g_param_spec_ref( pProps[i] );
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ splitColumn(pToBeFields);
+ pFields = pToBeFields;
+ }
+ }
+ }
+
+
+ guint
+ getFieldCount()
+ {
+ initFields();
+ return nFields;
+ }
+
+ const ColumnProperty *
+ getField(guint n)
+ {
+ initFields();
+ if( n < nFields )
+ return pFields[n];
+ else
+ return NULL;
+ }
+
+ GType
+ getGFieldType( guint nCol )
+ {
+ initFields();
+
+ sal_Int32 nType = G_TYPE_STRING;
+ if ( nCol < nFields )
+ return ((GParamSpec *)pFields[nCol]->pField)->value_type;
+ return nType;
+ }
+
+ sal_Int32
+ getFieldType( guint nCol )
+ {
+ sal_Int32 nType = getGFieldType( nCol );
+ return nType == G_TYPE_STRING ? DataType::VARCHAR : DataType::BIT;
+ }
+
+ guint findEvoabField(const rtl::OUString& aColName)
+ {
+ guint nRet = (guint)-1;
+ sal_Bool bFound = sal_False;
+ initFields();
+ for (guint i=0;(i < nFields) && !bFound;i++)
+ {
+ rtl::OUString aName = getFieldName(i);
+ if (aName == aColName)
+ {
+ nRet = i;
+ bFound = sal_True;
+ }
+ }
+ return nRet;
+ }
+
+ rtl::OUString
+ getFieldTypeName( guint nCol )
+ {
+ switch( getFieldType( nCol ) )
+ {
+ case DataType::BIT:
+ return ::rtl::OUString::createFromAscii( "BIT" );
+ case DataType::VARCHAR:
+ return ::rtl::OUString::createFromAscii( "VARCHAR" );
+ default:
+ break;
+ }
+ return ::rtl::OUString();
+ }
+
+ rtl::OUString
+ getFieldName( guint nCol )
+ {
+ const GParamSpec *pSpec = getField( nCol )->pField;
+ rtl::OUString aName;
+ initFields();
+
+ if( pSpec )
+ aName = rtl::OStringToOUString( g_param_spec_get_name( ( GParamSpec * )pSpec ),
+ RTL_TEXTENCODING_UTF8 );
+ aName = aName.replace( '-', '_' );
+ return aName;
+ }
+
+ void
+ free_column_resources()
+ {
+ for (int i=nFields-1;i > 0;i--)
+ {
+ if (pFields && pFields[i] )
+ {
+ if (pFields[i]->pField)
+ g_param_spec_unref(pFields[i]->pField);
+ g_free(pFields[i]);
+ }
+ }
+ if(pFields)
+ {
+ g_free(pFields);
+ pFields=NULL;
+ }
+
+ }
+
+
+ }
+}
+
+
+OEvoabDatabaseMetaData::OEvoabDatabaseMetaData(OEvoabConnection* _pCon)
+ : ::connectivity::ODatabaseMetaDataBase(_pCon, _pCon->getConnectionInfo())
+ ,m_pConnection(_pCon)
+{
+ OSL_ENSURE(m_pConnection,"OEvoabDatabaseMetaData::OEvoabDatabaseMetaData: No connection set!");
+}
+OEvoabDatabaseMetaData::~OEvoabDatabaseMetaData()
+{
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ORows& OEvoabDatabaseMetaData::getColumnRows( const ::rtl::OUString& columnNamePattern )
+{
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRows.clear();
+
+ // ****************************************************
+ // Some entries in a row never change, so set them now
+ // ****************************************************
+
+ // Catalog
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii(""));
+ // Schema
+ aRow[2] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii(""));
+ // COLUMN_SIZE
+ aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
+ // BUFFER_LENGTH, not used
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // DECIMAL_DIGITS.
+ aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
+ // NUM_PREC_RADIX
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ // NULLABLE
+ aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
+ // REMARKS
+ aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // COULUMN_DEF, not used
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATA_TYPE, not used
+ aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATETIME_SUB, not used
+ aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // CHAR_OCTET_LENGTH, refer to [5]
+ aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
+ // IS_NULLABLE
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii( "YES" ));
+
+
+ aRow[3] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii( "TABLE" ));
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ initFields();
+ for (sal_Int32 i = 0; i < (sal_Int32) nFields; i++)
+ {
+ if( match( columnNamePattern, getFieldName( i ), '\0' ) )
+ {
+ aRow[5] = new ORowSetValueDecorator( static_cast<sal_Int16>( getFieldType( i ) ) );
+ aRow[6] = new ORowSetValueDecorator( getFieldTypeName( i ) );
+
+ OSL_TRACE( "ColumnName = '%s'", g_param_spec_get_name( pFields[i]->pField ) );
+ // COLUMN_NAME
+ aRow[4] = new ORowSetValueDecorator( getFieldName( i ) );
+ // ORDINAL_POSITION
+ aRow[17] = new ORowSetValueDecorator( i );
+ aRows.push_back( aRow );
+ }
+ }
+
+ return aRows ;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OEvoabDatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 OEvoabDatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 OEvoabDatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ // We only support a single table
+ return 1;
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OEvoabDatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ // normally this is "
+ ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\"");
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ sal_Bool bValue = sal_False;
+ return bValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ // We allow you to select from any table.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ // For now definately read-only, no support for update/delete
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ // todo add Support for this.
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool OEvoabDatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ // Any case may be used
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_pConnection->getURL();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)1);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)0);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+// here follow all methods which return a resultset
+// the first methods is an example implementation how to use this resultset
+// of course you could implement it on your and you should do this because
+// the general way is more memory expensive
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ /* Dont need to change as evoab driver supports only table */
+
+ // there exists no possibility to get table types so we have to check
+ static ::rtl::OUString sTableTypes[] =
+ {
+ ::rtl::OUString::createFromAscii("TABLE"),
+ // Currently we only support a 'TABLE' nothing more complex
+ };
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ // here we fill the rows which should be visible when ask for data from the resultset returned here
+ sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
+ ODatabaseMetaDataResultSet::ORows aRows;
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
+
+ // bound row
+ aRows.push_back(aRow);
+ }
+ // here we set the rows at the resultset
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OEvoabDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ /*
+ * Return the proper type information required by evo driver
+ */
+
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
+
+ Reference< XResultSet > xResultSet = pResultSet;
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.reserve(19);
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::FULL));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)65535);
+ aRows.push_back(aRow);
+ }
+ pResultSet->setRows(aRows);
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns );
+ Reference< XResultSet > xResultSet = pResultSet;
+ pResultSet->setRows( getColumnRows( columnNamePattern ) );
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& /*tableNamePattern*/, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ // check if any type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ sal_Bool bTableFound = sal_True;
+ sal_Int32 nLength = types.getLength();
+ if(nLength)
+ {
+ bTableFound = sal_False;
+
+ const ::rtl::OUString* pBegin = types.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + nLength;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(*pBegin == aTable)
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ }
+ }
+ if(!bTableFound)
+ return xRef;
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+ ESourceList *pSourceList;
+ if( !e_book_get_addressbooks (&pSourceList, NULL) )
+ pSourceList = NULL;
+
+ GSList *g;
+ for( g = e_source_list_peek_groups( pSourceList ); g; g = g->next)
+ {
+ GSList *s;
+ const char *p = e_source_group_peek_base_uri(E_SOURCE_GROUP(g->data));
+
+ switch (m_pConnection->getSDBCAddressType()) {
+ case SDBCAddress::EVO_GWISE:
+ if (0==strncmp( "groupwise://", p, 11 ))
+ break;
+ else
+ continue;
+ case SDBCAddress::EVO_LOCAL:
+ if (0==strncmp( "file://", p, 6 ))
+ break;
+ else
+ continue;
+ case SDBCAddress::EVO_LDAP:
+ if (0==strncmp( "ldap://", p, 6 ))
+ break;
+ else
+ continue;
+ case SDBCAddress::Unknown:
+ break;
+ }
+ for (s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next)
+ {
+ ESource *pSource = E_SOURCE (s->data);
+
+ rtl::OUString aName = rtl::OStringToOUString( e_source_peek_name( pSource ),
+ RTL_TEXTENCODING_UTF8 );
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRows.push_back(aRow);
+ }
+ }
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabDatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XDatabaseMetaDaza::getUDTs", *this );
+ return NULL;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx
new file mode 100644
index 000000000000..0ac01575d440
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDatabaseMetaData.hxx
@@ -0,0 +1,236 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_DATABASEMETADATA_HXX_
+#define _CONNECTIVITY_EVOAB_DATABASEMETADATA_HXX_
+
+#ifndef _CONNECTIVITY_EVOAB_DEBUG_HXX_
+#include "NDebug.hxx"
+#endif
+#include "NConnection.hxx"
+#include "TDatabaseMetaDataBase.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class EvoContacts;
+
+
+ //**************************************************************
+ //************ Class: OEvoabDatabaseMetaData
+ //**************************************************************
+ typedef struct{
+ gboolean bIsSplittedValue;
+ GParamSpec *pField;
+ }ColumnProperty;
+
+ typedef enum {
+ DEFAULT_ADDR_LINE1=1,DEFAULT_ADDR_LINE2,DEFAULT_CITY,DEFAULT_STATE,DEFAULT_COUNTRY,DEFAULT_ZIP,
+ WORK_ADDR_LINE1,WORK_ADDR_LINE2,WORK_CITY,WORK_STATE,WORK_COUNTRY,WORK_ZIP,
+ HOME_ADDR_LINE1,HOME_ADDR_LINE2,HOME_CITY,HOME_STATE,HOME_COUNTRY,HOME_ZIP,
+ OTHER_ADDR_LINE1,OTHER_ADDR_LINE2,OTHER_CITY,OTHER_STATE,OTHER_COUNTRY,OTHER_ZIP
+ }ColumnNumber;
+
+ typedef struct {
+ const gchar *pColumnName;
+ ColumnNumber value;
+ }SplitEvoColumns;
+
+ const SplitEvoColumns* get_evo_addr();
+
+ const ColumnProperty *getField(guint n);
+ guint getFieldCount() ;
+ GType getGFieldType(guint nCol) ;
+ sal_Int32 getFieldType(guint nCol) ;
+ rtl::OUString getFieldTypeName(guint nCol) ;
+ rtl::OUString getFieldName(guint nCol) ;
+ guint findEvoabField(const rtl::OUString& aColName);
+
+ void free_column_resources();
+
+ class OEvoabDatabaseMetaData : public ODatabaseMetaDataBase
+ {
+ OEvoabConnection* m_pConnection;
+
+ ODatabaseMetaDataResultSet::ORows& getColumnRows( const ::rtl::OUString& columnNamePattern );
+
+ protected:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ // cached database information
+ virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( );
+ virtual sal_Bool impl_isCatalogAtStart_throw( );
+ virtual ::rtl::OUString impl_getCatalogSeparator_throw( );
+ virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( );
+ virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) ;
+ virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( );
+ virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) ;
+ virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) ;
+ virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( );
+ virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( );
+ virtual sal_Int32 impl_getMaxStatements_throw( );
+ virtual sal_Int32 impl_getMaxTablesInSelect_throw( );
+ virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( );
+
+ virtual ~OEvoabDatabaseMetaData();
+ public:
+ inline OEvoabConnection* getOwnConnection() const { return m_pConnection; }
+
+ OEvoabDatabaseMetaData(OEvoabConnection* _pCon);
+
+ // as I mentioned before this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_EVOAB_DATABASEMETADATA_HXX_
diff --git a/connectivity/source/drivers/evoab2/NDebug.cxx b/connectivity/source/drivers/evoab2/NDebug.cxx
new file mode 100644
index 000000000000..58db555c6f67
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDebug.cxx
@@ -0,0 +1,40 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NDebug.hxx"
+#include <osl/diagnose.h>
+#ifdef DEBUG
+void evo_traceStringMessage( const sal_Char *pFormat,
+ const ::rtl::OUString& rString )
+{
+ rtl::OString aStr;
+ aStr = ::rtl::OUStringToOString (rString, RTL_TEXTENCODING_UTF8);
+ OSL_TRACE(pFormat, (const sal_Char *) aStr );
+}
+#endif
diff --git a/connectivity/source/drivers/evoab2/NDebug.hxx b/connectivity/source/drivers/evoab2/NDebug.hxx
new file mode 100644
index 000000000000..949ea34f154b
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDebug.hxx
@@ -0,0 +1,42 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+#define CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
+
+#include <stdio.h>
+#include <rtl/ustring.hxx>
+#include <com/sun/star/beans/PropertyValue.hpp>
+
+#ifdef DEBUG
+ void evo_traceStringMessage( const sal_Char* pFormat, const ::rtl::OUString& rString );
+# define EVO_TRACE_STRING( pFormat, rString ) evo_traceStringMessage( pFormat, rString )
+#else
+# define EVO_TRACE_STRING( pFormat, rString ) ((void)0)
+#endif
+
+#endif // CONNECTIVITY_EVOAB_DEBUG_HELPER_HXX
diff --git a/connectivity/source/drivers/evoab2/NDriver.cxx b/connectivity/source/drivers/evoab2/NDriver.cxx
new file mode 100644
index 000000000000..37937f5bb57e
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDriver.cxx
@@ -0,0 +1,190 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NDriver.hxx"
+#include "NConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+//#ifndef _CONNECTIVITY_EVOAB_CONFIGACCESS_HXX_
+//#include "LConfigAccess.hxx"
+//#endif
+#include <osl/file.hxx>
+#include "osl/security.hxx"
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/ucb/XCommandEnvironment.hpp>
+#include <ucbhelper/content.hxx>
+#include <tools/debug.hxx>
+#include "NDebug.hxx"
+#include <signal.h>
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace osl;
+using namespace connectivity::evoab;
+//using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::ucb;
+
+// --------------------------------------------------------------------------------
+OEvoabDriver::OEvoabDriver(const Reference< XMultiServiceFactory >& _rxFactory) :
+ ODriver_BASE( m_aMutex ), m_xFactory( _rxFactory )
+{
+}
+// -----------------------------------------------------------------------------
+OEvoabDriver::~OEvoabDriver()
+{
+}
+// -----------------------------------------------------------------------------
+void OEvoabDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroied so all our connections have to be destroied as well
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is()) {
+ try {
+ xComp->dispose();
+ }
+ catch (com::sun::star::lang::DisposedException e) {
+ xComp.clear();
+ }
+ }
+ }
+ m_xConnections.clear();
+ connectivity::OWeakRefArray().swap(m_xConnections); // this really clears
+
+ ODriver_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OEvoabDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii(EVOAB_DRIVER_IMPL_NAME);
+ // this name is referenced in the configuration and in the evoab.xml
+ // Please take care when changing it.
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > OEvoabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ return aSNS;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+//------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OEvoabDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::evoab::OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new OEvoabDriver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OEvoabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OEvoabConnection* pCon = new OEvoabConnection( *this );
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return acceptsURL_Stat(url);
+}
+
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL OEvoabDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+
+ // if you have somthing special to say return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// --------------------------------------------------------------------------------
+sal_Bool OEvoabDriver::acceptsURL_Stat( const ::rtl::OUString& url )
+{
+ return (url.equalsAscii("sdbc:address:evolution:local") || url.equalsAscii("sdbc:address:evolution:groupwise")||url.equalsAscii("sdbc:address:evolution:ldap"))&& EApiInit();
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab2/NDriver.hxx b/connectivity/source/drivers/evoab2/NDriver.hxx
new file mode 100644
index 000000000000..330a94f0fd5a
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NDriver.hxx
@@ -0,0 +1,98 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_DRIVER_HXX_
+#define _CONNECTIVITY_EVOAB_DRIVER_HXX_
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <osl/module.h>
+
+#define EVOAB_EVOLUTION_SCHEMA "evolution"
+/*In Future, when seperate schema is required for ldap, groupwise*/
+#define EVOAB_LDAP_SCHEMA "ldap"
+#define EVOAB_GWISE_SCHEMA "groupwise"
+
+#define EVOAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.evoab.OEvoabDriver"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL OEvoabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo > ODriver_BASE;
+
+
+ class OEvoabDriver : public ODriver_BASE
+ {
+
+ protected:
+ ::osl::Mutex m_aMutex;
+ connectivity::OWeakRefArray m_xConnections;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xFactory;
+
+ public:
+ OEvoabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+ virtual ~OEvoabDriver();
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ & getMSFactory(void) const { return m_xFactory; }
+
+ // static methods
+ static sal_Bool acceptsURL_Stat( const ::rtl::OUString& url );
+ };
+ }
+
+}
+#endif //_CONNECTIVITY_EVOAB_DRIVER_HXX_
diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.cxx b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx
new file mode 100644
index 000000000000..8259de5d477b
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NPreparedStatement.cxx
@@ -0,0 +1,335 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include "NPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "propertyids.hxx"
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "resource/common_res.hrc"
+
+using namespace connectivity::evoab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OEvoabPreparedStatement,"com.sun.star.sdbcx.evoab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+
+OEvoabPreparedStatement::OEvoabPreparedStatement( OEvoabConnection* _pConnection )
+ :OCommonStatement(_pConnection)
+ ,m_sSqlStatement()
+ ,m_xMetaData()
+{
+}
+
+// -----------------------------------------------------------------------------
+void OEvoabPreparedStatement::construct( const ::rtl::OUString& _sql )
+{
+ m_sSqlStatement = _sql;
+
+ m_aQueryData = impl_getEBookQuery_throw( m_sSqlStatement );
+ ENSURE_OR_THROW( m_aQueryData.getQuery(), "no EBookQuery" );
+ ENSURE_OR_THROW( m_aQueryData.xSelectColumns.isValid(), "no SelectColumn" );
+
+ // create our meta data
+ OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( m_aQueryData.sTable );
+ m_xMetaData = pMeta;
+ pMeta->setEvoabFields( m_aQueryData.xSelectColumns );
+}
+
+// -----------------------------------------------------------------------------
+OEvoabPreparedStatement::~OEvoabPreparedStatement()
+{
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabPreparedStatement::acquire() throw()
+{
+ OCommonStatement::acquire();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabPreparedStatement::release() throw()
+{
+ OCommonStatement::release();
+}
+
+// -----------------------------------------------------------------------------
+Any SAL_CALL OEvoabPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPreparedStatement_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OEvoabPreparedStatement::getTypes( ) throw(RuntimeException)
+{
+ return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OEvoabPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ // the meta data should have been created at construction time
+ ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" );
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::close( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ free_column_resources();
+ // Reset last warning message
+ try {
+ clearWarnings ();
+ OCommonStatement::close();
+ }
+ catch (SQLException &) {
+ // If we get an error, ignore
+ }
+
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ Reference< XResultSet> xRS = impl_executeQuery_throw( m_aQueryData );
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OEvoabPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setString( sal_Int32 /*parameterIndex*/, const ::rtl::OUString& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setString", *this );
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OEvoabPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ return impl_getConnection();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ return impl_executeQuery_throw( m_aQueryData );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setBoolean", *this );
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setByte", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setDate", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const Time& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setTime", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setTimestamp", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setDouble", *this );
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setFloat", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setInt", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setLong", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setNull", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setObjectWithInfo", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setObjectNull( sal_Int32 /*parameterIndex*/, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setObjectNull", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setShort", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setBytes", *this );
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OEvoabPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setCharacterStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setBinaryStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OEvoabPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OEvoabPreparedStatement::getResultSet( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabPreparedStatement::getUpdateCount( ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabPreparedStatement::getMoreResults( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab2/NPreparedStatement.hxx b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx
new file mode 100644
index 000000000000..625f5a1071ff
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NPreparedStatement.hxx
@@ -0,0 +1,138 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_PREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_EVOAB_PREPAREDSTATEMENT_HXX_
+
+#include "NStatement.hxx"
+#include "NConnection.hxx"
+#include "NDatabaseMetaData.hxx"
+#include "NResultSet.hxx"
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XPreparedBatchExecution.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::sdbc::XMultipleResults,
+ ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
+
+ class OEvoabPreparedStatement :public OCommonStatement
+ ,public OPreparedStatement_BASE
+ {
+ protected:
+ struct Parameter
+ {
+ ::com::sun::star::uno::Any aValue;
+ sal_Int32 nDataType;
+
+ Parameter(const ::com::sun::star::uno::Any& rValue,
+ sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType)
+ {
+ }
+
+ };
+
+ ::std::vector< Parameter> m_aParameters;
+ //====================================================================
+ // Data attributes
+ //====================================================================
+
+ // our SQL statement
+ ::rtl::OUString m_sSqlStatement;
+ // the EBookQuery we're working with
+ QueryData m_aQueryData;
+ // our meta data
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+
+ protected:
+ virtual ~OEvoabPreparedStatement();
+
+ public:
+ OEvoabPreparedStatement( OEvoabConnection* _pConnection );
+
+ void construct( const ::rtl::OUString& _sql );
+
+ protected:
+ DECLARE_SERVICE_INFO();
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
diff --git a/connectivity/source/drivers/evoab2/NResultSet.cxx b/connectivity/source/drivers/evoab2/NResultSet.cxx
new file mode 100644
index 000000000000..f591d48a9570
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NResultSet.cxx
@@ -0,0 +1,1020 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "NDatabaseMetaData.hxx"
+#include "NConnection.hxx"
+#include "NResultSet.hxx"
+#include "propertyids.hxx"
+#include "resource/evoab2_res.hrc"
+#include "TSortIndex.hxx"
+#include <algorithm>
+
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/sqlerror.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <rtl/string.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/syslocale.hxx>
+#include <unotools/intlwrapper.hxx>
+
+#include <cstring>
+#include <vector>
+
+namespace connectivity { namespace evoab {
+
+using namespace ::comphelper;
+using namespace com::sun::star;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+namespace ErrorCondition = ::com::sun::star::sdb::ErrorCondition;
+
+//------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSet::getImplementationName( ) throw ( RuntimeException) \
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.evoab.ResultSet");
+}
+// -------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OEvoabResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// -------------------------------------------------------------------------
+OEvoabResultSet::OEvoabResultSet( OCommonStatement* pStmt, OEvoabConnection *pConnection )
+ :OResultSet_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer( OResultSet_BASE::rBHelper )
+ ,m_pStatement(pStmt)
+ ,m_pConnection(pConnection)
+ ,m_xMetaData(NULL)
+ ,m_bWasNull(sal_True)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
+ ,m_pContacts(NULL)
+ ,m_nIndex(-1)
+ ,m_nLength(0)
+{
+ #define REGISTER_PROP( id, member ) \
+ registerProperty( \
+ OMetaConnection::getPropMap().getNameByIndex( id ), \
+ id, \
+ PropertyAttribute::READONLY, \
+ &member, \
+ ::getCppuType( &member ) \
+ );
+
+ REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize );
+ REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType );
+ REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection );
+ REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency );
+}
+
+// -------------------------------------------------------------------------
+OEvoabResultSet::~OEvoabResultSet()
+{
+}
+
+// -------------------------------------------------------------------------
+
+static ESource *
+findSource( const char *name )
+{
+ ESourceList *pSourceList = NULL;
+
+ g_return_val_if_fail (name != NULL, NULL);
+
+ if (!e_book_get_addressbooks (&pSourceList, NULL))
+ pSourceList = NULL;
+
+ for ( GSList *g = e_source_list_peek_groups (pSourceList); g; g = g->next)
+ {
+ for (GSList *s = e_source_group_peek_sources (E_SOURCE_GROUP (g->data)); s; s = s->next)
+ {
+ ESource *pSource = E_SOURCE (s->data);
+ if (!strcmp (e_source_peek_name (pSource), name))
+ return pSource;
+ }
+ }
+ return NULL;
+}
+
+static EBook *
+openBook( const char *abname )
+{
+ ESource *pSource = findSource (abname);
+ EBook *pBook = NULL;
+ if (pSource)
+ pBook = e_book_new (pSource, NULL);
+
+ if (pBook && !e_book_open (pBook, TRUE, NULL))
+ {
+ g_object_unref (G_OBJECT (pBook));
+ pBook = NULL;
+ }
+
+ return pBook;
+}
+
+static bool isLDAP( EBook *pBook )
+{
+ return pBook && !strncmp( "ldap://", e_book_get_uri( pBook ), 6 );
+}
+
+static bool isLocal( EBook *pBook )
+{
+ return pBook && !strncmp( "file://", e_book_get_uri( pBook ), 6 );
+}
+
+static bool isAuthRequired( EBook *pBook )
+{
+ return e_source_get_property( e_book_get_source( pBook ),
+ "auth" ) != NULL;
+}
+
+static rtl::OString getUserName( EBook *pBook )
+{
+ rtl::OString aName;
+ if( isLDAP( pBook ) )
+ aName = e_source_get_property( e_book_get_source( pBook ), "binddn" );
+ else
+ aName = e_source_get_property( e_book_get_source( pBook ), "user" );
+ return aName;
+}
+
+static ::rtl::OUString
+valueToOUString( GValue& _rValue )
+{
+ const char *pStr = g_value_get_string( &_rValue );
+ rtl::OString aStr( pStr ? pStr : "" );
+ ::rtl::OUString sResult( ::rtl::OStringToOUString( aStr, RTL_TEXTENCODING_UTF8 ) );
+ g_value_unset( &_rValue );
+ return sResult;
+}
+
+static bool
+valueToBool( GValue& _rValue )
+{
+ bool bResult = g_value_get_boolean( &_rValue );
+ g_value_unset( &_rValue );
+ return bResult;
+}
+
+static bool
+executeQuery (EBook* pBook, EBookQuery* pQuery, GList **ppList,
+ rtl::OString &rPassword, GError **pError)
+{
+ ESource *pSource = e_book_get_source( pBook );
+ bool bSuccess = false;
+ bool bAuthSuccess = true;
+
+ *ppList = NULL;
+
+ if( isAuthRequired( pBook ) )
+ {
+ rtl::OString aUser( getUserName( pBook ) );
+ const char *pAuth = e_source_get_property( pSource, "auth" );
+ bAuthSuccess = e_book_authenticate_user( pBook, aUser, rPassword, pAuth, pError );
+ }
+
+ if (bAuthSuccess)
+ bSuccess = e_book_get_contacts( pBook, pQuery, ppList, pError );
+
+ return bSuccess;
+}
+
+static int
+whichAddress(int value)
+{
+ int fieldEnum;
+ switch (value)
+ {
+ case HOME_ADDR_LINE1:
+ case HOME_ADDR_LINE2:
+ case HOME_CITY:
+ case HOME_STATE:
+ case HOME_COUNTRY:
+ case HOME_ZIP:
+ fieldEnum = e_contact_field_id("address_home");
+ break;
+
+ case WORK_ADDR_LINE1:
+ case WORK_ADDR_LINE2:
+ case WORK_CITY:
+ case WORK_STATE:
+ case WORK_COUNTRY:
+ case WORK_ZIP:
+ fieldEnum = e_contact_field_id("address_work");
+ break;
+
+ case OTHER_ADDR_LINE1:
+ case OTHER_ADDR_LINE2:
+ case OTHER_CITY:
+ case OTHER_STATE:
+ case OTHER_COUNTRY:
+ case OTHER_ZIP:
+ fieldEnum = e_contact_field_id("address_other");
+ break;
+
+ default: fieldEnum = e_contact_field_id("address_home");
+ }
+ return fieldEnum;
+}
+
+/*
+* This function decides the default column values based on the first field of EContactAddress.
+* The search order is Work->Home->other(defaults).
+*/
+static EContactAddress *
+getDefaultContactAddress( EContact *pContact,int *value )
+{
+ EContactAddress *ec = (EContactAddress *)e_contact_get(pContact,whichAddress(WORK_ADDR_LINE1));
+ if ( ec && (strlen(ec->street)>0) )
+ {
+ *value= *value +WORK_ADDR_LINE1 -1;
+ return ec;
+ }
+ else
+ {
+ ec = (EContactAddress *)e_contact_get(pContact,whichAddress(HOME_ADDR_LINE1));
+ if ( ec && (strlen(ec->street)>0) )
+ {
+ *value=*value+HOME_ADDR_LINE1-1;
+ return ec;
+ }
+ }
+
+ *value=*value+OTHER_ADDR_LINE1-1;
+ return (EContactAddress *)e_contact_get(pContact,whichAddress(OTHER_ADDR_LINE1));
+}
+
+static EContactAddress*
+getContactAddress( EContact *pContact, int * address_enum )
+{
+ EContactAddress *ec = NULL;
+ switch (*address_enum) {
+
+ case DEFAULT_ADDR_LINE1:
+ case DEFAULT_ADDR_LINE2:
+ case DEFAULT_CITY:
+ case DEFAULT_STATE:
+ case DEFAULT_COUNTRY:
+ case DEFAULT_ZIP:
+ ec = getDefaultContactAddress(pContact,address_enum);break;
+ default:
+ ec = (EContactAddress *)e_contact_get(pContact,whichAddress(*address_enum));
+ }
+ return ec;
+}
+
+static bool
+handleSplitAddress( EContact *pContact,GValue *pStackValue, int value )
+{
+ EContactAddress *ec = getContactAddress(pContact,&value) ;
+
+ if (ec==NULL)
+ return true;
+
+ switch (value) {
+ case WORK_ADDR_LINE1:
+ g_value_set_string(pStackValue,ec->street ); break;
+ case WORK_ADDR_LINE2:
+ g_value_set_string(pStackValue,ec->po ); break;
+ case WORK_CITY:
+ g_value_set_string(pStackValue,ec->locality ); break;
+ case WORK_STATE:
+ g_value_set_string(pStackValue,ec->region ); break;
+ case WORK_COUNTRY:
+ g_value_set_string(pStackValue,ec->country ); break;
+ case WORK_ZIP:
+ g_value_set_string(pStackValue,ec->code ); break;
+
+ case HOME_ADDR_LINE1:
+ g_value_set_string(pStackValue,ec->street ); break;
+ case HOME_ADDR_LINE2:
+ g_value_set_string(pStackValue,ec->po ); break;
+ case HOME_CITY:
+ g_value_set_string(pStackValue,ec->locality ); break;
+ case HOME_STATE:
+ g_value_set_string(pStackValue,ec->region ); break;
+ case HOME_COUNTRY:
+ g_value_set_string(pStackValue,ec->country ); break;
+ case HOME_ZIP:
+ g_value_set_string(pStackValue,ec->code ); break;
+
+ case OTHER_ADDR_LINE1:
+ g_value_set_string(pStackValue,ec->street ); break;
+ case OTHER_ADDR_LINE2:
+ g_value_set_string(pStackValue,ec->po ); break;
+ case OTHER_CITY:
+ g_value_set_string(pStackValue,ec->locality ); break;
+ case OTHER_STATE:
+ g_value_set_string(pStackValue,ec->region ); break;
+ case OTHER_COUNTRY:
+ g_value_set_string(pStackValue,ec->country ); break;
+ case OTHER_ZIP:
+ g_value_set_string(pStackValue,ec->code ); break;
+
+ }
+
+ return false;
+}
+static bool
+getValue( EContact* pContact, sal_Int32 nColumnNum, GType nType, GValue* pStackValue, bool& _out_rWasNull )
+{
+ const ColumnProperty * pSpecs = evoab::getField( nColumnNum );
+ if ( !pSpecs )
+ return false;
+
+ GParamSpec* pSpec = pSpecs->pField;
+ gboolean bIsSplittedColumn = pSpecs->bIsSplittedValue;
+
+ _out_rWasNull = true;
+ if ( !pSpec || !pContact)
+ return false;
+
+ if ( G_PARAM_SPEC_VALUE_TYPE (pSpec) != nType )
+ {
+
+ OSL_TRACE( "Wrong type (0x%x) (0x%x) '%s'",
+ (int)G_PARAM_SPEC_VALUE_TYPE (pSpec), (int) nType,
+ pSpec->name ? pSpec->name : "<noname>");
+ return false;
+ }
+
+ g_value_init( pStackValue, nType );
+ if ( bIsSplittedColumn )
+ {
+ const SplitEvoColumns* evo_addr( get_evo_addr() );
+ for (int i=0;i<OTHER_ZIP;i++)
+ {
+ if (0 == strcmp (g_param_spec_get_name ((GParamSpec *)pSpec), evo_addr[i].pColumnName))
+ {
+ _out_rWasNull = handleSplitAddress( pContact, pStackValue, evo_addr[i].value );
+ return true;
+ }
+ }
+ }
+ else
+ {
+ g_object_get_property( G_OBJECT (pContact),
+ g_param_spec_get_name ((GParamSpec *) pSpec),
+ pStackValue );
+ if ( G_VALUE_TYPE( pStackValue ) != nType )
+ {
+ OSL_TRACE( "Fetched type mismatch" );
+ g_value_unset( pStackValue );
+ return false;
+ }
+ }
+ _out_rWasNull = false;
+ return true;
+}
+
+namespace
+{
+ struct ComparisonData
+ {
+ const SortDescriptor& rSortOrder;
+ IntlWrapper aIntlWrapper;
+
+ ComparisonData( const SortDescriptor& _rSortOrder, const Reference< XMultiServiceFactory >& _rxFactory )
+ :rSortOrder( _rSortOrder )
+ ,aIntlWrapper( _rxFactory, SvtSysLocale().GetLocaleData().getLocale() )
+ {
+ }
+ };
+}
+
+extern "C"
+int CompareContacts( gconstpointer _lhs, gconstpointer _rhs, gpointer _userData )
+{
+ EContact* lhs = static_cast< EContact* >( const_cast< gpointer >( _lhs ) );
+ EContact* rhs = static_cast< EContact* >( const_cast< gpointer >( _rhs ) );
+
+ GValue aLhsValue = { 0, { { 0 } } };
+ GValue aRhsValue = { 0, { { 0 } } };
+ bool bLhsNull = true;
+ bool bRhsNull = true;
+
+ ::rtl::OUString sLhs, sRhs;
+ bool bLhs(false), bRhs(false);
+
+ const ComparisonData& rCompData = *static_cast< const ComparisonData* >( _userData );
+ for ( SortDescriptor::const_iterator sortCol = rCompData.rSortOrder.begin();
+ sortCol != rCompData.rSortOrder.end();
+ ++sortCol
+ )
+ {
+ sal_Int32 nField = sortCol->nField;
+ GType eFieldType = evoab::getGFieldType( nField );
+
+ bool success = getValue( lhs, nField, eFieldType, &aLhsValue, bLhsNull )
+ && getValue( rhs, nField, eFieldType, &aRhsValue, bRhsNull );
+ OSL_ENSURE( success, "CompareContacts: could not retrieve both values!" );
+ if ( !success )
+ return 0;
+
+ if ( bLhsNull && !bRhsNull )
+ return -1;
+ if ( !bLhsNull && bRhsNull )
+ return 1;
+ if ( bLhsNull && bRhsNull )
+ continue;
+
+ if ( eFieldType == G_TYPE_STRING )
+ {
+ sLhs = valueToOUString( aLhsValue );
+ sRhs = valueToOUString( aRhsValue );
+ sal_Int32 nCompResult = rCompData.aIntlWrapper.getCaseCollator()->compareString( sLhs, sRhs );
+ if ( nCompResult != 0 )
+ return nCompResult;
+ continue;
+ }
+
+ bLhs = valueToBool( aLhsValue );
+ bRhs = valueToBool( aRhsValue );
+ if ( bLhs && !bRhs )
+ return -1;
+ if ( !bLhs && bRhs )
+ return 1;
+ continue;
+ }
+
+ return 0;
+}
+
+static GList*
+sortContacts( GList* _pContactList, const ComparisonData& _rCompData )
+{
+ OSL_ENSURE( !_rCompData.rSortOrder.empty(), "sortContacts: no need to call this without any sort order!" );
+ ENSURE_OR_THROW( _rCompData.aIntlWrapper.getCaseCollator(), "no collator for comparing strings" );
+
+ return g_list_sort_with_data( _pContactList, &CompareContacts, const_cast< gpointer >( static_cast< gconstpointer >( &_rCompData ) ) );
+}
+
+// -------------------------------------------------------------------------
+void OEvoabResultSet::construct( const QueryData& _rData )
+{
+ ENSURE_OR_THROW( _rData.getQuery(), "internal error: no EBookQuery" );
+
+ EBook *pBook = openBook( ::rtl::OUStringToOString( _rData.sTable, RTL_TEXTENCODING_UTF8 ) );
+ if ( !pBook )
+ m_pConnection->throwGenericSQLException( STR_CANNOT_OPEN_BOOK, *this );
+
+ g_list_free(m_pContacts);
+ m_pContacts = NULL;
+ bool bExecuteQuery = true;
+ switch ( _rData.eFilterType )
+ {
+ case eFilterNone:
+ if ( !isLocal( pBook ) )
+ {
+ SQLError aErrorFactory( m_pConnection->getDriver().getMSFactory() );
+ SQLException aAsException = aErrorFactory.getSQLException( ErrorCondition::DATA_CANNOT_SELECT_UNFILTERED, *this );
+ m_aWarnings.appendWarning( SQLWarning(
+ aAsException.Message,
+ aAsException.Context,
+ aAsException.SQLState,
+ aAsException.ErrorCode,
+ aAsException.NextException
+ ) );
+ bExecuteQuery = false;
+ }
+ break;
+ case eFilterAlwaysFalse:
+ bExecuteQuery = false;
+ break;
+ case eFilterOther:
+ bExecuteQuery = true;
+ break;
+ }
+ if ( bExecuteQuery )
+ {
+ rtl::OString aPassword = m_pConnection->getPassword();
+ executeQuery( pBook, _rData.getQuery(), &m_pContacts, aPassword, NULL );
+ m_pConnection->setPassword( aPassword );
+
+ if ( m_pContacts && !_rData.aSortOrder.empty() )
+ {
+ ComparisonData aCompData( _rData.aSortOrder, getConnection()->getDriver().getMSFactory() );
+ m_pContacts = sortContacts( m_pContacts, aCompData );
+ }
+ }
+ m_nLength = g_list_length( m_pContacts );
+ OSL_TRACE( "Query return %d records", m_nLength );
+ m_nIndex = -1;
+
+ // create our meta data (need the EBookQuery for this)
+ OEvoabResultSetMetaData* pMeta = new OEvoabResultSetMetaData( _rData.sTable );
+ m_xMetaData = pMeta;
+
+ pMeta->setEvoabFields( _rData.xSelectColumns );
+}
+
+// -------------------------------------------------------------------------
+void OEvoabResultSet::disposing(void)
+{
+ ::comphelper::OPropertyContainer::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ g_list_free(m_pContacts);
+ m_pContacts = NULL;
+ m_pStatement = NULL;
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OEvoabResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::comphelper::OPropertyContainer::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OEvoabResultSet::getTypes( ) throw( RuntimeException)
+{
+ return ::comphelper::concatSequences(
+ OResultSet_BASE::getTypes(),
+ ::comphelper::OPropertyContainer::getTypes()
+ );
+}
+
+// -------------------------------------------------------------------------
+// XRow Interface
+
+/**
+ * getString:
+ * @nColumnNum: The column index from the table.
+ *
+ * If the equivalent NResultSetMetaData.cxx marks the columntype of
+ * nColumnNum as DataType::VARCHAR this accessor is used.
+ */
+::rtl::OUString SAL_CALL OEvoabResultSet::getString( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ rtl::OUString aResult;
+ if ( m_xMetaData.is())
+ {
+ OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get();
+ sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum);
+ GValue aValue = { 0, { { 0 } } };
+ if ( getValue( getCur(), nFieldNumber, G_TYPE_STRING, &aValue, m_bWasNull ) )
+ aResult = valueToOUString( aValue );
+ }
+ return aResult;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::getBoolean( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ sal_Bool bResult = sal_False;
+
+ if ( m_xMetaData.is())
+ {
+ OEvoabResultSetMetaData *pMeta = (OEvoabResultSetMetaData *) m_xMetaData.get();
+ sal_Int32 nFieldNumber = pMeta->fieldAtColumn(nColumnNum);
+ GValue aValue = { 0, { { 0 } } };
+ if ( getValue( getCur(), nFieldNumber, G_TYPE_BOOLEAN, &aValue, m_bWasNull ) )
+ bResult = valueToBool( aValue );
+ }
+ return bResult ? sal_True : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL OEvoabResultSet::getLong( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getLong", *this );
+ return sal_Int64();
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OEvoabResultSet::getArray( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL OEvoabResultSet::getClob( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OEvoabResultSet::getBlob( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL OEvoabResultSet::getRef( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OEvoabResultSet::getObject( sal_Int32 /*nColumnNum*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this );
+ return Any();
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL OEvoabResultSet::getShort( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getShort", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OEvoabResultSet::getTime( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getTime", *this );
+ return ::com::sun::star::util::Time();
+}
+// -------------------------------------------------------------------------
+util::DateTime SAL_CALL OEvoabResultSet::getTimestamp( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getTimestamp", *this );
+ return ::com::sun::star::util::DateTime();
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OEvoabResultSet::getBinaryStream( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OEvoabResultSet::getCharacterStream( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getCharacterStream", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL OEvoabResultSet::getByte( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getByte", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL OEvoabResultSet::getBytes( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBytes", *this );
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Date SAL_CALL OEvoabResultSet::getDate( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getDate", *this );
+ return ::com::sun::star::util::Date();
+}
+// -------------------------------------------------------------------------
+double SAL_CALL OEvoabResultSet::getDouble( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getDouble", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+float SAL_CALL OEvoabResultSet::getFloat( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getFloat", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSet::getInt( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getInt", *this );
+ return 0;
+}
+// XRow Interface Ends
+// -------------------------------------------------------------------------
+
+// XResultSetMetaDataSupplier Interface
+Reference< XResultSetMetaData > SAL_CALL OEvoabResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // the meta data should have been created at construction time
+ ENSURE_OR_THROW( m_xMetaData.is(), "internal error: no meta data" );
+ return m_xMetaData;
+}
+// XResultSetMetaDataSupplier Interface Ends
+// -------------------------------------------------------------------------
+
+// XResultSet Interface
+sal_Bool SAL_CALL OEvoabResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ if (m_nIndex+1 < m_nLength) {
+ ++m_nIndex ;
+ return true;
+ }
+ else
+ return false;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nIndex < 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nIndex;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nIndex >= m_nLength;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nIndex == 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nIndex == m_nLength - 1;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_nIndex = -1;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_nIndex = m_nLength;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_nIndex = 0;
+ return true;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_nIndex = m_nLength - 1;
+ return true;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ if (row < m_nLength) {
+ m_nIndex = row;
+ return true;
+ }
+ else
+ return false;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if ((m_nIndex+row) < m_nLength) {
+ m_nIndex += row;
+ return true;
+ }
+ else
+ return false;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(m_nIndex > 0) {
+ m_nIndex--;
+ return true;
+ }
+ else
+ return false;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OEvoabResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+::com::sun::star::uno::WeakReferenceHelper aStatement((OWeakObject*)m_pStatement);
+ return aStatement.get();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+//XResult Interface ends
+// -------------------------------------------------------------------------
+// XCancellable
+
+void SAL_CALL OEvoabResultSet::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ OSL_TRACE("In/Out: OEvoabResultSet::cancel" );
+
+}
+
+//XCloseable
+void SAL_CALL OEvoabResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ }
+ OSL_TRACE("In/Out: OEvoabResultSet::close" );
+ dispose();
+}
+
+// XWarningsSupplier
+// -------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OEvoabResultSet::clearWarnings" );
+ m_aWarnings.clearWarnings();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OEvoabResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OEvoabResultSet::getWarnings" );
+ return m_aWarnings.getWarnings();
+}
+// -------------------------------------------------------------------------
+//XColumnLocate Interface
+sal_Int32 SAL_CALL OEvoabResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ // find the first column with the name columnName
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -------------------------------------------------------------------------
+//XColumnLocate interface ends
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OEvoabResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OEvoabResultSet::getInfoHelper()
+{
+ return *const_cast<OEvoabResultSet*>(this)->getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OEvoabResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL
+OEvoabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+} } // connectivity::evoab
diff --git a/connectivity/source/drivers/evoab2/NResultSet.hxx b/connectivity/source/drivers/evoab2/NResultSet.hxx
new file mode 100644
index 000000000000..3632c60cc955
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NResultSet.hxx
@@ -0,0 +1,183 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_RESULTSET_HXX_
+#define _CONNECTIVITY_EVOAB_RESULTSET_HXX_
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/compbase8.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/FValue.hxx"
+#include "connectivity/warningscontainer.hxx"
+#include "NStatement.hxx"
+#include "OSubComponent.hxx"
+#include "NResultSetMetaData.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ typedef ::cppu::WeakComponentImplHelper8 < ::com::sun::star::sdbc::XResultSet
+ , ::com::sun::star::sdbc::XRow
+ , ::com::sun::star::sdbc::XResultSetMetaDataSupplier
+ , ::com::sun::star::util::XCancellable
+ , ::com::sun::star::sdbc::XWarningsSupplier
+ , ::com::sun::star::sdbc::XCloseable
+ , ::com::sun::star::sdbc::XColumnLocate
+ , ::com::sun::star::lang::XServiceInfo
+ > OResultSet_BASE;
+
+
+ class OEvoabResultSet :public comphelper::OBaseMutex
+ ,public OResultSet_BASE
+ ,public ::comphelper::OPropertyContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper<OEvoabResultSet>
+ {
+
+ protected:
+
+ OCommonStatement* m_pStatement;
+ OEvoabConnection* m_pConnection;
+ ::com::sun::star::uno::WeakReferenceHelper m_aStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ ::dbtools::WarningsContainer m_aWarnings;
+
+ bool m_bWasNull;
+ // <properties>
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+ // </properties>
+
+ // Data & iteration
+ GList *m_pContacts;
+ sal_Int32 m_nIndex;
+ sal_Int32 m_nLength;
+ EContact *getCur()
+ {
+ gpointer pData = g_list_nth_data (m_pContacts, m_nIndex);
+ return pData ? E_CONTACT (pData) : NULL;
+ }
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ // you can't delete objects of this type
+ virtual ~OEvoabResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OEvoabResultSet( OCommonStatement *pStmt, OEvoabConnection *pConnection );
+ void construct( const QueryData& _rData );
+
+ OEvoabConnection * getConnection() { return m_pConnection; }
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
+ }
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+#endif // CONNECTIVITY_SRESULTSET_HXX
diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx
new file mode 100644
index 000000000000..096ed259cddf
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.cxx
@@ -0,0 +1,194 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NResultSetMetaData.hxx"
+#include "NDatabaseMetaData.hxx"
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "NDebug.hxx"
+#include "resource/evoab2_res.hrc"
+
+using namespace connectivity::evoab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+OEvoabResultSetMetaData::OEvoabResultSetMetaData(const ::rtl::OUString& _aTableName)
+ : m_aTableName(_aTableName),
+ m_aEvoabFields()
+{
+
+}
+// -------------------------------------------------------------------------
+OEvoabResultSetMetaData::~OEvoabResultSetMetaData()
+{
+}
+// -------------------------------------------------------------------------
+void OEvoabResultSetMetaData::setEvoabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
+{
+ OSQLColumns::Vector::const_iterator aIter;
+ static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
+
+ for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
+ {
+ ::rtl::OUString aFieldName;
+
+ (*aIter)->getPropertyValue(aName) >>= aFieldName;
+ guint nFieldNumber = findEvoabField(aFieldName);
+ if (nFieldNumber == (guint)-1)
+ {
+ connectivity::SharedResources aResource;
+ const ::rtl::OUString sError( aResource.getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", aFieldName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, *this );
+ }
+ m_aEvoabFields.push_back(nFieldNumber);
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnDisplaySize( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return 50;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnType( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
+ return evoab::getFieldType (nField);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ return m_aEvoabFields.size();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isCaseSensitive( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getSchemaName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
+ return evoab::getFieldName( nField );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnTypeName( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
+ return evoab::getFieldTypeName( nField );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnLabel( sal_Int32 nColumnNum ) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nField = m_aEvoabFields[nColumnNum - 1];
+ const ColumnProperty *pSpecs = getField(nField);
+ GParamSpec *pSpec = pSpecs->pField;
+ rtl::OUString aLabel;
+
+ if( pSpec )
+ aLabel = rtl::OStringToOUString( g_param_spec_get_nick( (GParamSpec *) pSpec ),
+ RTL_TEXTENCODING_UTF8 );
+ return aLabel;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getColumnServiceName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getTableName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return m_aTableName;//::rtl::OUString::createFromAscii("TABLE");
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OEvoabResultSetMetaData::getCatalogName( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isCurrency( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isAutoIncrement( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isSigned( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::getPrecision( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::getScale( sal_Int32 /*nColumnNum*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OEvoabResultSetMetaData::isNullable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isSearchable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isReadOnly( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isDefinitelyWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OEvoabResultSetMetaData::isWritable( sal_Int32 /*nColumnNum*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx b/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx
new file mode 100644
index 000000000000..95653c1ebeea
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NResultSetMetaData.hxx
@@ -0,0 +1,88 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_RESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_EVOAB_RESULTSETMETADATA_HXX_
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include "NConnection.hxx"
+#include <vos/ref.hxx>
+#include <com/sun/star/connection/XConnection.hpp>
+namespace connectivity
+{
+ namespace evoab
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OEvoabResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ ::rtl::OUString m_aTableName;
+ ::std::vector<sal_Int32> m_aEvoabFields;
+
+ protected:
+ virtual ~OEvoabResultSetMetaData();
+ public:
+ OEvoabResultSetMetaData(const ::rtl::OUString& _aTableName);
+ void setEvoabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(::com::sun::star::sdbc::SQLException);
+ inline sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const
+ { return m_aEvoabFields[columnIndex - 1]; }
+ inline sal_Int32 getFieldSize() const
+ {return m_aEvoabFields.size();}
+ /// Avoid ambigous cast error from the compiler.
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SRESULSETMETADATA_HXX
diff --git a/connectivity/source/drivers/evoab2/NServices.cxx b/connectivity/source/drivers/evoab2/NServices.cxx
new file mode 100644
index 000000000000..c11eed9d6c61
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NServices.cxx
@@ -0,0 +1,175 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::evoab;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "EVOAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(::com::sun::star::uno::Exception)
+ {
+ OSL_ENSURE(0,"Service Creation Exception");
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ OEvoabDriver::getImplementationName_Static(),
+ OEvoabDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ OEvoabDriver::getImplementationName_Static(),
+ OEvoabDriver::getSupportedServiceNames_Static(),
+ OEvoabDriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/evoab2/NStatement.cxx b/connectivity/source/drivers/evoab2/NStatement.cxx
new file mode 100644
index 000000000000..feca8f55aeff
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NStatement.cxx
@@ -0,0 +1,682 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include "propertyids.hxx"
+#include "NStatement.hxx"
+#include "NConnection.hxx"
+#include "NDatabaseMetaData.hxx"
+#include "NResultSet.hxx"
+#include "NDebug.hxx"
+#include "resource/evoab2_res.hrc"
+#include <resource/common_res.hrc>
+#include <connectivity/dbexception.hxx>
+#include <tools/diagnose_ex.h>
+
+namespace connectivity { namespace evoab {
+
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OCommonStatement::OCommonStatement(OEvoabConnection* _pConnection)
+ : OCommonStatement_IBase(m_aMutex)
+ , ::comphelper::OPropertyContainer(OCommonStatement_IBase::rBHelper)
+ , OStatement_CBase( (::cppu::OWeakObject*)_pConnection, this )
+ , m_xResultSet(NULL)
+ , m_pResultSet(NULL)
+ , m_pConnection(_pConnection)
+ , m_aParser(_pConnection->getDriver().getMSFactory())
+ , m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL )
+ , m_pParseTree(NULL)
+ , m_nMaxFieldSize(0)
+ , m_nMaxRows(0)
+ , m_nQueryTimeOut(0)
+ , m_nFetchSize(0)
+ , m_nResultSetType(ResultSetType::FORWARD_ONLY)
+ , m_nFetchDirection(FetchDirection::FORWARD)
+ , m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ , m_bEscapeProcessing(sal_True)
+ , rBHelper(OCommonStatement_IBase::rBHelper)
+{
+ m_pConnection->acquire();
+
+#define REGISTER_PROP( id, member ) \
+ registerProperty( \
+ OMetaConnection::getPropMap().getNameByIndex( id ), \
+ id, \
+ 0, \
+ &member, \
+ ::getCppuType( &member ) \
+ );
+
+ REGISTER_PROP( PROPERTY_ID_CURSORNAME, m_aCursorName );
+ REGISTER_PROP( PROPERTY_ID_MAXFIELDSIZE, m_nMaxFieldSize );
+ REGISTER_PROP( PROPERTY_ID_MAXROWS, m_nMaxRows );
+ REGISTER_PROP( PROPERTY_ID_QUERYTIMEOUT, m_nQueryTimeOut );
+ REGISTER_PROP( PROPERTY_ID_FETCHSIZE, m_nFetchSize );
+ REGISTER_PROP( PROPERTY_ID_RESULTSETTYPE, m_nResultSetType );
+ REGISTER_PROP( PROPERTY_ID_FETCHDIRECTION, m_nFetchDirection );
+ REGISTER_PROP( PROPERTY_ID_ESCAPEPROCESSING, m_bEscapeProcessing );
+ REGISTER_PROP( PROPERTY_ID_RESULTSETCONCURRENCY, m_nResultSetConcurrency );
+}
+// -----------------------------------------------------------------------------
+OCommonStatement::~OCommonStatement()
+{
+}
+//------------------------------------------------------------------------------
+void OCommonStatement::disposeResultSet()
+{
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet = Reference< XResultSet>();
+}
+//------------------------------------------------------------------------------
+void OCommonStatement::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ disposeResultSet();
+
+ if (m_pConnection)
+ m_pConnection->release();
+ m_pConnection = NULL;
+
+ dispose_ChildImpl();
+ OCommonStatement_IBase::disposing();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement_IBase::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = ::comphelper::OPropertyContainer::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBase::getTypes());
+}
+// -------------------------------------------------------------------------
+
+//void SAL_CALL OCommonStatement::cancel( ) throw(RuntimeException)
+//{
+//::osl::MutexGuard aGuard( m_aMutex );
+//checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+//// cancel the current sql statement
+//}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void OCommonStatement::reset() throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+
+ clearWarnings ();
+
+ if (m_xResultSet.get().is())
+ clearMyResultSet();
+}
+
+void OCommonStatement::clearMyResultSet () throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ try
+ {
+ Reference<XCloseable> xCloseable;
+ if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+
+ m_xResultSet = Reference< XResultSet >();
+}
+
+EBookQuery *
+OCommonStatement::createTrue()
+{ // Not the world's most efficient unconditional true but ...
+ return e_book_query_from_string("(exists \"full_name\")");
+}
+
+EBookQuery *
+OCommonStatement::createTest( const ::rtl::OUString &aColumnName,
+ EBookQueryTest eTest,
+ const ::rtl::OUString &aMatch )
+{
+ ::rtl::OString sMatch = rtl::OUStringToOString( aMatch, RTL_TEXTENCODING_UTF8 );
+ ::rtl::OString sColumnName = rtl::OUStringToOString( aColumnName, RTL_TEXTENCODING_UTF8 );
+
+ return e_book_query_field_test( e_contact_field_id( sColumnName ),
+ eTest, sMatch );
+}
+
+// -------------------------------------------------------------------------
+
+::rtl::OUString OCommonStatement::impl_getColumnRefColumnName_throw( const OSQLParseNode& _rColumnRef )
+{
+ ENSURE_OR_THROW( SQL_ISRULE( &_rColumnRef, column_ref ), "internal error: only column_refs supported as LHS" );
+
+ ::rtl::OUString sColumnName;
+ switch ( _rColumnRef.count() )
+ {
+ case 3: // SQL_TOKEN_NAME '.' column_val
+ {
+ const OSQLParseNode* pPunct = _rColumnRef.getChild( 1 );
+ const OSQLParseNode* pColVal = _rColumnRef.getChild( 2 );
+ if ( SQL_ISPUNCTUATION( pPunct, "." )
+ && ( pColVal->count() == 1 )
+ )
+ {
+ sColumnName = pColVal->getChild( 0 )->getTokenValue();
+ }
+ }
+ break;
+
+ case 1: // column
+ {
+ sColumnName = _rColumnRef.getChild( 0 )->getTokenValue();
+ }
+ break;
+ }
+
+ if ( !sColumnName.getLength() )
+ m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this );
+
+ return sColumnName;
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort )
+{
+ ENSURE_OR_THROW( _pOrderByClause, "NULL node" );
+ ENSURE_OR_THROW( SQL_ISRULE( _pOrderByClause, opt_order_by_clause ), "wrong node type" );
+
+ _out_rSort.clear();
+
+ const OSQLParseNode* pOrderList = _pOrderByClause->getByRule( OSQLParseNode::ordering_spec_commalist );
+ ENSURE_OR_THROW( pOrderList, "unexpected parse tree structure" );
+
+ for ( sal_uInt32 i=0; i<pOrderList->count(); ++i )
+ {
+ const OSQLParseNode* pOrderBy = pOrderList->getChild(i);
+ if ( !pOrderBy || !SQL_ISRULE( pOrderBy, ordering_spec ) )
+ continue;
+ const OSQLParseNode* pColumnRef = pOrderBy->count() == 2 ? pOrderBy->getChild(0) : NULL;
+ const OSQLParseNode* pAscDesc = pOrderBy->count() == 2 ? pOrderBy->getChild(1) : NULL;
+ ENSURE_OR_THROW(
+ ( pColumnRef != NULL )
+ && ( pAscDesc != NULL )
+ && SQL_ISRULE( pAscDesc, opt_asc_desc )
+ && ( pAscDesc->count() < 2 ),
+ "ordering_spec structure error" );
+
+ // column name -> column field
+ if ( !SQL_ISRULE( pColumnRef, column_ref ) )
+ m_pConnection->throwGenericSQLException( STR_SORT_BY_COL_ONLY, *this );
+ const ::rtl::OUString sColumnName( impl_getColumnRefColumnName_throw( *pColumnRef ) );
+ guint nField = evoab::findEvoabField( sColumnName );
+ // ascending/descending?
+ bool bAscending = true;
+ if ( ( pAscDesc->count() == 1 )
+ && SQL_ISTOKEN( pAscDesc->getChild( 0 ), DESC )
+ )
+ bAscending = false;
+
+ _out_rSort.push_back( FieldSort( nField, bAscending ) );
+ }
+}
+
+// -------------------------------------------------------------------------
+EBookQuery *OCommonStatement::whereAnalysis( const OSQLParseNode* parseTree )
+{
+ EBookQuery *pResult = NULL;
+
+ ENSURE_OR_THROW( parseTree, "invalid parse tree" );
+
+ // Nested brackets
+ if( parseTree->count() == 3 &&
+ SQL_ISPUNCTUATION( parseTree->getChild( 0 ), "(" ) &&
+ SQL_ISPUNCTUATION( parseTree->getChild( 2 ), ")" ) )
+ {
+ pResult = whereAnalysis( parseTree->getChild( 1 ) );
+ }
+
+ // SQL AND, OR
+ else if( ( SQL_ISRULE( parseTree, search_condition ) ||
+ SQL_ISRULE( parseTree, boolean_term ) ) &&
+ parseTree->count() == 3 )
+ {
+ ENSURE_OR_THROW( SQL_ISTOKEN( parseTree->getChild( 1 ), OR )
+ || SQL_ISTOKEN( parseTree->getChild( 1 ), AND ),
+ "unexpected search_condition structure" );
+
+ EBookQuery *pArgs[2];
+ pArgs[0] = whereAnalysis( parseTree->getChild( 0 ) );
+ pArgs[1] = whereAnalysis( parseTree->getChild( 2 ) );
+
+ if( SQL_ISTOKEN( parseTree->getChild( 1 ), OR ) )
+ pResult = e_book_query_or( 2, pArgs, TRUE );
+ else
+ pResult = e_book_query_and( 2, pArgs, TRUE );
+ }
+ // SQL =, !=
+ else if( SQL_ISRULE( parseTree, comparison_predicate ) )
+ {
+ OSQLParseNode *pPrec = parseTree->getChild( 1 );
+
+ ENSURE_OR_THROW( parseTree->count() == 3, "unexpected comparison_predicate structure" );
+
+ OSQLParseNode* pLHS = parseTree->getChild( 0 );
+ OSQLParseNode* pRHS = parseTree->getChild( 2 );
+
+ if ( ( !( SQL_ISRULE( pLHS, column_ref ) ) // on the LHS, we accept a column or a constant int value
+ && ( pLHS->getNodeType() != SQL_NODE_INTNUM )
+ )
+ || ( ( pRHS->getNodeType() != SQL_NODE_STRING ) // on the RHS, certain literals are acceptable
+ && ( pRHS->getNodeType() != SQL_NODE_INTNUM )
+ && ( pRHS->getNodeType() != SQL_NODE_APPROXNUM )
+ && !( SQL_ISTOKEN( pRHS, TRUE ) )
+ && !( SQL_ISTOKEN( pRHS, FALSE ) )
+ )
+ || ( ( pLHS->getNodeType() == SQL_NODE_INTNUM ) // an int on LHS requires an int on RHS
+ && ( pRHS->getNodeType() != SQL_NODE_INTNUM )
+ )
+ )
+ {
+ m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+
+ if ( ( pPrec->getNodeType() != SQL_NODE_EQUAL )
+ && ( pPrec->getNodeType() != SQL_NODE_NOTEQUAL )
+ )
+ {
+ m_pConnection->throwGenericSQLException( STR_OPERATOR_TOO_COMPLEX, *this );
+ }
+
+ // recognize the special "0 = 1" condition
+ if ( ( pLHS->getNodeType() == SQL_NODE_INTNUM )
+ && ( pRHS->getNodeType() == SQL_NODE_INTNUM )
+ && ( pPrec->getNodeType() == SQL_NODE_EQUAL )
+ )
+ {
+ const sal_Int32 nLHS = pLHS->getTokenValue().toInt64();
+ const sal_Int32 nRHS = pRHS->getTokenValue().toInt64();
+ return ( nLHS == nRHS ) ? createTrue() : NULL;
+ }
+
+ ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *pLHS ) );
+
+ ::rtl::OUString aMatchString;
+ if ( pRHS->isToken() )
+ aMatchString = pRHS->getTokenValue();
+ else
+ aMatchString = pRHS->getChild( 0 )->getTokenValue();
+
+ pResult = createTest( aColumnName, E_BOOK_QUERY_IS, aMatchString );
+
+ if ( pResult && ( pPrec->getNodeType() == SQL_NODE_NOTEQUAL ) )
+ pResult = e_book_query_not( pResult, TRUE );
+ }
+ // SQL like
+ else if( SQL_ISRULE( parseTree, like_predicate ) )
+ {
+ ENSURE_OR_THROW( parseTree->count() == 2, "unexpected like_predicate structure" );
+ const OSQLParseNode* pPart2 = parseTree->getChild(1);
+
+ if( ! SQL_ISRULE( parseTree->getChild( 0 ), column_ref) )
+ m_pConnection->throwGenericSQLException(STR_QUERY_INVALID_LIKE_COLUMN,*this);
+
+ ::rtl::OUString aColumnName( impl_getColumnRefColumnName_throw( *parseTree->getChild( 0 ) ) );
+
+ OSQLParseNode *pAtom = pPart2->getChild( pPart2->count() - 2 ); // Match String
+ bool bNotLike = pPart2->getChild(0)->isToken();
+
+ if( !( pAtom->getNodeType() == SQL_NODE_STRING ||
+ pAtom->getNodeType() == SQL_NODE_NAME ||
+ SQL_ISRULE( pAtom,parameter ) ||
+ ( pAtom->getChild( 0 ) && pAtom->getChild( 0 )->getNodeType() == SQL_NODE_NAME ) ||
+ ( pAtom->getChild( 0 ) && pAtom->getChild( 0 )->getNodeType() == SQL_NODE_STRING ) ) )
+ {
+ OSL_TRACE( "analyseSQL : pAtom->count() = %d\n", pAtom->count() );
+ m_pConnection->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,*this);
+ }
+
+ const sal_Unicode WILDCARD = '%';
+
+ rtl::OUString aMatchString;
+ aMatchString = pAtom->getTokenValue();
+
+ // Determine where '%' character is...
+ if( aMatchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) )
+ {
+ // String containing only a '%' and nothing else matches everything
+ pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS,
+ rtl::OUString::createFromAscii( "" ) );
+ }
+ else if( aMatchString.indexOf( WILDCARD ) == -1 )
+ { // Simple string , eg. "to match" "contains in evo"
+ EVO_TRACE_STRING( "Plain contains '%s'", aMatchString );
+ pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString );
+ if( pResult && bNotLike )
+ pResult = e_book_query_not( pResult, TRUE );
+ }
+ else if( bNotLike )
+ {
+ // We currently can't handle a 'NOT LIKE' when there are '%'
+ m_pConnection->throwGenericSQLException(STR_QUERY_NOT_LIKE_TOO_COMPLEX,*this);
+ }
+ else if( (aMatchString.indexOf ( WILDCARD ) == aMatchString.lastIndexOf ( WILDCARD ) ) )
+ { // One occurance of '%' matches...
+ if ( aMatchString.indexOf ( WILDCARD ) == 0 )
+ pResult = createTest( aColumnName, E_BOOK_QUERY_ENDS_WITH, aMatchString.copy( 1 ) );
+ else if ( aMatchString.indexOf ( WILDCARD ) == aMatchString.getLength() - 1 )
+ pResult = createTest( aColumnName, E_BOOK_QUERY_BEGINS_WITH, aMatchString.copy( 0, aMatchString.getLength() - 1 ) );
+ else
+ m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD,*this);
+
+ if( pResult && bNotLike )
+ pResult = e_book_query_not( pResult, TRUE );
+ }
+ else if( aMatchString.getLength() >= 3 &&
+ aMatchString.indexOf ( WILDCARD ) == 0 &&
+ aMatchString.indexOf ( WILDCARD, 1) == aMatchString.getLength() - 1 ) {
+ // one '%' at the start and another at the end
+ pResult = createTest( aColumnName, E_BOOK_QUERY_CONTAINS, aMatchString.copy (1, aMatchString.getLength() - 2) );
+ }
+ else
+ m_pConnection->throwGenericSQLException(STR_QUERY_LIKE_WILDCARD_MANY,*this);
+ }
+
+ return pResult;
+}
+
+rtl::OUString OCommonStatement::getTableName()
+{
+ ::rtl::OUString aTableName;
+
+ if( m_pParseTree && m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT )
+ {
+ Any aCatalog;
+ ::rtl::OUString aSchema, aComposedName;
+ const OSQLParseNode *pSelectStmnt = m_aSQLIterator.getParseTree();
+ const OSQLParseNode *pAllTableNames = pSelectStmnt->getChild( 3 )->getChild( 0 )->getChild( 1 );
+
+ if( m_aSQLIterator.isTableNode( pAllTableNames->getChild( 0 ) ) )
+ OSQLParseNode::getTableComponents( pAllTableNames->getChild( 0 ),
+ aCatalog,aSchema, aTableName,NULL );
+
+ else if( SQL_ISRULE( pAllTableNames->getChild( 0 ), table_ref ) )
+ {
+ OSQLParseNode *pNodeForTableName = pAllTableNames->getChild( 0 )->getChild( 0 );
+ if( m_aSQLIterator.isTableNode( pNodeForTableName ) )
+ {
+ aTableName = OSQLParseNode::getTableRange(pAllTableNames->getChild( 0 ));
+ if( !aTableName.getLength() )
+ OSQLParseNode::getTableComponents( pNodeForTableName, aCatalog, aSchema, aTableName,NULL);
+ }
+ else
+ OSL_ENSURE( false, "odd table layout" );
+ }
+ else
+ OSL_ENSURE( false, "unusual table layout" );
+ }
+ return aTableName;
+}
+
+void OCommonStatement::parseSql( const rtl::OUString& sql, QueryData& _out_rQueryData )
+{
+ EVO_TRACE_STRING( "parsing %s", sql );
+
+ _out_rQueryData.eFilterType = eFilterOther;
+
+ ::rtl::OUString aErr;
+ m_pParseTree = m_aParser.parseTree( aErr, sql );
+ m_aSQLIterator.setParseTree( m_pParseTree );
+ m_aSQLIterator.traverseAll();
+
+ _out_rQueryData.sTable = getTableName();
+
+ // to be sorted?
+ const OSQLParseNode* pOrderByClause = m_aSQLIterator.getOrderTree();
+ if ( pOrderByClause )
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sTreeDebug;
+ pOrderByClause->showParseTree( sTreeDebug );
+ EVO_TRACE_STRING( "found order-by tree:\n%s", sTreeDebug );
+ #endif
+ orderByAnalysis( pOrderByClause, _out_rQueryData.aSortOrder );
+ }
+
+ const OSQLParseNode* pWhereClause = m_aSQLIterator.getWhereTree();
+ if ( pWhereClause && SQL_ISRULE( pWhereClause, where_clause ) )
+ {
+ #if OSL_DEBUG_LEVEL > 0
+ ::rtl::OUString sTreeDebug;
+ pWhereClause->showParseTree( sTreeDebug );
+ EVO_TRACE_STRING( "found where tree:\n%s", sTreeDebug );
+ #endif
+ EBookQuery* pQuery = whereAnalysis( pWhereClause->getChild( 1 ) );
+ if ( !pQuery )
+ {
+ _out_rQueryData.eFilterType = eFilterAlwaysFalse;
+ pQuery = createTrue();
+ }
+ _out_rQueryData.setQuery( pQuery );
+ }
+ else
+ {
+ _out_rQueryData.eFilterType = eFilterNone;
+ _out_rQueryData.setQuery( createTrue() );
+ }
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ // just return our connection here
+ return impl_getConnection();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+
+ return makeAny(SQLWarning());
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties( aProps );
+ return new ::cppu::OPropertyArrayHelper( aProps );
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper()
+{
+ return *const_cast< OCommonStatement* >( this )->getArrayHelper();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::acquire() throw()
+{
+ OCommonStatement_IBase::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::release() throw()
+{
+ relase_ChildImpl();
+}
+
+// -------------------------------------------------------------------------
+QueryData OCommonStatement::impl_getEBookQuery_throw( const ::rtl::OUString& _rSql )
+{
+ QueryData aData;
+ parseSql( _rSql, aData );
+
+#ifdef DEBUG
+ char *pSexpr = aData.getQuery() ? e_book_query_to_string( aData.getQuery() ) : g_strdup( "<map failed>" );
+ g_message( "Parsed SQL to sexpr '%s'\n", pSexpr );
+ g_free( pSexpr );
+#endif
+
+ if ( !aData.getQuery() )
+ m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this );
+
+ // a postcondition of this method is that we properly determined the SELECT columns
+ aData.xSelectColumns = m_aSQLIterator.getSelectColumns();
+ if ( !aData.xSelectColumns.isValid() )
+ m_pConnection->throwGenericSQLException( STR_QUERY_TOO_COMPLEX, *this );
+
+ return aData;
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const QueryData& _rQueryData )
+{
+ // create result set
+ OEvoabResultSet* pResult = new OEvoabResultSet( this, m_pConnection );
+ Reference< XResultSet > xRS = pResult;
+ pResult->construct( _rQueryData );
+
+ // done
+ m_xResultSet = xRS;
+ return xRS;
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > OCommonStatement::impl_executeQuery_throw( const ::rtl::OUString& _rSql )
+{
+ EVO_TRACE_STRING( "OCommonStatement::impl_executeQuery_throw(%s)\n", _rSql );
+
+#ifdef DEBUG
+ g_message( "Parse SQL '%s'\n",
+ (const sal_Char *)OUStringToOString( _rSql, RTL_TEXTENCODING_UTF8 ) );
+#endif
+
+ return impl_executeQuery_throw( impl_getEBookQuery_throw( _rSql ) );
+}
+
+// -----------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() );
+}
+
+// =============================================================================
+// = OStatement
+// =============================================================================
+// -----------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO( OStatement, "com.sun.star.comp.sdbcx.evoab.OStatement", "com.sun.star.sdbc.Statement" );
+
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XINTERFACE2( OStatement, OCommonStatement, OStatement_IBase )
+
+// -----------------------------------------------------------------------------
+IMPLEMENT_FORWARD_XTYPEPROVIDER2( OStatement, OCommonStatement, OStatement_IBase )
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatement::execute( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ Reference< XResultSet > xRS = impl_executeQuery_throw( _sql );
+ return xRS.is();
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString& _sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+
+ return impl_executeQuery_throw( _sql );
+}
+
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStatement::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBase::rBHelper.bDisposed);
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+}
+
+} } // namespace ::connectivity::evoab
diff --git a/connectivity/source/drivers/evoab2/NStatement.hxx b/connectivity/source/drivers/evoab2/NStatement.hxx
new file mode 100644
index 000000000000..63c9b00d7b83
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NStatement.hxx
@@ -0,0 +1,288 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_STATEMENT_HXX_
+#define _CONNECTIVITY_EVOAB_STATEMENT_HXX_
+
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XMultipleResults.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase2.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sqliterator.hxx"
+#include "connectivity/sqlparse.hxx"
+#include <connectivity/FValue.hxx>
+#include "OSubComponent.hxx"
+#include <com/sun/star/util/XCancellable.hpp>
+#include <cppuhelper/compbase5.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+#include "EApi.h"
+
+#include <list>
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabResultSet;
+ class OEvoabConnection;
+ typedef ::cppu::WeakComponentImplHelper2 < ::com::sun::star::sdbc::XWarningsSupplier
+ , ::com::sun::star::sdbc::XCloseable
+ > OCommonStatement_IBase;
+
+ struct FieldSort
+ {
+ sal_Int32 nField;
+ bool bAscending;
+
+ FieldSort() : nField(0), bAscending( true ) { }
+ FieldSort( const sal_Int32 _nField, const bool _bAscending ) : nField( _nField ), bAscending( _bAscending ) { }
+ };
+ typedef ::std::vector< FieldSort > SortDescriptor;
+
+ enum QueryFilterType
+ {
+ eFilterAlwaysFalse,
+ eFilterNone,
+ eFilterOther
+ };
+
+ struct QueryData
+ {
+ private:
+ EBookQuery* pQuery;
+
+ public:
+ ::rtl::OUString sTable;
+ QueryFilterType eFilterType;
+ ::vos::ORef< ::connectivity::OSQLColumns > xSelectColumns;
+ SortDescriptor aSortOrder;
+
+ QueryData()
+ :pQuery( NULL )
+ ,sTable()
+ ,eFilterType( eFilterOther )
+ ,xSelectColumns()
+ ,aSortOrder()
+ {
+ }
+
+ QueryData( const QueryData& _rhs )
+ :pQuery( NULL )
+ ,sTable()
+ ,eFilterType( eFilterType )
+ ,xSelectColumns()
+ ,aSortOrder()
+ {
+ *this = _rhs;
+ }
+
+ QueryData& operator=( const QueryData& _rhs )
+ {
+ if ( this == &_rhs )
+ return *this;
+
+ setQuery( _rhs.pQuery );
+ sTable = _rhs.sTable;
+ eFilterType = _rhs.eFilterType;
+ xSelectColumns = _rhs.xSelectColumns;
+ aSortOrder = _rhs.aSortOrder;
+
+ return *this;
+ }
+
+ ~QueryData()
+ {
+ setQuery( NULL );
+ }
+
+ EBookQuery* getQuery() const { return pQuery; }
+
+ void setQuery( EBookQuery* _pQuery )
+ {
+ if ( pQuery )
+ e_book_query_unref( pQuery );
+ pQuery = _pQuery;
+ if ( pQuery )
+ e_book_query_ref( pQuery );
+ }
+ };
+
+ //**************************************************************
+ //************ Class: OCommonStatement
+ // is a base class for the normal statement and for the prepared statement
+ //**************************************************************
+ class OCommonStatement;
+ typedef OSubComponent< OCommonStatement, OCommonStatement_IBase > OStatement_CBase;
+
+ class OCommonStatement :public comphelper::OBaseMutex
+ ,public OCommonStatement_IBase
+ ,public ::comphelper::OPropertyContainer
+ ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement >
+ ,public OStatement_CBase
+ {
+ friend class OSubComponent< OCommonStatement, OCommonStatement_IBase >;
+
+ private:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+ OEvoabResultSet *m_pResultSet;
+ OEvoabConnection *m_pConnection;
+ connectivity::OSQLParser m_aParser;
+ connectivity::OSQLParseTreeIterator m_aSQLIterator;
+ connectivity::OSQLParseNode *m_pParseTree;
+
+ // <properties>
+ ::rtl::OUString m_aCursorName;
+ sal_Int32 m_nMaxFieldSize;
+ sal_Int32 m_nMaxRows;
+ sal_Int32 m_nQueryTimeOut;
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+ sal_Bool m_bEscapeProcessing;
+ // </properties>
+
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ protected:
+
+ void disposeResultSet();
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual ~OCommonStatement();
+
+ protected:
+ void reset () throw( ::com::sun::star::sdbc::SQLException);
+ void clearMyResultSet () throw( ::com::sun::star::sdbc::SQLException);
+ void parseSql( const ::rtl::OUString& sql, QueryData& _out_rQueryData );
+ EBookQuery *whereAnalysis( const OSQLParseNode* parseTree );
+ void orderByAnalysis( const OSQLParseNode* _pOrderByClause, SortDescriptor& _out_rSort );
+ rtl::OUString getTableName();
+ EBookQuery *createTrue();
+ EBookQuery *createTest( const ::rtl::OUString &aColumnName,
+ EBookQueryTest eTest,
+ const ::rtl::OUString &aMatch );
+
+ public:
+
+ // other methods
+ OEvoabConnection* getOwnConnection() const { return m_pConnection;}
+
+ using OCommonStatement_IBase::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ protected:
+ OCommonStatement( OEvoabConnection* _pConnection );
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ /** will return the EBookQuery representing the stamement's WHERE condition, or throw
+
+ Also, all statement dependent members (such as the parser/iterator) will be inited afterwards.
+ */
+ QueryData
+ impl_getEBookQuery_throw( const ::rtl::OUString& _rSql );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_executeQuery_throw( const ::rtl::OUString& _rSql );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_executeQuery_throw( const QueryData& _rData );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >
+ impl_getConnection() { return ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >( (::com::sun::star::sdbc::XConnection*)m_pConnection ); }
+
+ ::rtl::OUString
+ impl_getColumnRefColumnName_throw( const ::connectivity::OSQLParseNode& _rColumnRef );
+ };
+
+ typedef ::cppu::ImplHelper2 < ::com::sun::star::lang::XServiceInfo
+ , ::com::sun::star::sdbc::XStatement
+ > OStatement_IBase;
+ class OStatement :public OCommonStatement
+ ,public OStatement_IBase
+ {
+ protected:
+ virtual ~OStatement(){}
+
+ public:
+ OStatement( OEvoabConnection* _pConnection)
+ :OCommonStatement( _pConnection)
+ {
+ }
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ DECLARE_XTYPEPROVIDER()
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ };
+ }
+}
+#endif // CONNECTIVITY_SSTATEMENT_HXX
diff --git a/connectivity/source/drivers/evoab2/NTable.cxx b/connectivity/source/drivers/evoab2/NTable.cxx
new file mode 100644
index 000000000000..04881536e18c
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NTable.cxx
@@ -0,0 +1,89 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "NTable.hxx"
+#include "NTables.hxx"
+#include "NColumns.hxx"
+#ifndef _CONNECTIVITY_EVOAB_CATALOG_HXX__
+#include "NCatalog.hxx"
+#endif
+
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace connectivity::evoab;
+// -------------------------------------------------------------------------
+OEvoabTable::OEvoabTable( sdbcx::OCollection* _pTables,
+ OEvoabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OEvoabTable_TYPEDEF(_pTables,sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName),
+ m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OEvoabTable::refreshColumns()
+{
+ TStringVector aVector;
+
+ if (!isNew())
+ {
+ Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(
+ Any(),
+ m_SchemaName,
+ m_Name,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
+
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult, UNO_QUERY);
+ while (xResult->next())
+ aVector.push_back(xRow->getString(4));
+ }
+ }
+ if (m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OEvoabColumns(this,m_aMutex,aVector);
+}
diff --git a/connectivity/source/drivers/evoab2/NTable.hxx b/connectivity/source/drivers/evoab2/NTable.hxx
new file mode 100644
index 000000000000..8d75fabacecc
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NTable.hxx
@@ -0,0 +1,67 @@
+ /*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_EVOAB_TABLE_HXX_
+#define _CONNECTIVITY_EVOAB_TABLE_HXX_
+
+#include "NConnection.hxx"
+#include "connectivity/sdbcx/VTable.hxx"
+
+namespace connectivity
+{
+ namespace evoab
+ {
+ typedef connectivity::sdbcx::OTable OEvoabTable_TYPEDEF;
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class OEvoabTable : public OEvoabTable_TYPEDEF
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ OEvoabConnection* m_pConnection;
+
+ public:
+ OEvoabTable( sdbcx::OCollection* _pTables,
+ OEvoabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description = ::rtl::OUString(),
+ const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
+ const ::rtl::OUString& _CatalogName = ::rtl::OUString()
+ );
+
+ OEvoabConnection* getConnection() { return m_pConnection;}
+
+ virtual void refreshColumns();
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_EVOAB_TABLE_HXX_
diff --git a/connectivity/source/drivers/evoab2/NTables.cxx b/connectivity/source/drivers/evoab2/NTables.cxx
new file mode 100644
index 000000000000..e7129f0ec254
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NTables.cxx
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "NTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <connectivity/sdbcx/VTable.hxx>
+#include "NCatalog.hxx"
+#ifndef _CONNECTIVITY_EVOAB_BCONNECTION_HXX_
+#include "NConnection.hxx"
+#endif
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+#include "NDebug.hxx"
+#include "NTable.hxx"
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity::evoab;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+ObjectType OEvoabTables::createObject(const ::rtl::OUString& aName)
+{
+ ::rtl::OUString aSchema = ::rtl::OUString::createFromAscii("%");
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString::createFromAscii("TABLE");
+ ::rtl::OUString sEmpty;
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
+
+ ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ OEvoabTable* pRet = new OEvoabTable(
+ this,
+ (OEvoabConnection *)static_cast<OEvoabCatalog&>(m_rParent).getConnection(),
+ aName,
+ xRow->getString(4),
+ xRow->getString(5),
+ sEmpty);
+ xRet = pRet;
+ }
+ }
+
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OEvoabTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OEvoabCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OEvoabTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/evoab2/NTables.hxx b/connectivity/source/drivers/evoab2/NTables.hxx
new file mode 100644
index 000000000000..6c3db65adc3c
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/NTables.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_EVOAB_TABLES_HXX_
+#define _CONNECTIVITY_EVOAB_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace evoab
+ {
+ class OEvoabTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OEvoabTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,
+ ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) :
+ sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector),
+ m_xMetaData(_rMetaData)
+ {}
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_EVOAB_TABLES_HXX_
+
diff --git a/connectivity/source/drivers/evoab2/evoab.xml b/connectivity/source/drivers/evoab2/evoab.xml
new file mode 100644
index 000000000000..67aede2b31ef
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/evoab.xml
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>evoab</module-name>
+ <component-description>
+ <author>Jayant Madavi</author>
+ <name>com.sun.star.comp.sdbc.evoab.OEvoabDriver</name>
+ <description>This library implements the database driver for evolution address book formats.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/evoab2/evoab2.xcu b/connectivity/source/drivers/evoab2/evoab2.xcu
new file mode 100755
index 000000000000..a7c81d9c75e8
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/evoab2.xcu
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:evolution:local" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Evolution Local</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:evolution:ldap" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Evolution LDAP</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:evolution:groupwise" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.evoab.OEvoabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Groupwise</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/evoab2/makefile.mk b/connectivity/source/drivers/evoab2/makefile.mk
new file mode 100644
index 000000000000..e8a1cf96cddf
--- /dev/null
+++ b/connectivity/source/drivers/evoab2/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=evoab2
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+.IF "$(ENABLE_EVOAB2)"!="TRUE"
+dummy:
+ @echo "Evolution 2.x Addressbook build disabled"
+.ELSE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+PKGCONFIG_MODULES=gtk+-2.0
+.INCLUDE : pkg_config.mk
+
+CFLAGS+=$(GOBJECT_CFLAGS)
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/NDriver.obj \
+ $(SLO)$/NTable.obj \
+ $(SLO)$/NColumns.obj \
+ $(SLO)$/NTables.obj \
+ $(SLO)$/NCatalog.obj \
+ $(SLO)$/NConnection.obj \
+ $(SLO)$/NDatabaseMetaData.obj \
+ $(SLO)$/NStatement.obj \
+ $(SLO)$/NPreparedStatement.obj \
+ $(SLO)$/NServices.obj \
+ $(SLO)$/NResultSet.obj \
+ $(SLO)$/NResultSetMetaData.obj \
+ $(SLO)$/EApi.obj \
+ $(SLO)$/NDebug.obj
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+
+# --- Library -----------------------------------
+#SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1TARGET= $(EVOAB_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBFILELIB)" == ""
+SHL1STDLIBS+= ifile.lib
+.ENDIF
+SHL1STDLIBS+=$(GOBJECT_LIBS)
+
+
+SHL1STDLIBS+=$(PKGCONFIG_LIBS:s/ -lpangoxft-1.0//)
+# hack for faked SO environment
+.IF "$(PKGCONFIG_ROOT)"!=""
+SHL1SONAME+=-z nodefs
+SHL1NOCHECK=TRUE
+.ENDIF # "$(PKGCONFIG_ROOT)"!=""
+
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+.ENDIF
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
diff --git a/connectivity/source/drivers/file/FCatalog.cxx b/connectivity/source/drivers/file/FCatalog.cxx
new file mode 100644
index 000000000000..7ef176353082
--- /dev/null
+++ b/connectivity/source/drivers/file/FCatalog.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include "file/FTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+using namespace connectivity::file;
+// -------------------------------------------------------------------------
+OFileCatalog::OFileCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::OFileCatalog" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OFileCatalog::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ typedef connectivity::sdbcx::OCatalog OFileCatalog_BASE;
+m_xMetaData.clear();
+ OFileCatalog_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OFileCatalog::buildName(const Reference< XRow >& _xRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::buildName" );
+ return _xRow->getString(3);
+}
+// -------------------------------------------------------------------------
+void OFileCatalog::refreshTables()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::refreshTables" );
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+ fillNames(xResult,aVector);
+
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OFileCatalog::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::queryInterface" );
+ if( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XViewsSupplier>*)0))
+ return Any();
+
+
+ typedef sdbcx::OCatalog OFileCatalog_BASE;
+ return OFileCatalog_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFileCatalog::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileCatalog::getTypes" );
+ typedef sdbcx::OCatalog OFileCatalog_BASE;
+
+ Sequence< Type > aTypes = OFileCatalog_BASE::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XUsersSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XViewsSupplier>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ const Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/FColumns.cxx b/connectivity/source/drivers/file/FColumns.cxx
new file mode 100644
index 000000000000..3c3929a80c50
--- /dev/null
+++ b/connectivity/source/drivers/file/FColumns.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "file/FTable.hxx"
+#include <comphelper/property.hxx>
+
+using namespace connectivity::file;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sdbcx::OColumn* pRet = new sdbcx::OColumn(_rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False,
+ sal_False,
+ sal_False,
+ m_pTable->getConnection()->getMetaData()->storesMixedCaseQuotedIdentifiers());
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -----------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
diff --git a/connectivity/source/drivers/file/FConnection.cxx b/connectivity/source/drivers/file/FConnection.cxx
new file mode 100644
index 000000000000..de145407188a
--- /dev/null
+++ b/connectivity/source/drivers/file/FConnection.cxx
@@ -0,0 +1,461 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include "file/FConnection.hxx"
+#include "file/FDatabaseMetaData.hxx"
+#include "file/FDriver.hxx"
+#include "file/FStatement.hxx"
+#include "file/FPreparedStatement.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/container/XChild.hpp>
+#include <com/sun/star/ucb/XContent.hpp>
+#include <com/sun/star/ucb/XContentIdentifier.hpp>
+#include <tools/urlobj.hxx>
+#include "file/FCatalog.hxx"
+#include <unotools/pathoptions.hxx>
+#include <ucbhelper/content.hxx>
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <osl/thread.h>
+#include <osl/nlsupport.h>
+#include "resource/file_res.hrc"
+
+using namespace connectivity::file;
+using namespace dbtools;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::ucb;
+using namespace ::ucbhelper;
+using rtl::OUString;
+typedef connectivity::OMetaConnection OConnection_BASE;
+// --------------------------------------------------------------------------------
+OConnection::OConnection(OFileDriver* _pDriver)
+ : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+ ,m_pDriver(_pDriver)
+ ,m_bClosed(sal_False)
+ ,m_bShowDeleted(sal_False)
+ ,m_bCaseSensitiveExtension( sal_True )
+ ,m_bCheckSQL92(sal_False)
+ ,m_bDefaultTextEncoding(false)
+{
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ if(!isClosed( ))
+ close();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+
+//-----------------------------------------------------------------------------
+sal_Bool OConnection::matchesExtension( const String& _rExt ) const
+{
+ if ( isCaseSensitveExtension() )
+ return ( getExtension() == _rExt );
+
+ String sMyExtension( getExtension() );
+ sMyExtension.ToLowerAscii();
+ String sExt( _rExt );
+ sExt.ToLowerAscii();
+
+ return sMyExtension == sExt;
+}
+
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ ::rtl::OUString aExt;
+ const PropertyValue *pIter = info.getConstArray();
+ const PropertyValue *pEnd = pIter + info.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if(0 == pIter->Name.compareToAscii("Extension"))
+ OSL_VERIFY( pIter->Value >>= aExt );
+ else if(0 == pIter->Name.compareToAscii("CharSet"))
+ {
+ ::rtl::OUString sIanaName;
+ OSL_VERIFY( pIter->Value >>= sIanaName );
+
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end())
+ m_nTextEncoding = (*aLookup).getEncoding();
+ else
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+ }
+ else if (0 == pIter->Name.compareToAscii("ShowDeleted"))
+ {
+ OSL_VERIFY( pIter->Value >>= m_bShowDeleted );
+ }
+ else if (0 == pIter->Name.compareToAscii("EnableSQL92Check"))
+ {
+ pIter->Value >>= m_bCheckSQL92;
+ }
+ } // for(;pIter != pEnd;++pIter)
+
+ {
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(url.copy(nLen+1)),aUID,aPWD;
+
+ String aFileName = aDSN;
+ INetURLObject aURL;
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ {
+ SvtPathOptions aPathOptions;
+ aFileName = aPathOptions.SubstituteVariable(aFileName);
+ }
+
+ aURL.SetSmartURL(aFileName);
+
+ setURL(aURL.GetMainURL(INetURLObject::NO_DECODE));
+ }
+
+ if ( m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW )
+ {
+ //m_nTextEncoding = osl_getTextEncodingFromLocale(NULL);
+ m_nTextEncoding = osl_getThreadTextEncoding();
+ m_bDefaultTextEncoding = true;
+ }
+
+ if ( aExt.getLength() )
+ m_aFilenameExtension = aExt;
+
+ try
+ {
+ ::ucbhelper::Content aFile;
+ try
+ {
+ aFile = ::ucbhelper::Content(getURL(),Reference< XCommandEnvironment >());
+ }
+ catch(ContentCreationException& e)
+ {
+ throwUrlNotValid(getURL(),e.Message);
+ }
+
+ // set fields to fetch
+ Sequence< OUString > aProps(1);
+ OUString* pProps = aProps.getArray();
+ pProps[ 0 ] = OUString::createFromAscii( "Title" );
+
+ try
+ {
+ if (aFile.isFolder())
+ {
+ m_xDir = aFile.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ m_xContent = aFile.get();
+ }
+ else if (aFile.isDocument())
+ {
+ Reference<XContent> xParent(Reference<XChild>(aFile.get(),UNO_QUERY)->getParent(),UNO_QUERY);
+ Reference<XContentIdentifier> xIdent = xParent->getIdentifier();
+ m_xContent = xParent;
+
+ ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >());
+ m_xDir = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ }
+ else
+ {
+ OSL_ENSURE(0,"OConnection::construct: ::ucbhelper::Content isn't a folde nor a document! How that?!");
+ throw SQLException();
+ }
+ }
+ catch(Exception& e) // a execption is thrown when no file exists
+ {
+ throwUrlNotValid(getURL(),e.Message);
+ }
+ if(!m_xDir.is() || !m_xContent.is())
+ throwUrlNotValid(getURL(),::rtl::OUString());
+
+ if (m_aFilenameExtension.Search('*') != STRING_NOTFOUND || m_aFilenameExtension.Search('?') != STRING_NOTFOUND)
+ throw SQLException();
+ }
+ catch(const Exception&)
+ {
+ osl_decrementInterlockedCount( &m_refCount );
+ throw;
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.file.Connection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XStatement > xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OPreparedStatement* pStmt = new OPreparedStatement(this);
+ Reference< XPreparedStatement > xHoldAlive = pStmt;
+ pStmt->construct(sql);
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return pStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ return sql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ m_bAutoCommit = autoCommit;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ return m_bAutoCommit;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ m_bReadOnly = readOnly;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return m_bReadOnly;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// --------------------------------------------------------------------------------
+Reference< XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OConnection_BASE::disposing();
+
+ m_bClosed = sal_True;
+m_xDir.clear();
+m_xContent.clear();
+ m_xCatalog = WeakReference< XTablesSupplier>();
+
+ dispose_ChildImpl();
+}
+//------------------------------------------------------------------------------
+Reference< XTablesSupplier > OConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ xTab = new OFileCatalog(this);
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+Reference< XDynamicResultSet > OConnection::getDir() const
+{
+ Reference<XDynamicResultSet> xContent;
+ Sequence< ::rtl::OUString > aProps(1);
+ ::rtl::OUString* pProps = aProps.getArray();
+ pProps[ 0 ] = ::rtl::OUString::createFromAscii( "Title" );
+ try
+ {
+ Reference<XContentIdentifier> xIdent = getContent()->getIdentifier();
+ ::ucbhelper::Content aParent(xIdent->getContentIdentifier(),Reference< XCommandEnvironment >());
+ xContent = aParent.createDynamicCursor(aProps, ::ucbhelper::INCLUDE_DOCUMENTS_ONLY );
+ }
+ catch(Exception&)
+ {
+ }
+ return xContent;
+}
+// -----------------------------------------------------------------------------
+sal_Int64 SAL_CALL OConnection::getSomething( const Sequence< sal_Int8 >& rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : (sal_Int64)0;
+}
+// -----------------------------------------------------------------------------
+Sequence< sal_Int8 > OConnection::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+// -----------------------------------------------------------------------------
+void OConnection::throwUrlNotValid(const ::rtl::OUString & _rsUrl,const ::rtl::OUString & _rsMessage)
+{
+ SQLException aError;
+ aError.Message = getResources().getResourceStringWithSubstitution(
+ STR_NO_VALID_FILE_URL,
+ "$URL$", _rsUrl
+ );
+
+ aError.SQLState = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("S1000"));
+ aError.ErrorCode = 0;
+ aError.Context = static_cast< XConnection* >(this);
+ if (_rsMessage.getLength())
+ aError.NextException <<= SQLException(_rsMessage, aError.Context, ::rtl::OUString(), 0, Any());
+
+ throw aError;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/file/FDatabaseMetaData.cxx b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
new file mode 100644
index 000000000000..24fcb06833fa
--- /dev/null
+++ b/connectivity/source/drivers/file/FDatabaseMetaData.cxx
@@ -0,0 +1,1223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FDatabaseMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/ucb/SearchRecursion.hpp>
+#include <com/sun/star/ucb/SearchCommandArgument.hpp>
+#include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
+#include <com/sun/star/ucb/XContentProvider.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <tools/urlobj.hxx>
+#include "file/FDriver.hxx"
+#include "file/FTable.hxx"
+#include <comphelper/extract.hxx>
+#include <ucbhelper/content.hxx>
+#include <ucbhelper/contentbroker.hxx>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+
+using namespace com::sun::star::ucb;
+using namespace connectivity::file;
+using namespace connectivity;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::container;
+
+DBG_NAME( file_ODatabaseMetaData )
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon) : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_pConnection(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ODatabaseMetaData" );
+ DBG_CTOR( file_ODatabaseMetaData, NULL );
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+ DBG_DTOR( file_ODatabaseMetaData, NULL );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getTypeInfo_throw" );
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTypeInfo );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getCatalogSeparator_throw" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*tableNamePattern*/,
+ const ::rtl::OUString& /*columnNamePattern*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getColumns" );
+ OSL_ENSURE(0,"Should be overloaded!");
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumns );
+}
+
+// -------------------------------------------------------------------------
+namespace
+{
+ sal_Int16 isCaseSensitiveParentFolder( const String& _rFolderOrDoc, const String& _rDocName )
+ {
+ sal_Int16 nIsCS = 1;
+ try
+ {
+ // first get the real content for the URL
+ INetURLObject aContentURL( _rFolderOrDoc );
+ ::ucbhelper::Content aContent1;
+ {
+ ::ucbhelper::Content aFolderOrDoc( _rFolderOrDoc, Reference< XCommandEnvironment >() );
+ if ( aFolderOrDoc.isDocument() )
+ aContent1 = aFolderOrDoc;
+ else
+ {
+ aContentURL = INetURLObject( _rFolderOrDoc, INetURLObject::WAS_ENCODED );
+ aContentURL.Append( _rDocName );
+ aContent1 = ::ucbhelper::Content( aContentURL.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
+ }
+ }
+
+ // get two extensions which differ by case only
+ String sExtension1 = aContentURL.getExtension();
+ String sExtension2( sExtension1 );
+ sExtension2.ToLowerAscii();
+ if ( sExtension2 == sExtension1 )
+ // the extension was already in lower case
+ sExtension2.ToUpperAscii();
+
+ // the complete URL for the second extension
+ INetURLObject aURL2( aContentURL );
+ if ( sExtension2.Len() )
+ aURL2.SetExtension( sExtension2 );
+ if ( aURL2.GetMainURL(INetURLObject::NO_DECODE) == aContentURL.GetMainURL(INetURLObject::NO_DECODE) )
+ return -1;
+
+ // the second context
+ sal_Bool bCanAccess = sal_False;
+ ::ucbhelper::Content aContent2;
+ try
+ {
+ aContent2 = ::ucbhelper::Content( aURL2.GetMainURL( INetURLObject::NO_DECODE ), Reference< XCommandEnvironment >() );
+ bCanAccess = aContent2.isDocument();
+ }
+ catch( const Exception& )
+ {
+ }
+
+ if ( bCanAccess )
+ {
+ // here we have two contents whose URLs differ by case only.
+ // Now let's check if both really refer to the same object ....
+ Reference< XContent > xContent1 = aContent1.get();
+ Reference< XContent > xContent2 = aContent2.get();
+ OSL_ENSURE( xContent1.is() && xContent2.is(), "isCaseSensitiveParentFolder: invalid content interfaces!" );
+ if ( xContent1.is() && xContent2.is() )
+ {
+ Reference< XContentIdentifier > xID1 = xContent1->getIdentifier();
+ Reference< XContentIdentifier > xID2 = xContent2->getIdentifier();
+ OSL_ENSURE( xID1.is() && xID2.is(), "isCaseSensitiveParentFolder: invalid ID interfaces!" );
+ if ( xID1.is() && xID2.is() )
+ {
+ // get a generic content provider
+ ::ucbhelper::ContentBroker* pBroker = ::ucbhelper::ContentBroker::get();
+ Reference< XContentProvider > xProvider;
+ if ( pBroker )
+ xProvider = pBroker->getContentProviderInterface();
+ OSL_ENSURE( xProvider.is(), "isCaseSensitiveParentFolder: invalid content broker!" );
+ if ( xProvider.is() )
+ {
+ if ( 0 == xProvider->compareContentIds( xID1, xID2 ) )
+ // finally, we know that the folder is not case-sensitive ....
+ nIsCS = 0;
+ }
+ }
+ }
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "isCaseSensitiveParentFolder: caught an unexpected exception!" );
+ }
+
+ return nIsCS;
+ }
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTables" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTables );
+ Reference< XResultSet > xRef = pResult;
+
+ // check if any type is given
+ // when no types are given then we have to return all tables e.g. TABLE
+
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ sal_Bool bTableFound = sal_True;
+ sal_Int32 nLength = types.getLength();
+ if(nLength)
+ {
+ bTableFound = sal_False;
+
+ const ::rtl::OUString* pBegin = types.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + nLength;
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(*pBegin == aTable)
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ }
+ }
+ if(!bTableFound)
+ return xRef;
+
+ Reference<XDynamicResultSet> xContent = m_pConnection->getDir();
+ Reference < XSortedDynamicResultSetFactory > xSRSFac(
+ m_pConnection->getDriver()->getFactory()->createInstance( ::rtl::OUString::createFromAscii("com.sun.star.ucb.SortedDynamicResultSetFactory") ), UNO_QUERY );
+
+ Sequence< NumberedSortingInfo > aSortInfo( 1 );
+ NumberedSortingInfo* pInfo = aSortInfo.getArray();
+ pInfo[ 0 ].ColumnIndex = 1;
+ pInfo[ 0 ].Ascending = sal_True;
+
+ Reference < XAnyCompareFactory > xFactory;
+ Reference< XDynamicResultSet > xDynamicResultSet;
+ xDynamicResultSet = xSRSFac->createSortedDynamicResultSet( xContent, aSortInfo, xFactory );
+ Reference<XResultSet> xResultSet = xDynamicResultSet->getStaticResultSet();
+
+ Reference<XRow> xRow(xResultSet,UNO_QUERY);
+
+ String aFilenameExtension = m_pConnection->getExtension();
+ String sThisContentExtension;
+ ODatabaseMetaDataResultSet::ORows aRows;
+ // scan the directory for tables
+ ::rtl::OUString aName;
+ INetURLObject aURL;
+ xResultSet->beforeFirst();
+
+ sal_Bool bKnowCaseSensivity = sal_False;
+ sal_Bool bCaseSensitiveDir = sal_True;
+ sal_Bool bCheckEnabled = m_pConnection->isCheckEnabled();
+
+ while(xResultSet->next())
+ {
+ aName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = m_pConnection->getURL() + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + aName;
+ aURL.SetSmartURL( sUrl );
+ sThisContentExtension = aURL.getExtension();
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+ aRow.reserve(6);
+ sal_Bool bNewRow = sal_False;
+
+ if ( !bKnowCaseSensivity )
+ {
+ bKnowCaseSensivity = sal_True;
+ sal_Int16 nCase = isCaseSensitiveParentFolder( m_pConnection->getURL(), aURL.getName() );
+ switch( nCase )
+ {
+ case 1:
+ bCaseSensitiveDir = sal_True;
+ break;
+ case -1:
+ bKnowCaseSensivity = sal_False;
+ /** run through */
+ case 0:
+ bCaseSensitiveDir = sal_False;
+ }
+ if ( bKnowCaseSensivity )
+ {
+ m_pConnection->setCaseSensitiveExtension( bCaseSensitiveDir, OConnection::GrantAccess() );
+ if ( !bCaseSensitiveDir )
+ aFilenameExtension.ToLowerAscii();
+ }
+ }
+
+ if (aFilenameExtension.Len())
+ {
+ if ( !bCaseSensitiveDir )
+ sThisContentExtension.ToLowerAscii();
+
+ if ( sThisContentExtension == aFilenameExtension )
+ {
+ aName = aName.replaceAt(aName.getLength()-(aFilenameExtension.Len()+1),aFilenameExtension.Len()+1,::rtl::OUString());
+ sal_Unicode nChar = aName.toChar();
+ if ( match(tableNamePattern,aName.getStr(),'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) )
+ {
+ aRow.push_back(new ORowSetValueDecorator(aName));
+ bNewRow = sal_True;
+ }
+ }
+ }
+ else // no extension, filter myself
+ {
+ sal_Bool bErg = sal_False;
+ do
+ {
+ if (!aURL.getExtension().getLength())
+ {
+ sal_Unicode nChar = aURL.getBase().getStr()[0];
+ if(match(tableNamePattern,aURL.getBase().getStr(),'\0') && ( !bCheckEnabled || ( bCheckEnabled && ((nChar < '0' || nChar > '9')))) )
+ {
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString(aURL.getBase())));
+ bNewRow = sal_True;
+ }
+ break;
+ }
+ else if ( ( bErg = xResultSet->next() ) != sal_False )
+ {
+ aName = xRow->getString(1);
+ aURL.SetSmartURL(aName);
+ }
+ } while (bErg);
+ }
+ if(bNewRow)
+ {
+ aRow.push_back(new ORowSetValueDecorator(aTable));
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+
+ aRows.push_back(aRow);
+ }
+ }
+
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxBinaryLiteralLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxRowSize" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCatalogNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCharLiteralLength" );
+ return STRING_MAXLEN;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInIndex" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxCursorNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxConnections" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInTable" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getMaxStatements_throw" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxTableNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getMaxTablesInSelect_throw" );
+ return 1;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTablePrivileges" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+ Reference< XResultSet > xRef = pResult;
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+
+ Reference< XTablesSupplier > xTabSup = m_pConnection->createCatalog();
+ if( xTabSup.is())
+ {
+ Reference< XNameAccess> xNames = xTabSup->getTables();
+ Sequence< ::rtl::OUString > aNames = xNames->getElementNames();
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(match(tableNamePattern,pBegin->getStr(),'\0'))
+ {
+ static ODatabaseMetaDataResultSet::ORow aRow(8);
+
+ aRow[2] = new ORowSetValueDecorator(*pBegin);
+ aRow[6] = ODatabaseMetaDataResultSet::getSelectValue();
+ aRow[7] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ aRows.push_back(aRow);
+
+ Reference< XPropertySet> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pBegin));
+ if(xTable.is())
+ {
+ Reference<XUnoTunnel> xTunnel(xTable,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OFileTable* pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) );
+ if(pTable)
+ {
+ if(!pTable->isReadOnly())
+ {
+ aRow[6] = ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ if(!m_pConnection->showDeleted())
+ {
+ aRow[6] = ODatabaseMetaDataResultSet::getDeleteValue();
+ aRows.push_back(aRow);
+ }
+ aRow[6] = ODatabaseMetaDataResultSet::getUpdateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getCreateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getReadValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getAlterValue();
+ aRows.push_back(aRow);
+ aRow[6] = ODatabaseMetaDataResultSet::getDropValue();
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::doesMaxRowSizeIncludeBlobs" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesLowerCaseQuotedIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesLowerCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesMixedCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesUpperCaseQuotedIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::storesUpperCaseIdentifiers" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxIndexLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsNonNullableColumns" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getCatalogTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_getIdentifierQuoteString_throw" );
+ static const ::rtl::OUString sQuote = ::rtl::OUString::createFromAscii("\"");
+ return sQuote;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getExtraNameCharacters" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDifferentTableCorrelationNames" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_isCatalogAtStart_throw" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::dataDefinitionIgnoredInTransactions" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::dataDefinitionCausesTransactionCommit" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDataManipulationTransactionsOnly" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsPositionedDelete" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsPositionedUpdate" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenStatementsAcrossRollback" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenStatementsAcrossCommit" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenCursorsAcrossCommit" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOpenCursorsAcrossRollback" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTransactionIsolationLevel" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92FullSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92EntryLevelSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsIntegrityEnhancementFacility" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInIndexDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInIndexDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTableTypes" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTableTypes );
+ Reference< XResultSet > xRef = pResult;
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TABLE")));
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxStatementLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxProcedureNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxSchemaNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::allProceduresAreCallable" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsStoredProcedures" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSelectForUpdate" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::allTablesAreSelectable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::isReadOnly" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::usesLocalFiles" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::usesLocalFilePerTable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTypeConversion" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullPlusNonNullIsNull" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsColumnAliasing" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsTableCorrelationNames" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsConvert" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsExpressionsInOrderBy" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupBy" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupByBeyondSelect" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsGroupByUnrelated" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMultipleTransactions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMultipleResultSets" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsLikeEscapeClause" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsOrderByUnrelated" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsUnion" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsUnionAll" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMixedCaseIdentifiers" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedAtEnd" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedAtStart" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedHigh" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::nullsAreSortedLow" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInProcedureCalls" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInProcedureCalls" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCorrelatedSubqueries" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInComparisons" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInExists" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInIns" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsSubqueriesInQuantifieds" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsANSI92IntermediateSQL" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getURL" );
+ static const ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:file:");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getUserName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverVersion" );
+ return ::rtl::OUString::valueOf((sal_Int32)1);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDatabaseProductVersion" );
+ return ::rtl::OUString::valueOf((sal_Int32)0);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDatabaseProductName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getProcedureTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSchemaTerm" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverMajorVersion" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDefaultTransactionIsolation" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getDriverMinorVersion" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSQLKeywords" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSearchStringEscape" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getStringFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UCASE,LCASE,ASCII,LENGTH,OCTET_LENGTH,CHAR_LENGTH,CHARACTER_LENGTH,CHAR,CONCAT,LOCATE,SUBSTRING,LTRIM,RTRIM,SPACE,REPLACE,REPEAT,INSERT,LEFT,RIGHT"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getTimeDateFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DAYOFWEEK,DAYOFMONTH,DAYOFYEAR,MONTH,DAYNAME,MONTHNAME,QUARTER,WEEK,YEAR,HOUR,MINUTE,SECOND,CURDATE,CURTIME,NOW"));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getSystemFunctions" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getNumericFunctions" );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ABS,SIGN,MOD,FLOOR,CEILING,ROUND,EXP,LN,LOG,LOG10,POWER,SQRT,PI,COS,SIN,TAN,ACOS,ASIN,ATAN,ATAN2,DEGREES,RADIANS"));
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsExtendedSQLGrammar" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsCoreSQLGrammar" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsMinimumSQLGrammar" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsFullOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsLimitedOuterJoins" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInGroupBy" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInOrderBy" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxColumnsInSelect" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getMaxUserNameLength" );
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsResultSetType" );
+ switch(setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ return sal_True;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ case ResultSetType::SCROLL_SENSITIVE:
+ break;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsResultSetConcurrency" );
+ switch(setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ return sal_True;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ case ResultSetType::SCROLL_SENSITIVE:
+ break;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownUpdatesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownDeletesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::ownInsertsAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersUpdatesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersDeletesAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::othersInsertsAreVisible" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::updatesAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::deletesAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::insertsAreDetected" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::supportsBatchUpdates" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ODatabaseMetaData::getUDTs" );
+ return NULL;
+}
+
+
diff --git a/connectivity/source/drivers/file/FDateFunctions.cxx b/connectivity/source/drivers/file/FDateFunctions.cxx
new file mode 100644
index 000000000000..69330bf0c168
--- /dev/null
+++ b/connectivity/source/drivers/file/FDateFunctions.cxx
@@ -0,0 +1,289 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "file/FDateFunctions.hxx"
+#include <tools/date.hxx>
+#include <tools/time.hxx>
+#include <tools/datetime.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfWeek::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 0;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
+ switch(eDayOfWeek)
+ {
+ case MONDAY:
+ nRet = 2;
+ break;
+ case TUESDAY:
+ nRet = 3;
+ break;
+ case WEDNESDAY:
+ nRet = 4;
+ break;
+ case THURSDAY:
+ nRet = 5;
+ break;
+ case FRIDAY:
+ nRet = 6;
+ break;
+ case SATURDAY:
+ nRet = 7;
+ break;
+ case SUNDAY:
+ nRet = 1;
+ break;
+ default:
+ OSL_ENSURE(0,"Error in enum values for date");
+ }
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfMonth::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Day);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayOfYear::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ return static_cast<sal_Int16>(aDate.GetDayOfYear());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Month::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Month);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_DayName::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ DayOfWeek eDayOfWeek = aDate.GetDayOfWeek();
+ switch(eDayOfWeek)
+ {
+ case MONDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Monday"));
+ break;
+ case TUESDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Tuesday"));
+ break;
+ case WEDNESDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Wednesday"));
+ break;
+ case THURSDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thursday"));
+ break;
+ case FRIDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Friday"));
+ break;
+ case SATURDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Saturday"));
+ break;
+ case SUNDAY:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Sunday"));
+ break;
+ default:
+ OSL_ENSURE(0,"Error in enum values for date");
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_MonthName::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ ::com::sun::star::util::Date aD = lhs;
+ switch(aD.Month)
+ {
+ case 1:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("January"));
+ break;
+ case 2:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("February"));
+ break;
+ case 3:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("March"));
+ break;
+ case 4:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("April"));
+ break;
+ case 5:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("May"));
+ break;
+ case 6:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("June"));
+ break;
+ case 7:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("July"));
+ break;
+ case 8:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("August"));
+ break;
+ case 9:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("September"));
+ break;
+ case 10:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("October"));
+ break;
+ case 11:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("November"));
+ break;
+ case 12:
+ sRet = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("December"));
+ break;
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Quarter::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 1;
+ ::com::sun::star::util::Date aD = lhs;
+ Date aDate(aD.Day,aD.Month,aD.Year);
+ if ( aD.Month >= 4 && aD.Month < 7 )
+ nRet = 2;
+ else if ( aD.Month >= 7 && aD.Month < 10 )
+ nRet = 3;
+ else if ( aD.Month >= 10 && aD.Month <= 12 )
+ nRet = 4;
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Week::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+
+ size_t nSize = lhs.size();
+
+ ::com::sun::star::util::Date aD = lhs[nSize-1];
+ Date aDate(aD.Day,aD.Month,aD.Year);
+
+ sal_Int16 nStartDay = SUNDAY;
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nStartDay = lhs[0];
+
+ return static_cast<sal_Int16>(aDate.GetWeekOfYear(static_cast<DayOfWeek>(nStartDay)));
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Year::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Date aD = lhs;
+ return static_cast<sal_Int16>(aD.Year);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Hour::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Hours);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Minute::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Minutes);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Second::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::com::sun::star::util::Time aT = lhs;
+ return static_cast<sal_Int16>(aT.Seconds);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CurDate::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ Date aCurDate;
+ return ::com::sun::star::util::Date(aCurDate.GetDay(),aCurDate.GetMonth(),aCurDate.GetYear());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CurTime::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ Time aCurTime;
+ return ::com::sun::star::util::Time(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour());
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Now::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( !lhs.empty() )
+ return ORowSetValue();
+
+ DateTime aCurTime;
+ return ::com::sun::star::util::DateTime(aCurTime.Get100Sec(),aCurTime.GetSec(),aCurTime.GetMin(),aCurTime.GetHour(),
+ aCurTime.GetDay(),aCurTime.GetMonth(),aCurTime.GetYear());
+}
+//------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FDriver.cxx b/connectivity/source/drivers/file/FDriver.cxx
new file mode 100644
index 000000000000..d0d952e9bab6
--- /dev/null
+++ b/connectivity/source/drivers/file/FDriver.cxx
@@ -0,0 +1,285 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FDriver.hxx"
+#include "file/FConnection.hxx"
+#include "file/fcode.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include <rtl/logfile.hxx>
+
+
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+// --------------------------------------------------------------------------------
+OFileDriver::OFileDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : ODriver_BASE(m_aMutex)
+ ,m_xFactory(_rxFactory)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::OFileDriver" );
+}
+// --------------------------------------------------------------------------------
+void OFileDriver::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ ODriver_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString OFileDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.sdbc.driver.file.Driver");
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > OFileDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver");
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFileDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL OFileDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OFileDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OFileDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::connect" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriver_BASE::rBHelper.bDisposed);
+
+ OConnection* pCon = new OConnection(this);
+ Reference< XConnection > xCon = pCon;
+ pCon->construct(url,info);
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OFileDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::acceptsURL" );
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:file:"),10));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL OFileDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getPropertyInfo" );
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBoolean(2);
+ aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
+ aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Extension of the file format."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(".*"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ShowDeleted"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Display inactive records."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EnableSQL92Check"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Use SQL92 naming constraints."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseRelativePath"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Handle the connection url as relative path."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The URL of the database document which is used to create an absolute path."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&(aDriverInfo[0]),aDriverInfo.size());
+ } // if ( acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFileDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getMajorVersion" );
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFileDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getMinorVersion" );
+ return 0;
+}
+// --------------------------------------------------------------------------------
+// --------------------------------------------------------------------------------
+// XDataDefinitionSupplier
+Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByConnection( const Reference< ::com::sun::star::sdbc::XConnection >& connection ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getDataDefinitionByConnection" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriver_BASE::rBHelper.bDisposed);
+
+ Reference< XTablesSupplier > xTab = NULL;
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ OConnection* pSearchConnection = reinterpret_cast< OConnection* >( xTunnel->getSomething(OConnection::getUnoTunnelImplementationId()) );
+ OConnection* pConnection = NULL;
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ if ((OConnection*) Reference< XConnection >::query(i->get().get()).get() == pSearchConnection)
+ {
+ pConnection = pSearchConnection;
+ break;
+ }
+ }
+
+ if(pConnection)
+ xTab = pConnection->createCatalog();
+ }
+ return xTab;
+}
+
+// --------------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL OFileDriver::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileDriver::getDataDefinitionByURL" );
+ if ( ! acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+ return getDataDefinitionByConnection(connect(url,info));
+}
+// -----------------------------------------------------------------------------
+void OOperandParam::describe(const Reference< XPropertySet>& rColumn, ::vos::ORef<connectivity::OSQLColumns> rParameterColumns)
+{
+ // den alten namen beibehalten
+
+ OSL_ENSURE(getRowPos() < rParameterColumns->get().size(),"Invalid index for orderkey values!");
+
+ Reference< XPropertySet> xColumn = (rParameterColumns->get())[getRowPos()];
+
+ try
+ {
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+ xColumn->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT),rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)));
+ }
+ catch(const Exception&)
+ {
+ }
+
+ m_eDBType = ::comphelper::getINT32(rColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+}
+// -----------------------------------------------------------------------------
+OOperandAttr::OOperandAttr(sal_uInt16 _nPos,const Reference< XPropertySet>& _xColumn)
+ : OOperandRow(_nPos,::comphelper::getINT32(_xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ , m_xColumn(_xColumn)
+{
+}
+// -----------------------------------------------------------------------------
+
+
+
+
diff --git a/connectivity/source/drivers/file/FNoException.cxx b/connectivity/source/drivers/file/FNoException.cxx
new file mode 100644
index 000000000000..4bf0a2e37a1b
--- /dev/null
+++ b/connectivity/source/drivers/file/FNoException.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FCatalog.hxx"
+#include "file/fcomp.hxx"
+#include "file/fanalyzer.hxx"
+#include "file/FResultSet.hxx"
+#include "file/FPreparedStatement.hxx"
+#include <connectivity/FValue.hxx>
+#include <tools/debug.hxx>
+#include "TKeyValue.hxx"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+// -----------------------------------------------------------------------------
+void OFileCatalog::refreshViews()
+{}
+void OFileCatalog::refreshGroups()
+{}
+void OFileCatalog::refreshUsers()
+{
+}
+// -----------------------------------------------------------------------------
+OPredicateInterpreter::~OPredicateInterpreter()
+{
+ while(!m_aStack.empty())
+ {
+ delete m_aStack.top();
+ m_aStack.pop();
+ }
+ // m_aStack.clear();
+}
+// -----------------------------------------------------------------------------
+void OPredicateCompiler::Clean()
+{
+ for(OCodeList::reverse_iterator aIter = m_aCodeList.rbegin(); aIter != m_aCodeList.rend();++aIter)
+ {
+ delete *aIter;
+ }
+ m_aCodeList.clear();
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::clean()
+{
+ m_aCompiler->Clean();
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::bindParameterRow(OValueRefRow& _pRow)
+{
+ OCodeList& rCodeList = m_aCompiler->m_aCodeList;
+ for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end();++aIter)
+ {
+ OOperandParam* pParam = PTR_CAST(OOperandParam,(*aIter));
+ if ( pParam )
+ pParam->bindValue(_pRow);
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::scanParameter" );
+ DBG_ASSERT(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode");
+
+ // Parameter Name-Regel gefunden?
+ if (SQL_ISRULE(pParseNode,parameter))
+ {
+ DBG_ASSERT(pParseNode->count() >= 1,"OResultSet: Parse Tree fehlerhaft");
+ DBG_ASSERT(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Parse Tree fehlerhaft");
+
+ _rParaNodes.push_back(pParseNode);
+ // Weiterer Abstieg nicht erforderlich
+ return;
+ }
+
+ // Weiter absteigen im Parse Tree
+ for (UINT32 i = 0; i < pParseNode->count(); i++)
+ scanParameter(pParseNode->getChild(i),_rParaNodes);
+}
+// -----------------------------------------------------------------------------
+OKeyValue* OResultSet::GetOrderbyKeyValue(OValueRefRow& _rRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::GetOrderbyKeyValue" );
+ UINT32 nBookmarkValue = Abs((sal_Int32)(_rRow->get())[0]->getValue());
+
+ OKeyValue* pKeyValue = OKeyValue::createKeyValue((UINT32)nBookmarkValue);
+
+ ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
+ for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
+ {
+ OSL_ENSURE(*aIter < static_cast<sal_Int32>(_rRow->get().size()),"Invalid index for orderkey values!");
+ pKeyValue->pushKey(new ORowSetValueDecorator((_rRow->get())[*aIter]->getValue()));
+ }
+
+ return pKeyValue;
+}
+// -----------------------------------------------------------------------------
+
+
+
+
+
+
+
+
diff --git a/connectivity/source/drivers/file/FNumericFunctions.cxx b/connectivity/source/drivers/file/FNumericFunctions.cxx
new file mode 100644
index 000000000000..ea5848132ecb
--- /dev/null
+++ b/connectivity/source/drivers/file/FNumericFunctions.cxx
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <cmath>
+#include "file/FNumericFunctions.hxx"
+#include <rtl/math.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_Abs::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ if ( nVal < 0 )
+ nVal *= -1.0;
+ return fabs(nVal);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Sign::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ sal_Int32 nRet = 0;
+ double nVal(lhs);
+ if ( nVal < 0 )
+ nRet = -1;
+ else if ( nVal > 0 )
+ nRet = 1;
+
+ return nRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Mod::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return ORowSetValue();
+
+ return fmod((double)lhs,(double)rhs);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Floor::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return floor((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Ceiling::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ return ceil(nVal);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Round::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+
+ size_t nSize = lhs.size();
+ double nVal = lhs[nSize-1];
+
+ sal_Int32 nDec = 0;
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nDec = lhs[0];
+ return ::rtl::math::round(nVal,nDec);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Exp::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal(lhs);
+ return exp(nVal);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Ln::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ return lhs;
+
+ double nVal(lhs);
+ nVal = log(nVal);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Log::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ if ( lhs.empty() || lhs.size() > 2 )
+ return ORowSetValue();
+ size_t nSize = lhs.size();
+ double nVal = log( (double)lhs[nSize-1] );
+
+
+ if ( nSize == 2 && !lhs[0].isNull() )
+ nVal /= log((double)lhs[0]);
+
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Log10::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() || static_cast<double>(lhs) < 0.0 )
+ return lhs;
+
+ double nVal = log((double)lhs);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ nVal /= log(10.0);
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Pow::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ return pow((double)lhs,(double)rhs);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Sqrt::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nVal = sqrt((double)lhs);
+ if ( rtl::math::isNan(nVal) )
+ return ORowSetValue();
+ return nVal;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Pi::operate(const ::std::vector<ORowSetValue>& /*lhs*/) const
+{
+ return 3.141592653589793116;
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Cos::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return cos((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Sin::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return sin((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Tan::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return tan((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ACos::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return acos((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ASin::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return asin((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ATan::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ return atan((double)lhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_ATan2::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ return atan2((double)lhs,(double)rhs);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Degrees::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nLhs = lhs;
+ return nLhs*180*(1.0/3.141592653589793116);
+}
+// -----------------------------------------------------------------------------
+ORowSetValue OOp_Radians::operate(const ORowSetValue& lhs) const
+{
+ if ( lhs.isNull() )
+ return lhs;
+
+ double nLhs = lhs;
+ return nLhs*3.141592653589793116*(1.0/180.0);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FPreparedStatement.cxx b/connectivity/source/drivers/file/FPreparedStatement.cxx
new file mode 100644
index 000000000000..68e23360331b
--- /dev/null
+++ b/connectivity/source/drivers/file/FPreparedStatement.cxx
@@ -0,0 +1,634 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <osl/diagnose.h>
+#include "file/FPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "file/FResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "connectivity/PColumn.hxx"
+#include "diagnose_ex.h"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <tools/debug.hxx>
+#include "resource/file_res.hrc"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace comphelper;
+using namespace ::dbtools;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbc.driver.file.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+DBG_NAME( file_OPreparedStatement )
+// -------------------------------------------------------------------------
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection)
+ : OStatement_BASE2( _pConnection )
+ ,m_pResultSet(NULL)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::OPreparedStatement" );
+ DBG_CTOR( file_OPreparedStatement, NULL );
+}
+
+// -------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::~OPreparedStatement" );
+ DBG_DTOR( file_OPreparedStatement, NULL );
+}
+
+// -------------------------------------------------------------------------
+void OPreparedStatement::disposing()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::disposing" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ clearMyResultSet();
+ OStatement_BASE2::disposing();
+
+ if(m_pResultSet)
+ {
+ m_pResultSet->release();
+ m_pResultSet = NULL;
+ }
+
+ m_xParamColumns = NULL;
+ m_xMetaData.clear();
+ if(m_aParameterRow.isValid())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+
+
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::construct" );
+ OStatement_Base::construct(sql);
+
+ m_aParameterRow = new OValueRefVector();
+ m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) );
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+
+ if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT )
+ m_xParamColumns = m_aSQLIterator.getParameters();
+ else
+ {
+ m_xParamColumns = new OSQLColumns();
+ // describe all parameters need for the resultset
+ describeParameter();
+ }
+
+ OValueRefRow aTemp;
+ OResultSet::setBoundedColumns(m_aEvaluateRow,aTemp,m_xParamColumns,xNames,sal_False,m_xDBMetaData,m_aColMapping);
+
+ m_pResultSet = createResultSet();
+ m_pResultSet->acquire();
+ m_xResultSet = Reference<XResultSet>(m_pResultSet);
+ initializeResultSet(m_pResultSet);
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::queryInterface" );
+ Any aRet = OStatement_BASE2::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
+ static_cast< XPreparedStatement*>(this),
+ static_cast< XParameters*>(this),
+ static_cast< XResultSetMetaDataSupplier*>(this));
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getTypes" );
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_aSQLIterator.getSelectColumns(),m_aSQLIterator.getTables().begin()->first,m_pTable);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::close" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearMyResultSet();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::execute" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ initResultSet();
+
+ return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeUpdate" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ initResultSet();
+
+ return m_pResultSet ? m_pResultSet->getRowCountResult() : sal_Int32(0);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setString" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::getConnection" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::executeQuery" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return initResultSet();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBoolean" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setByte" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDate" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aData));
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTime" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aVal));
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setTimestamp" );
+ setParameter(parameterIndex,DBTypeConversion::toDouble(aVal));
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setDouble" );
+ setParameter(parameterIndex,x);
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setFloat" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setInt" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setLong" );
+ throwFeatureNotImplementedException( "XParameters::setLong", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setNull" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ if ( m_aAssignValues.isValid() )
+ (m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]]->setNull();
+ else
+ (m_aParameterRow->get())[parameterIndex]->setNull();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setClob" );
+ throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBlob" );
+ throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setArray" );
+ throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setRef" );
+ throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectWithInfo" );
+ switch(sqlType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ setString(parameterIndex,::comphelper::getString(x));
+ break;
+ default:
+ ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale);
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObjectNull" );
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setObject" );
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ // setObject (parameterIndex, x, sqlType, 0);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setShort" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBytes" );
+ setParameter(parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setCharacterStream" );
+ setBinaryStream(parameterIndex,x,length );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setBinaryStream" );
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ setParameter(parameterIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::clearParameters" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_aParameterRow->get().clear();
+ m_aParameterRow->get().push_back(new ORowSetValueDecorator(sal_Int32(0)) );
+}
+// -------------------------------------------------------------------------
+OResultSet* OPreparedStatement::createResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::createResultSet" );
+ return new OResultSet(this,m_aSQLIterator);
+}
+// -----------------------------------------------------------------------------
+Reference<XResultSet> OPreparedStatement::initResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initResultSet" );
+ m_pResultSet->clear();
+ Reference<XResultSet> xRs(m_pResultSet);
+
+ // check if we got enough paramters
+ if ( (m_aParameterRow.isValid() && ( m_aParameterRow->get().size() -1 ) < m_xParamColumns->get().size()) ||
+ (m_xParamColumns.isValid() && !m_aParameterRow.isValid() && !m_aParameterRow->get().empty()) )
+ m_pConnection->throwGenericSQLException(STR_INVALID_PARA_COUNT,*this);
+
+ m_pResultSet->OpenImpl();
+ m_pResultSet->setMetaData(getMetaData());
+
+ return xRs;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::checkAndResizeParameters" );
+ ::connectivity::checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ if ( m_aAssignValues.isValid() && (parameterIndex < 1 || parameterIndex >= static_cast<sal_Int32>(m_aParameterIndexes.size())) )
+ throwInvalidIndexException(*this);
+ else if ( static_cast<sal_Int32>((m_aParameterRow->get()).size()) <= parameterIndex )
+ {
+ sal_Int32 i = m_aParameterRow->get().size();
+ (m_aParameterRow->get()).resize(parameterIndex+1);
+ for ( ;i <= parameterIndex+1; ++i )
+ {
+ if ( !(m_aParameterRow->get())[i].isValid() )
+ (m_aParameterRow->get())[i] = new ORowSetValueDecorator;
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const ORowSetValue& x)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::setParameter" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ if(m_aAssignValues.isValid())
+ *(m_aAssignValues->get())[m_aParameterIndexes[parameterIndex]] = x;
+ else
+ *((m_aParameterRow->get())[parameterIndex]) = x;
+}
+// -----------------------------------------------------------------------------
+UINT32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::AddParameter" );
+ OSL_UNUSED( pParameter );
+ OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter");
+ OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree");
+#if OSL_DEBUG_LEVEL > 0
+ OSQLParseNode * pMark = pParameter->getChild(0);
+ OSL_UNUSED( pMark );
+#endif
+
+ ::rtl::OUString sParameterName;
+ // Parameter-Column aufsetzen:
+ sal_Int32 eType = DataType::VARCHAR;
+ UINT32 nPrecision = 255;
+ sal_Int32 nScale = 0;
+ sal_Int32 nNullable = ColumnValue::NULLABLE;
+
+ if (_xCol.is())
+ {
+ // Typ, Precision, Scale ... der angegebenen Column verwenden,
+ // denn dieser Column wird der Wert zugewiesen bzw. mit dieser
+ // Column wird der Wert verglichen.
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= eType;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nPrecision;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)) >>= nScale;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNullable;
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName;
+ }
+
+ Reference<XPropertySet> xParaColumn = new connectivity::parse::OParseColumn(sParameterName
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,nNullable
+ ,nPrecision
+ ,nScale
+ ,eType
+ ,sal_False
+ ,sal_False
+ ,m_aSQLIterator.isCaseSensitive());
+ m_xParamColumns->get().push_back(xParaColumn);
+ return m_xParamColumns->get().size();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeColumn" );
+ Reference<XPropertySet> xProp;
+ if(SQL_ISRULE(_pNode,column_ref))
+ {
+ ::rtl::OUString sColumnName,sTableRange;
+ m_aSQLIterator.getColumnRange(_pNode,sColumnName,sTableRange);
+ if ( sColumnName.getLength() )
+ {
+ Reference<XNameAccess> xNameAccess = _xTable->getColumns();
+ if(xNameAccess->hasByName(sColumnName))
+ xNameAccess->getByName(sColumnName) >>= xProp;
+ AddParameter(_pParameter,xProp);
+ }
+ }
+ // else
+ // AddParameter(_pParameter,xProp);
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::describeParameter()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::describeParameter" );
+ ::std::vector< OSQLParseNode*> aParseNodes;
+ scanParameter(m_pParseTree,aParseNodes);
+ if ( !aParseNodes.empty() )
+ {
+ // m_xParamColumns = new OSQLColumns();
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+ if( !xTabs.empty() )
+ {
+ OSQLTable xTable = xTabs.begin()->second;
+ ::std::vector< OSQLParseNode*>::const_iterator aIter = aParseNodes.begin();
+ for (;aIter != aParseNodes.end();++aIter )
+ {
+ describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable);
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::initializeResultSet(OResultSet* _pResult)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::initializeResultSet" );
+ OStatement_Base::initializeResultSet(_pResult);
+
+ m_pResultSet->setParameterColumns(m_xParamColumns);
+ m_pResultSet->setParameterRow(m_aParameterRow);
+
+ // Parameter substituieren (AssignValues und Kriterien):
+ if (!m_xParamColumns->get().empty())
+ {
+ // Zunaechst AssignValues
+ USHORT nParaCount=0; // gibt die aktuelle Anzahl der bisher gesetzen Parameter an
+
+ // Nach zu substituierenden Parametern suchen:
+ size_t nCount = m_aAssignValues.isValid() ? m_aAssignValues->get().size() : 1; // 1 ist wichtig fuer die Kriterien
+ for (size_t j = 1; j < nCount; j++)
+ {
+ UINT32 nParameter = (*m_aAssignValues).getParameterIndex(j);
+ if (nParameter == SQL_NO_PARAMETER)
+ continue; // dieser AssignValue ist kein Parameter
+
+ ++nParaCount; // ab hier ist der Parameter gueltig
+ // Parameter ersetzen. Wenn Parameter nicht verfuegbar,
+ // Value auf NULL setzen.
+ // (*m_aAssignValues)[j] = (*m_aParameterRow)[(UINT16)nParameter];
+ }
+
+ if (m_aParameterRow.isValid() && (m_xParamColumns->get().size()+1) != m_aParameterRow->get().size() )
+ {
+ sal_Int32 i = m_aParameterRow->get().size();
+ sal_Int32 nParamColumns = m_xParamColumns->get().size()+1;
+ m_aParameterRow->get().resize(nParamColumns);
+ for ( ;i < nParamColumns; ++i )
+ {
+ if ( !(m_aParameterRow->get())[i].isValid() )
+ (m_aParameterRow->get())[i] = new ORowSetValueDecorator;
+ }
+ //m_aParameterRow->resize(m_xParamColumns->size()+1);
+ }
+ if (m_aParameterRow.isValid() && nParaCount < m_aParameterRow->get().size() )
+ {
+
+ m_pSQLAnalyzer->bindParameterRow(m_aParameterRow);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::parseParamterElem(const String& _sColumnName,OSQLParseNode* pRow_Value_Constructor_Elem)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OPreparedStatement::parseParamterElem" );
+ Reference<XPropertySet> xCol;
+ m_xColNames->getByName(_sColumnName) >>= xCol;
+ sal_Int32 nParameter = -1;
+ if(m_xParamColumns.isValid())
+ {
+ OSQLColumns::Vector::const_iterator aIter = find(m_xParamColumns->get().begin(),m_xParamColumns->get().end(),_sColumnName,::comphelper::UStringMixEqual(m_pTable->isCaseSensitive()));
+ if(aIter != m_xParamColumns->get().end())
+ nParameter = m_xParamColumns->get().size() - (m_xParamColumns->get().end() - aIter) + 1;// +1 because the rows start at 1
+ }
+ if(nParameter == -1)
+ nParameter = AddParameter(pRow_Value_Constructor_Elem,xCol);
+ // Nr. des Parameters in der Variablen merken:
+ SetAssignValue(_sColumnName, String(), TRUE, nParameter);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/FResultSet.cxx b/connectivity/source/drivers/file/FResultSet.cxx
new file mode 100644
index 000000000000..265084be697f
--- /dev/null
+++ b/connectivity/source/drivers/file/FResultSet.cxx
@@ -0,0 +1,1896 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <limits> // included here to prevent problems if compiling with C52
+
+#ifdef GCC
+#include <iostream>
+#endif
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "file/FResultSet.hxx"
+#include "file/FResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/container/XIndexAccess.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbconversion.hxx"
+#include "connectivity/dbtools.hxx"
+#include <cppuhelper/propshlp.hxx>
+#include <iterator>
+#include <tools/debug.hxx>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+
+#include <algorithm>
+#include <comphelper/extract.hxx>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/types.hxx>
+#include "resource/file_res.hrc"
+#include "resource/sharedresources.hxx"
+#include <rtl/logfile.hxx>
+
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace dbtools;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+
+// Maximale Anzahl von Rows, die mit ORDER BY sortiert durchlaufen werden koennen:
+#if defined (WIN)
+#define MAX_KEYSET_SIZE 0x3ff0 // Etwas weniger als ein Segment, damit
+ // noch Platz fuer Memory Debug-Informationen
+#else
+#define MAX_KEYSET_SIZE 0x40000 // 256K
+#endif
+
+namespace
+{
+ void lcl_throwError(sal_uInt16 _nErrorId,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xContext)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(_nErrorId);
+ ::dbtools::throwGenericSQLException(sMessage ,_xContext);
+ }
+}
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.drivers.file.ResultSet","com.sun.star.sdbc.ResultSet");
+DBG_NAME( file_OResultSet )
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(OStatement_Base* pStmt,OSQLParseTreeIterator& _aSQLIterator) : OResultSet_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(OResultSet_BASE::rBHelper)
+ ,m_aAssignValues(NULL)
+ ,m_pEvaluationKeySet(NULL)
+ ,m_aSkipDeletedSet(this)
+ ,m_pFileSet(NULL)
+ ,m_pSortIndex(NULL)
+ ,m_pTable(NULL)
+ ,m_pParseTree(pStmt->getParseTree())
+ ,m_pSQLAnalyzer(NULL)
+ ,m_aSQLIterator(_aSQLIterator)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_xStatement(*pStmt)
+ ,m_xMetaData(NULL)
+ ,m_xDBMetaData(pStmt->getOwnConnection()->getMetaData())
+ ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
+ ,m_nRowPos(-1)
+ ,m_nFilePos(0)
+ ,m_nLastVisitedPos(-1)
+ ,m_nRowCountResult(-1)
+ ,m_nCurrentPosition(0)
+ ,m_nColumnCount(0)
+ ,m_bWasNull(sal_False)
+ ,m_bEOF(sal_False)
+ ,m_bLastRecord(sal_False)
+ ,m_bInserted(sal_False)
+ ,m_bRowUpdated(sal_False)
+ ,m_bRowInserted(sal_False)
+ ,m_bRowDeleted(sal_False)
+ ,m_bShowDeleted(pStmt->getOwnConnection()->showDeleted())
+ ,m_bIsCount(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OResultSet" );
+ DBG_CTOR( file_OResultSet, NULL );
+ osl_incrementInterlockedCount( &m_refCount );
+ m_bIsCount = (m_pParseTree &&
+ m_pParseTree->count() > 2 &&
+ SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
+ m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
+ );
+
+ m_nResultSetConcurrency = isCount() ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
+ construct();
+ m_aSkipDeletedSet.SetDeleted(m_bShowDeleted);
+ osl_decrementInterlockedCount( &m_refCount );
+}
+
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::~OResultSet" );
+ osl_incrementInterlockedCount( &m_refCount );
+ disposing();
+ DBG_DTOR( file_OResultSet, NULL );
+}
+// -------------------------------------------------------------------------
+void OResultSet::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::construct" );
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, 0,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, PropertyAttribute::READONLY,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, 0,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY,PropertyAttribute::READONLY,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+}
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_xStatement.clear();
+ m_xMetaData.clear();
+ m_pParseTree = NULL;
+ m_xColNames.clear();
+ m_xColumns = NULL;
+ m_xParamColumns = NULL;
+ m_xColsIdx.clear();
+
+ Reference<XComponent> xComp = m_pTable;
+ if ( xComp.is() )
+ xComp->removeEventListener(this);
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+ clear();
+}
+// -----------------------------------------------------------------------------
+void OResultSet::clear()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clear" );
+ m_pFileSet = NULL;
+ DELETEZ(m_pSortIndex);
+
+ if(m_aInsertRow.isValid())
+ m_aInsertRow->get().clear();
+
+ m_aSkipDeletedSet.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::queryInterface" );
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTypes" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& OResultSet::getValue(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ //columnIndex = mapColumn(columnIndex);
+ checkIndex(columnIndex );
+
+
+ m_bWasNull = (m_aSelectRow->get())[columnIndex]->getValue().isNull();
+ return *(m_aSelectRow->get())[columnIndex];
+}
+// -----------------------------------------------------------------------------
+void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::checkIndex" );
+ if ( columnIndex <= 0
+ // || columnIndex > (sal_Int32)m_xColumns->size()
+ || columnIndex >= m_nColumnCount )
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBinaryStream" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getCharacterStream" );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBoolean" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getByte" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDouble" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getFloat" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInt" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ OSL_ENSURE((m_bShowDeleted || !m_aRow->isDeleted()),"getRow called for deleted row");
+
+ return m_aSkipDeletedSet.getMappedPosition((m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getLong" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_xColumns,m_aSQLIterator.getTables().begin()->first,m_pTable);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getArray" );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getClob" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getBlob" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getRef" );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
+ return getValue(columnIndex).makeAny();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getShort" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getString" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::util::DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
+ return getValue(columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isAfterLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == sal_Int32(m_pFileSet->get().size());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == sal_Int32(m_pFileSet->get().size() - 1);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(first())
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::close" );
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::first" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::FIRST,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::last" );
+ // here I know definitely that I stand on the last record
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::ABSOLUTE,row,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::relative" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::RELATIVE,row,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::previous" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::PRIOR,0,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getStatement" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowDeleted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowInserted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bRowUpdated;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isBeforeFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_nRowPos == -1;
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::evaluate()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::evaluate" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::evaluate: Analyzer isn't set!");
+ sal_Bool bRet = sal_True;
+ while(!m_pSQLAnalyzer->evaluateRestriction())
+ {
+ if(m_pEvaluationKeySet)
+ {
+ if(m_aEvaluateIter == m_pEvaluationKeySet->end())
+ return sal_False;
+ bRet = m_pTable->seekRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),m_nRowPos);
+ ++m_aEvaluateIter;
+ }
+ else
+ bRet = m_pTable->seekRow(IResultSetHelper::NEXT,1,m_nRowPos);
+ if(bRet)
+ {
+ if(m_pEvaluationKeySet)
+ {
+ bRet = m_pTable->fetchRow(m_aEvaluateRow,m_pTable->getTableColumns().getBody(),sal_True,sal_True);
+ evaluate();
+
+ }
+ else
+ bRet = m_pTable->fetchRow(m_aRow,m_xColumns.getBody(),sal_False,sal_True);
+ }
+ }
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::next" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_pTable ? m_aSkipDeletedSet.skipDeleted(IResultSetHelper::NEXT,1,sal_True) : sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancel" );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearWarnings" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getWarnings" );
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_bInserted || !m_pTable)
+ throwFunctionSequenceException(*this);
+
+ // we know that we append new rows at the end
+ // so we have to know where the end is
+ m_aSkipDeletedSet.skipDeleted(IResultSetHelper::LAST,1,sal_False);
+ m_bRowInserted = m_pTable->InsertRow(m_aInsertRow.getBody(), TRUE,m_xColsIdx);
+ if(m_bRowInserted && m_pFileSet.isValid())
+ {
+ sal_Int32 nPos = (m_aInsertRow->get())[0]->getValue();
+ m_pFileSet->get().push_back(nPos);
+ *(m_aInsertRow->get())[0] = sal_Int32(m_pFileSet->get().size());
+ clearInsertRow();
+
+ m_aSkipDeletedSet.insertNewPosition((m_aRow->get())[0]->getValue());
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+
+ m_bRowUpdated = m_pTable->UpdateRow(m_aInsertRow.getBody(), m_aRow,m_xColsIdx);
+ *(m_aInsertRow->get())[0] = (sal_Int32)(m_aRow->get())[0]->getValue();
+
+ clearInsertRow();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+ if (m_bShowDeleted)
+ lcl_throwError(STR_DELETE_ROW,*this);
+ if(m_aRow->isDeleted())
+ lcl_throwError(STR_ROW_ALREADY_DELETED,*this);
+
+ sal_Int32 nPos = (sal_Int32)(m_aRow->get())[0]->getValue();
+ m_bRowDeleted = m_pTable->DeleteRow(m_xColumns.getBody());
+ if(m_bRowDeleted && m_pFileSet.isValid())
+ {
+ m_aRow->setDeleted(sal_True);
+ // don't touch the m_pFileSet member here
+ m_aSkipDeletedSet.deletePosition(nPos);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::cancelRowUpdates" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bInserted = sal_False;
+ m_bRowUpdated = sal_False;
+ m_bRowInserted = sal_False;
+ m_bRowDeleted = sal_False;
+
+ if(m_aInsertRow.isValid())
+ {
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
+ for(;aIter != m_aInsertRow->get().end();++aIter)
+ {
+ (*aIter)->setBound(sal_False);
+ (*aIter)->setNull();
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!m_pTable || m_pTable->isReadOnly())
+ lcl_throwError(STR_TABLE_READONLY,*this);
+
+ m_bInserted = sal_True;
+
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin()+1;
+ for(;aIter != m_aInsertRow->get().end();++aIter)
+ {
+ (*aIter)->setBound(sal_False);
+ (*aIter)->setNull();
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::moveToCurrentRow" );
+}
+// -------------------------------------------------------------------------
+void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aInsertRow->get())[columnIndex]->setBound(sal_True);
+ *(m_aInsertRow->get())[columnIndex] = x;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNull" );
+ ORowSetValue aEmpty;
+ updateValue(columnIndex,aEmpty);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBoolean" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateByte" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateShort" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateInt" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateLong" );
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateFloat" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDouble" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateString" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBytes" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateDate" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTime" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateTimestamp" );
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateBinaryStream" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateValue(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateCharacterStream" );
+ updateBinaryStream(columnIndex,x,length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateObject" );
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::updateNumericObject" );
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getInfoHelper" );
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+
+//------------------------------------------------------------------
+BOOL OResultSet::ExecuteRow(IResultSetHelper::Movement eFirstCursorPosition,
+ INT32 nFirstOffset,
+ BOOL bEvaluate,
+ BOOL bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::ExecuteRow" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::ExecuteRow: Analyzer isn't set!");
+
+ // Fuer weitere Fetch-Operationen werden diese Angaben ggf. veraendert ...
+ IResultSetHelper::Movement eCursorPosition = eFirstCursorPosition;
+ INT32 nOffset = nFirstOffset;
+
+ const OSQLColumns & rTableCols = m_pTable->getTableColumns().getBody();
+ BOOL bHasRestriction = m_pSQLAnalyzer->hasRestriction();
+again:
+
+ // protect from reading over the end when someboby is inserting while we are reading
+ // this method works only for dBase at the moment !!!!
+ if (eCursorPosition == IResultSetHelper::NEXT && m_nFilePos == m_nLastVisitedPos)
+ {
+ return sal_False;
+ }
+
+ if (!m_pTable || !m_pTable->seekRow(eCursorPosition, nOffset, m_nFilePos))
+ {
+ return sal_False;
+ }
+
+ if (!bEvaluate) // Laeuft keine Auswertung, dann nur Ergebniszeile fuellen
+ {
+ m_pTable->fetchRow(m_aRow,rTableCols, sal_True,bRetrieveData);
+ }
+ else
+ {
+ m_pTable->fetchRow(m_aEvaluateRow, rTableCols, sal_True,bRetrieveData || bHasRestriction);
+
+ if ( (!m_bShowDeleted && m_aEvaluateRow->isDeleted())
+ || (bHasRestriction && //!bShowDeleted && m_aEvaluateRow->isDeleted() ||// keine Anzeige von geloeschten Saetzen
+ !m_pSQLAnalyzer->evaluateRestriction())) // Auswerten der Bedingungen
+ { // naechsten Satz auswerten
+ // aktuelle Zeile loeschen im Keyset
+ if (m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ if (m_pEvaluationKeySet->end() != m_aEvaluateIter)
+ nOffset = (*m_aEvaluateIter);
+ else
+ {
+ return sal_False;
+ }
+ }
+ else if (m_pFileSet.isValid())
+ {
+ OSL_ENSURE(//!m_pFileSet->IsFrozen() &&
+ eCursorPosition == IResultSetHelper::NEXT, "Falsche CursorPosition!");
+ eCursorPosition = IResultSetHelper::NEXT;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::FIRST ||
+ eCursorPosition == IResultSetHelper::NEXT ||
+ eCursorPosition == IResultSetHelper::ABSOLUTE)
+ {
+ eCursorPosition = IResultSetHelper::NEXT;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::LAST ||
+ eCursorPosition == IResultSetHelper::PRIOR)
+ {
+ eCursorPosition = IResultSetHelper::PRIOR;
+ nOffset = 1;
+ }
+ else if (eCursorPosition == IResultSetHelper::RELATIVE)
+ {
+ eCursorPosition = (nOffset >= 0) ? IResultSetHelper::NEXT : IResultSetHelper::PRIOR;
+ }
+ else
+ {
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ return sal_False;
+ }
+ // Nochmal probieren ...
+ goto again;
+ }
+ }
+
+ // Evaluate darf nur gesetzt sein,
+ // wenn der Keyset weiter aufgebaut werden soll
+ if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && !isCount() &&
+ (m_pFileSet.isValid() || m_pSortIndex) && bEvaluate)
+ {
+ if (m_pSortIndex)
+ {
+ OKeyValue* pKeyValue = GetOrderbyKeyValue(m_aEvaluateRow);
+ m_pSortIndex->AddKeyValue(pKeyValue);
+ }
+ else if (m_pFileSet.isValid())
+ {
+ // OSL_ENSURE(!m_pFileSet->IsFrozen() , "Falsche CursorPosition!");
+ sal_uInt32 nBookmarkValue = Abs((sal_Int32)(m_aEvaluateRow->get())[0]->getValue());
+ m_pFileSet->get().push_back(nBookmarkValue);
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_UPDATE)
+ {
+ sal_Bool bOK = sal_True;
+ if (bEvaluate)
+ {
+ // jetzt die eigentliche Ergebniszeile Lesen
+ bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,TRUE);
+ }
+
+ if (bOK)
+ {
+ // Nur die zu aendernden Werte uebergeben:
+ if(!m_pTable->UpdateRow(m_aAssignValues.getBody(),m_aEvaluateRow,m_xColsIdx))
+ return sal_False;
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_DELETE)
+ {
+ sal_Bool bOK = sal_True;
+ if (bEvaluate)
+ {
+ bOK = m_pTable->fetchRow(m_aEvaluateRow, m_pTable->getTableColumns().getBody(), sal_True,TRUE);
+ }
+ if (bOK)
+ {
+ if(!m_pTable->DeleteRow(m_xColumns.getBody()))
+ return sal_False;
+ }
+ }
+ return sal_True;
+}
+
+//-------------------------------------------------------------------
+BOOL OResultSet::Move(IResultSetHelper::Movement eCursorPosition, INT32 nOffset, BOOL bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::Move" );
+
+//IgnoreDeletedRows:
+//
+ INT32 nTempPos = m_nRowPos;
+ // exclusiver zugriff auf die Tabelle
+ // NAMESPACE_VOS(OGuard)* pGuard = m_pTable->Lock();
+
+ if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT &&
+ !isCount())
+ {
+ if (!m_pFileSet.isValid()) // kein Index verfuegbar
+ {
+ // Normales FETCH
+ ExecuteRow(eCursorPosition,nOffset,FALSE,bRetrieveData);
+
+ // now set the bookmark for outside this is the logical pos and not the file pos
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+ }
+ else
+ {
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nRowPos;
+ break;
+ case IResultSetHelper::PRIOR:
+ if (m_nRowPos >= 0)
+ --m_nRowPos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ // OSL_ENSURE(IsRowCountFinal(), "Fehler im Keyset!"); // muss eingefroren sein, sonst Fehler beim SQLCursor
+ m_nRowPos = m_pFileSet->get().size() - 1;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nRowPos += nOffset;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ if ( m_nRowPos == (nOffset -1) )
+ return sal_True;
+ m_nRowPos = nOffset -1;
+ break;
+ }
+
+ // OffRange?
+ // Der FileCursor ist ausserhalb des gueltigen Bereichs, wenn
+ // a.) m_nRowPos < 1
+ // b.) Ein KeySet besteht und m_nRowPos > m_pFileSet->size()
+ if (m_nRowPos < 0 || (m_pFileSet->isFrozen() && eCursorPosition != IResultSetHelper::BOOKMARK && m_nRowPos >= (INT32)m_pFileSet->get().size() )) // && m_pFileSet->IsFrozen()
+ {
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ goto Error;
+ }
+ else
+ {
+ if (m_nRowPos < (INT32)m_pFileSet->get().size())
+ {
+ // Fetch ueber Index
+ ExecuteRow(IResultSetHelper::BOOKMARK,(m_pFileSet->get())[m_nRowPos],FALSE,bRetrieveData);
+
+ // now set the bookmark for outside
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+ if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
+ {
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ }
+ }
+ else // Index muss weiter aufgebaut werden
+ {
+ // Zunaechst auf die letzte bekannte Zeile setzen
+ if (!m_pFileSet->get().empty())
+ {
+ m_aFileSetIter = m_pFileSet->get().end()-1;
+ // m_pFileSet->SeekPos(m_pFileSet->size()-1);
+ m_pTable->seekRow(IResultSetHelper::BOOKMARK, *m_aFileSetIter, m_nFilePos);
+ }
+ sal_Bool bOK = sal_True;
+ // Ermitteln der Anzahl weiterer Fetches
+ while (bOK && m_nRowPos >= (INT32)m_pFileSet->get().size())
+ {
+ if (m_pEvaluationKeySet)
+ {
+ if (m_nRowPos >= (INT32)m_pEvaluationKeySet->size())
+ return sal_False;
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ else if (m_nRowPos == 0)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,TRUE, bRetrieveData);
+ }
+ else
+ {
+ ++m_aEvaluateIter;
+ bOK = ExecuteRow(IResultSetHelper::BOOKMARK,*m_aEvaluateIter,TRUE, bRetrieveData);
+ }
+ }
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE, FALSE);//bRetrieveData);
+ }
+
+ if (bOK)
+ {
+ // jetzt nochmal die Ergebnisse lesen
+ m_pTable->fetchRow(m_aRow, m_pTable->getTableColumns().getBody(), sal_True,bRetrieveData);
+
+ // now set the bookmark for outside
+ *(*m_aRow->get().begin()) = sal_Int32(m_nRowPos + 1);
+
+ if ( (bRetrieveData || m_pSQLAnalyzer->hasRestriction()) && m_pSQLAnalyzer->hasFunctions() )
+ {
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ }
+ }
+ else if (!m_pFileSet->isFrozen()) // keinen gueltigen Satz gefunden
+ {
+ //m_pFileSet->Freeze();
+ m_pFileSet->setFrozen();
+
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ // aStatus.Set(SQL_STAT_NO_DATA_FOUND);
+ goto Error;
+ }
+ }
+ }
+ }
+ }
+ else if (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT && isCount())
+ {
+ // Fetch des COUNT(*)
+ switch (eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nRowPos;
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::LAST:
+ m_nRowPos = 0;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nRowPos += nOffset;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK:
+ m_nRowPos = nOffset - 1;
+ break;
+ }
+
+ if (m_nRowPos == 0)
+ {
+ // COUNT(*) in Ergebnisrow packen
+ // (muss die erste und einzige Variable in der Row sein)
+ if (m_aRow->get().size() >= 2)
+ {
+ *(m_aRow->get())[1] = m_nRowCountResult;
+ *(m_aRow->get())[0] = sal_Int32(1);
+ (m_aRow->get())[1]->setBound(sal_True);
+ (m_aSelectRow->get())[1] = (m_aRow->get())[1];
+ }
+ }
+ else
+ {
+ m_bEOF = sal_True;
+ m_nRowPos = 1;
+ return sal_False;
+ }
+ }
+ else
+ // Fetch nur bei SELECT moeglich!
+ return sal_False;
+
+ return sal_True;
+
+Error:
+ // steht der Cursor vor dem ersten Satz
+ // dann wird die position beibehalten
+ if (nTempPos == -1)
+ m_nRowPos = nTempPos;
+ else
+ {
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::PRIOR:
+ case IResultSetHelper::FIRST:
+ m_nRowPos = -1;
+ break;
+ case IResultSetHelper::LAST:
+ case IResultSetHelper::NEXT:
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::RELATIVE:
+ if (nOffset > 0)
+ m_nRowPos = m_pFileSet.isValid() ? (sal_Int32)m_pFileSet->get().size() : -1;
+ else if (nOffset < 0)
+ m_nRowPos = -1;
+ break;
+ case IResultSetHelper::BOOKMARK:
+ m_nRowPos = nTempPos; // vorherige Position
+ }
+ }
+ // delete pGuard;
+ // rMode = (!bShowDeleted && aStatus.IsSuccessful() && m_aRow->isDeleted()) ? // keine Anzeige von geloeschten Saetzen
+ // OCursor::SQL_MOD_INVALID : OCursor::SQL_MOD_NONE;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::sortRows()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::sortRows" );
+ if (!m_pSQLAnalyzer->hasRestriction() && m_aOrderbyColumnNumber.size() == 1)
+ {
+ // Ist nur ein Feld fuer die Sortierung angegeben
+ // Und diese Feld ist indiziert, dann den Index ausnutzen
+ Reference<XIndexesSupplier> xIndexSup;
+ m_pTable->queryInterface(::getCppuType((const Reference<XIndexesSupplier>*)0)) >>= xIndexSup;
+ // Reference<XIndexesSupplier> xIndexSup(m_pTable,UNO_QUERY);
+ Reference<XIndexAccess> xIndexes;
+ if(xIndexSup.is())
+ {
+ xIndexes.set(xIndexSup->getIndexes(),UNO_QUERY);
+ Reference<XPropertySet> xColProp;
+ if(m_aOrderbyColumnNumber[0] < xIndexes->getCount())
+ {
+ xColProp.set(xIndexes->getByIndex(m_aOrderbyColumnNumber[0]),UNO_QUERY);
+ // iterate through the indexes to find the matching column
+ const sal_Int32 nCount = xIndexes->getCount();
+ for(sal_Int32 i=0; i < nCount;++i)
+ {
+ Reference<XColumnsSupplier> xIndex(xIndexes->getByIndex(i),UNO_QUERY);
+ Reference<XNameAccess> xIndexCols = xIndex->getColumns();
+ if(xIndexCols->hasByName(comphelper::getString(xColProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)))))
+ {
+ m_pFileSet = new OKeySet();
+
+ if(fillIndexValues(xIndex))
+ return;
+ }
+ }
+ }
+ }
+ }
+
+ OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
+ ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
+ for (::std::vector<sal_Int16>::size_type i=0;aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
+ {
+ OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
+ switch ((*(m_aRow->get().begin()+*aOrderByIter))->getValue().getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ eKeyType[i] = SQL_ORDERBYKEY_STRING;
+ break;
+
+ case DataType::OTHER:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
+ break;
+
+ // Andere Typen sind nicht implementiert (und damit immer FALSE)
+ default:
+ eKeyType[i] = SQL_ORDERBYKEY_NONE;
+ OSL_ASSERT("OFILECursor::Execute: Datentyp nicht implementiert");
+ break;
+ }
+ (m_aEvaluateRow->get())[*aOrderByIter]->setBound(sal_True);
+ }
+
+ m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+
+ while (m_aEvaluateIter != m_pEvaluationKeySet->end())
+ {
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ ++m_aEvaluateIter;
+ }
+ }
+ else
+ {
+ while (ExecuteRow(IResultSetHelper::NEXT,1,TRUE))
+ {
+ }
+ }
+
+ // Sortiertes Keyset erzeugen
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ m_pFileSet = NULL;
+ m_pFileSet = m_pSortIndex->CreateKeySet();
+ // if(!bDistinct)
+ // SetRowCount(pFileSet->count());
+ DELETEZ(m_pSortIndex);
+ // Nun kann ueber den Index sortiert zugegriffen werden.
+}
+
+
+// -------------------------------------------------------------------------
+BOOL OResultSet::OpenImpl()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::OpenImpl" );
+ OSL_ENSURE(m_pSQLAnalyzer,"No analyzer set with setSqlAnalyzer!");
+ if(!m_pTable)
+ {
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+ if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
+ lcl_throwError(STR_QUERY_TOO_COMPLEX,*this);
+
+ if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
+ lcl_throwError(STR_QUERY_MORE_TABLES,*this);
+
+ OSQLTable xTable = xTabs.begin()->second;
+ m_xColumns = m_aSQLIterator.getSelectColumns();
+
+ m_xColNames = xTable->getColumns();
+ m_xColsIdx.set(m_xColNames,UNO_QUERY);
+ doTableSpecials(xTable);
+ Reference<XComponent> xComp(xTable,UNO_QUERY);
+ if(xComp.is())
+ xComp->addEventListener(this);
+ }
+
+ m_pTable->refreshHeader();
+
+ sal_Int32 nColumnCount = m_xColsIdx->getCount();
+
+ initializeRow(m_aRow,nColumnCount);
+ initializeRow(m_aEvaluateRow,nColumnCount);
+ initializeRow(m_aInsertRow,nColumnCount);
+
+
+ m_nResultSetConcurrency = (m_pTable->isReadOnly() || isCount()) ? ResultSetConcurrency::READ_ONLY : ResultSetConcurrency::UPDATABLE;
+
+ // Neuen Index aufbauen:
+ m_pFileSet = NULL;
+ // DELETEZ(m_pEvaluationKeySet);
+
+ // An den Anfang positionieren
+ m_nRowPos = -1;
+ m_nFilePos = 0;
+ m_nRowCountResult = -1;
+
+ // exclusiver zugriff auf die Tabelle
+ // NAMESPACE_VOS(OGuard)* pGuard = pTable->Lock();
+ m_nLastVisitedPos = m_pTable->getCurrentLastPos();
+
+ switch(m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ if(isCount())
+ {
+ if(m_xColumns->get().size() > 1)
+ lcl_throwError(STR_QUERY_COMPLEX_COUNT,*this);
+
+ m_nRowCountResult = 0;
+ // Vorlaeufig einfach ueber alle Datensaetze iterieren und
+ // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen):
+ {
+ sal_Bool bOK = sal_True;
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+
+ }
+ while (bOK)
+ {
+ if (m_pEvaluationKeySet)
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE);
+
+ if (bOK)
+ {
+ m_nRowCountResult++;
+ if(m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+ }
+ }
+ }
+
+ // Ergebnis von COUNT(*) in m_nRowCountResult merken.
+ // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser
+ // Anfrage = 1!
+ m_pEvaluationKeySet = NULL;
+ // DELETEZ(m_pEvaluationKeySet);
+ }
+ }
+ else
+ {
+ BOOL bDistinct = FALSE;
+ BOOL bWasSorted = FALSE;
+ OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
+ ::std::vector<sal_Int32> aOrderbyColumnNumberSave;
+ ::std::vector<TAscendingOrder> aOrderbyAscendingSave;
+
+ if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT )
+ {
+ // Sort on all columns, saving original order for later
+ if(IsSorted())
+ {
+ aOrderbyColumnNumberSave = m_aOrderbyColumnNumber;// .assign(m_aOrderbyColumnNumber.begin(), m_aOrderbyColumnNumber.end());
+ m_aOrderbyColumnNumber.clear();
+ aOrderbyAscendingSave.assign(m_aOrderbyAscending.begin(), m_aOrderbyAscending.end());
+ bWasSorted = TRUE;
+ }
+
+ // the first column is the bookmark column
+ ::std::vector<sal_Int32>::iterator aColStart = (m_aColMapping.begin()+1);
+ ::std::copy(aColStart, m_aColMapping.end(),::std::back_inserter(m_aOrderbyColumnNumber));
+// m_aOrderbyColumnNumber.assign(aColStart, m_aColMapping.end());
+ m_aOrderbyAscending.assign(m_aColMapping.size()-1, SQL_ASC);
+ bDistinct = TRUE;
+ }
+
+ if (IsSorted())
+ sortRows();
+
+ if (!m_pFileSet.isValid())
+ {
+ m_pFileSet = new OKeySet();
+
+ if (!m_pSQLAnalyzer->hasRestriction())
+ // jetzt kann das Keyset schon gefuellt werden!
+ // Aber Achtung: es wird davon ausgegangen, das die FilePositionen als Folge 1..n
+ // abgelegt werden!
+ {
+ if ( m_nLastVisitedPos > 0)
+ m_pFileSet->get().reserve( m_nLastVisitedPos );
+ for (sal_Int32 i = 0; i < m_nLastVisitedPos; i++)
+ m_pFileSet->get().push_back(i + 1);
+ }
+ }
+ OSL_ENSURE(m_pFileSet.isValid(),"Kein KeySet vorhanden! :-(");
+
+ if(bDistinct && m_pFileSet.isValid()) // sicher ist sicher
+ {
+ OValueRow aSearchRow = new OValueVector(m_aRow->get().size());
+ OValueRefVector::Vector::iterator aRowIter = m_aRow->get().begin();
+ OValueVector::Vector::iterator aSearchIter = aSearchRow->get().begin();
+ for ( ++aRowIter,++aSearchIter; // the first column is the bookmark column
+ aRowIter != m_aRow->get().end();
+ ++aRowIter,++aSearchIter)
+ aSearchIter->setBound((*aRowIter)->isBound());
+
+ size_t nMaxRow = m_pFileSet->get().size();
+
+ if (nMaxRow)
+ {
+ #if OSL_DEBUG_LEVEL > 1
+ INT32 nFound=0;
+ #endif
+ INT32 nPos;
+ INT32 nKey;
+
+ for( size_t j = nMaxRow-1; j > 0; --j)
+ {
+ nPos = (m_pFileSet->get())[j];
+ ExecuteRow(IResultSetHelper::BOOKMARK,nPos,FALSE);
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ { // copy row values
+ OValueRefVector::Vector::iterator copyFrom = m_aSelectRow->get().begin();
+ OValueVector::Vector::iterator copyTo = aSearchRow->get().begin();
+ for ( ++copyFrom,++copyTo; // the first column is the bookmark column
+ copyFrom != m_aSelectRow->get().end();
+ ++copyFrom,++copyTo)
+ *copyTo = *(*copyFrom);
+ // *aSearchRow = *m_aRow;
+ }
+
+ // compare with next row
+ nKey = (m_pFileSet->get())[j-1];
+ ExecuteRow(IResultSetHelper::BOOKMARK,nKey,FALSE);
+ m_pSQLAnalyzer->setSelectionEvaluationResult(m_aSelectRow,m_aColMapping);
+ OValueRefVector::Vector::iterator loopInRow = m_aSelectRow->get().begin();
+ OValueVector::Vector::iterator existentInSearchRow = aSearchRow->get().begin();
+ for ( ++loopInRow,++existentInSearchRow; // the first column is the bookmark column
+ loopInRow != m_aSelectRow->get().end();
+ ++loopInRow,++existentInSearchRow)
+ {
+ if ( (*loopInRow)->isBound() && !( *(*loopInRow) == *existentInSearchRow) )
+ break;
+ }
+
+ if(loopInRow == m_aSelectRow->get().end())
+ (m_pFileSet->get())[j] = 0; // Rows match -- Mark for deletion by setting key to 0
+ #if OSL_DEBUG_LEVEL > 1
+ else
+ nFound++;
+ #endif
+ }
+
+ m_pFileSet->get().erase(::std::remove_if(m_pFileSet->get().begin(),m_pFileSet->get().end(),
+ ::std::bind2nd(::std::equal_to<sal_Int32>(),0))
+ ,m_pFileSet->get().end());
+
+ if (bWasSorted)
+ {
+ // Re-sort on original requested order
+ m_aOrderbyColumnNumber = aOrderbyColumnNumberSave;
+ m_aOrderbyAscending.assign(aOrderbyAscendingSave.begin(), aOrderbyAscendingSave.end());
+
+ TIntVector aEvaluationKeySet(m_pFileSet->get());
+ m_pEvaluationKeySet = &aEvaluationKeySet;
+ sortRows();
+ }
+ else
+ {
+ m_aOrderbyColumnNumber.clear();
+ m_aOrderbyAscending.clear();
+ ::std::sort(m_pFileSet->get().begin(),m_pFileSet->get().end());
+ }
+ }
+ // SetRowCount(m_pFileSet->count());
+ }
+ }
+ } break;
+
+ case SQL_STATEMENT_UPDATE:
+ case SQL_STATEMENT_DELETE:
+ // waehrend der Bearbeitung die Anzahl der bearbeiteten Rows zaehlen:
+ m_nRowCountResult = 0;
+ // Vorlaeufig einfach ueber alle Datensaetze iterieren und
+ // dabei die Aktionen bearbeiten (bzw. einfach nur zaehlen):
+ {
+
+ sal_Bool bOK = sal_True;
+ if (m_pEvaluationKeySet)
+ {
+ m_aEvaluateIter = m_pEvaluationKeySet->begin();
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+
+ }
+ while (bOK)
+ {
+ if (m_pEvaluationKeySet)
+ ExecuteRow(IResultSetHelper::BOOKMARK,(*m_aEvaluateIter),TRUE);
+ else
+ bOK = ExecuteRow(IResultSetHelper::NEXT,1,TRUE);
+
+ if (bOK)
+ {
+ m_nRowCountResult++;
+ if(m_pEvaluationKeySet)
+ {
+ ++m_aEvaluateIter;
+ bOK = m_aEvaluateIter == m_pEvaluationKeySet->end();
+ }
+ }
+ }
+
+ // Ergebnis von COUNT(*) in nRowCountResult merken.
+ // nRowCount, also die Anzahl der Rows in der Ergebnismenge, ist bei dieser
+ // Anfrage = 1!
+ // DELETEZ(m_pEvaluationKeySet);
+ m_pEvaluationKeySet = NULL;
+ }
+ // SetRowCount(1);
+ break;
+ case SQL_STATEMENT_INSERT:
+ m_nRowCountResult = 0;
+
+ OSL_ENSURE(m_aAssignValues.isValid(),"No assign values set!");
+ if(!m_pTable->InsertRow(m_aAssignValues.getBody(), TRUE,m_xColsIdx))
+ {
+ m_nFilePos = 0;
+ return sal_False;
+ }
+
+ m_nRowCountResult = 1;
+ break;
+ default:
+ OSL_ENSURE( false, "OResultSet::OpenImpl: unsupported statement type!" );
+ break;
+ }
+
+ // FilePos zuruecksetzen
+ m_nFilePos = 0;
+
+ return sal_True;
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OResultSet::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getUnoTunnelImplementationId" );
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OResultSet::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : 0;
+}
+// -----------------------------------------------------------------------------
+void OResultSet::setBoundedColumns(const OValueRefRow& _rRow,
+ const OValueRefRow& _rSelectRow,
+ const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,
+ const Reference<XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const Reference<XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::setBoundedColumns" );
+ ::comphelper::UStringMixEqual aCase(_xMetaData->storesMixedCaseQuotedIdentifiers());
+
+ Reference<XPropertySet> xTableColumn;
+ ::rtl::OUString sTableColumnName, sSelectColumnRealName;
+
+ const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
+ const ::rtl::OUString sType = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE);
+
+ typedef ::std::map<OSQLColumns::Vector::iterator,sal_Bool> IterMap;
+ IterMap aSelectIters;
+ OValueRefVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
+ for (sal_Int32 i=0; // the first column is the bookmark column
+ aRowIter != _rRow->get().end();
+ ++i, ++aRowIter
+ )
+ {
+ (*aRowIter)->setBound(sal_False);
+ try
+ {
+ // get the table column and it's name
+ _xNames->getByIndex(i) >>= xTableColumn;
+ OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
+ else
+ sTableColumnName = ::rtl::OUString();
+
+ // look if we have such a select column
+ // TODO: would like to have a O(log n) search here ...
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter
+ )
+ {
+ if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+
+ if ( aCase(sTableColumnName, sSelectColumnRealName) && !(*aRowIter)->isBound() && aSelectIters.end() == aSelectIters.find(aIter) )
+ {
+ aSelectIters.insert(IterMap::value_type(aIter,sal_True));
+ if(_bSetColumnMapping)
+ {
+ sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column ...
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ (_rSelectRow->get())[nSelectColumnPos] = *aRowIter;
+ }
+
+ (*aRowIter)->setBound(sal_True);
+ sal_Int32 nType = DataType::OTHER;
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sType) >>= nType;
+ (*aRowIter)->setTypeKind(nType);
+
+ break;
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(sal_False, "OResultSet::setBoundedColumns: caught an Exception!");
+ }
+ }
+ // in this case we got more select columns as columns exist in the table
+ if ( _bSetColumnMapping && aSelectIters.size() != _rColMapping.size() )
+ {
+ Reference<XNameAccess> xNameAccess(_xNames,UNO_QUERY);
+ Sequence< ::rtl::OUString > aSelectColumns = xNameAccess->getElementNames();
+
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter
+ )
+ {
+ if ( aSelectIters.end() == aSelectIters.find(aIter) )
+ {
+ if ( (*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName) )
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+
+ if ( xNameAccess->hasByName( sSelectColumnRealName ) )
+ {
+ aSelectIters.insert(IterMap::value_type(aIter,sal_True));
+ sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
+ const ::rtl::OUString* pBegin = aSelectColumns.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aSelectColumns.getLength();
+ for(sal_Int32 i=0;pBegin != pEnd;++pBegin,++i)
+ {
+ if ( aCase(*pBegin, sSelectColumnRealName) )
+ {
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column ...
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ (_rSelectRow->get())[nSelectColumnPos] = (_rRow->get())[nTableColumnPos];
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void OResultSet::doTableSpecials(const OSQLTable& _xTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::doTableSpecials" );
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(_xTable,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ m_pTable = reinterpret_cast< OFileTable* >( xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()) );
+ if(m_pTable)
+ m_pTable->acquire();
+ }
+}
+// -----------------------------------------------------------------------------
+void OResultSet::clearInsertRow()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::clearInsertRow" );
+ m_aRow->setDeleted(sal_False); // set to false here because this is the new row
+ OValueRefVector::Vector::iterator aIter = m_aInsertRow->get().begin();
+ const OValueRefVector::Vector::iterator aEnd = m_aInsertRow->get().end();
+ for(sal_Int32 nPos = 0;aIter != aEnd;++aIter,++nPos)
+ {
+ ORowSetValueDecoratorRef& rValue = (*aIter);
+ if ( rValue->isBound() )
+ {
+ (m_aRow->get())[nPos]->setValue( (*aIter)->getValue() );
+ }
+ rValue->setBound(nPos == 0);
+ rValue->setModified(sal_False);
+ rValue->setNull();
+ }
+}
+// -----------------------------------------------------------------------------
+void OResultSet::initializeRow(OValueRefRow& _rRow,sal_Int32 _nColumnCount)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::initializeRow" );
+ if(!_rRow.isValid())
+ {
+ _rRow = new OValueRefVector(_nColumnCount);
+ (_rRow->get())[0]->setBound(sal_True);
+ ::std::for_each(_rRow->get().begin()+1,_rRow->get().end(),TSetRefBound(sal_False));
+ }
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::fillIndexValues(const Reference< XColumnsSupplier> &/*_xIndex*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::fillIndexValues" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::move" );
+ return Move(_eCursorPosition,_nOffset,_bRetrieveData);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OResultSet::getDriverPos() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::getDriverPos" );
+ return (m_aRow->get())[0]->getValue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::deletedVisible() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::deletedVisible" );
+ return m_bShowDeleted;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::isRowDeleted() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::isRowDeleted" );
+ return m_aRow->isDeleted();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::disposing( const EventObject& Source ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSet::disposing" );
+ // Reference<XInterface> xInt = m_pTable;
+ Reference<XPropertySet> xProp = m_pTable;
+ if(m_pTable && Source.Source == xProp)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FResultSetMetaData.cxx b/connectivity/source/drivers/file/FResultSetMetaData.cxx
new file mode 100644
index 000000000000..3e3befaa2430
--- /dev/null
+++ b/connectivity/source/drivers/file/FResultSetMetaData.cxx
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FResultSetMetaData.hxx"
+#include "file/FTable.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace dbtools;
+using namespace connectivity::file;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,const ::rtl::OUString& _aTableName,OFileTable* _pTable)
+ :m_aTableName(_aTableName)
+ ,m_xColumns(_rxColumns)
+ ,m_pTable(_pTable)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::OResultSetMetaData" );
+}
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+ m_xColumns = NULL;
+}
+// -----------------------------------------------------------------------------
+void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::checkColumnIndex" );
+ if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
+ throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnDisplaySize" );
+ return getPrecision(column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnType" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnCount" );
+ return (m_xColumns->get()).size();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCaseSensitive" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getSchemaName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnName" );
+ checkColumnIndex(column);
+
+ Any aName((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+ return aName.hasValue() ? getString(aName) : getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getTableName" );
+ return m_aTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getCatalogName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnTypeName" );
+ checkColumnIndex(column);
+ return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnLabel" );
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnServiceName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isCurrency" );
+ checkColumnIndex(column);
+ return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*setCatalogcolumn*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isAutoIncrement" );
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSigned" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getPrecision" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::getScale" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isNullable" );
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSearchable" );
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isReadOnly" );
+ checkColumnIndex(column);
+ return m_pTable->isReadOnly() || (
+ (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
+ ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION))));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isDefinitelyWritable" );
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OResultSetMetaData::isWritable" );
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
new file mode 100644
index 000000000000..acc2059f15c7
--- /dev/null
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -0,0 +1,860 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <osl/diagnose.h>
+#include "file/FStatement.hxx"
+#include "file/FConnection.hxx"
+#include "file/FDriver.hxx"
+#include "file/FResultSet.hxx"
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include "connectivity/dbexception.hxx"
+#include "resource/file_res.hrc"
+#include <algorithm>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+#define THROW_SQL(x) \
+ OTools::ThrowException(x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
+
+namespace connectivity
+{
+ namespace file
+ {
+
+//------------------------------------------------------------------------------
+using namespace dbtools;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+DBG_NAME( file_OStatement_Base )
+
+//------------------------------------------------------------------------------
+OStatement_Base::OStatement_Base(OConnection* _pConnection )
+ :OStatement_BASE(m_aMutex)
+ ,::comphelper::OPropertyContainer(OStatement_BASE::rBHelper)
+ ,m_xDBMetaData(_pConnection->getMetaData())
+ ,m_aParser(_pConnection->getDriver()->getFactory())
+ ,m_aSQLIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL )
+ ,m_pConnection(_pConnection)
+ ,m_pParseTree(NULL)
+ ,m_pSQLAnalyzer(NULL)
+ ,m_pEvaluationKeySet(NULL)
+ ,m_pTable(NULL)
+ ,m_nMaxFieldSize(0)
+ ,m_nMaxRows(0)
+ ,m_nQueryTimeOut(0)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_bEscapeProcessing(sal_True)
+ ,rBHelper(OStatement_BASE::rBHelper)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::OStatement_Base" );
+ DBG_CTOR( file_OStatement_Base, NULL );
+
+ m_pConnection->acquire();
+
+ sal_Int32 nAttrib = 0;
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_CURSORNAME), PROPERTY_ID_CURSORNAME, nAttrib,&m_aCursorName, ::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXFIELDSIZE), PROPERTY_ID_MAXFIELDSIZE, nAttrib,&m_nMaxFieldSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_MAXROWS), PROPERTY_ID_MAXROWS, nAttrib,&m_nMaxRows, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_QUERYTIMEOUT), PROPERTY_ID_QUERYTIMEOUT, nAttrib,&m_nQueryTimeOut, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE), PROPERTY_ID_FETCHSIZE, nAttrib,&m_nFetchSize, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE), PROPERTY_ID_RESULTSETTYPE, nAttrib,&m_nResultSetType, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION), PROPERTY_ID_FETCHDIRECTION, nAttrib,&m_nFetchDirection, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ESCAPEPROCESSING),PROPERTY_ID_ESCAPEPROCESSING, nAttrib,&m_bEscapeProcessing,::getCppuBooleanType());
+
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY), PROPERTY_ID_RESULTSETCONCURRENCY, nAttrib,&m_nResultSetConcurrency, ::getCppuType(reinterpret_cast<sal_Int32*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+OStatement_Base::~OStatement_Base()
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ disposing();
+ delete m_pSQLAnalyzer;
+
+ DBG_DTOR( file_OStatement_Base, NULL );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::disposeResultSet()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::disposeResultSet" );
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet = Reference< XResultSet>();
+}
+//------------------------------------------------------------------------------
+void OStatement_BASE2::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ disposeResultSet();
+
+ if(m_pSQLAnalyzer)
+ m_pSQLAnalyzer->dispose();
+
+ if(m_aRow.isValid())
+ {
+ m_aRow->get().clear();
+ m_aRow = NULL;
+ }
+
+ m_aSQLIterator.dispose();
+
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+
+ if (m_pConnection)
+ {
+ m_pConnection->release();
+ m_pConnection = NULL;
+ }
+
+ dispose_ChildImpl();
+
+ if ( m_pParseTree )
+ {
+ delete m_pParseTree;
+ m_pParseTree = NULL;
+ }
+
+ OStatement_Base::disposing();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::acquire() throw()
+{
+ OStatement_BASE::acquire();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OStatement_BASE2::release() throw()
+{
+ relase_ChildImpl();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::queryInterface" );
+ const Any aRet = OStatement_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getTypes" );
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::cancel" );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::close" );
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void OStatement_Base::reset() throw (SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::reset" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearWarnings ();
+
+ if (m_xResultSet.get().is())
+ clearMyResultSet();
+}
+//--------------------------------------------------------------------
+// clearMyResultSet
+// If a ResultSet was created for this Statement, close it
+//--------------------------------------------------------------------
+
+void OStatement_Base::clearMyResultSet () throw (SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::clearMyResultSet " );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ Reference<XCloseable> xCloseable;
+ if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+
+ m_xResultSet = Reference< XResultSet>();
+}
+//--------------------------------------------------------------------
+// setWarning
+// Sets the warning
+//--------------------------------------------------------------------
+
+void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::setWarning " );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = ex;
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getWarnings" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::clearWarnings" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createArrayHelper" );
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getInfoHelper" );
+ return *const_cast<OStatement_Base*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+OResultSet* OStatement::createResultSet()
+{
+ return new OResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbc.driver.file.Statement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ executeQuery(sql);
+
+ return m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ construct(sql);
+ Reference< XResultSet > xRS;
+ OResultSet* pResult = createResultSet();
+ xRS = pResult;
+ initializeResultSet(pResult);
+ m_xResultSet = Reference<XResultSet>(pResult);
+
+ pResult->OpenImpl();
+
+ return xRS;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL OStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OStatement::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ construct(sql);
+ OResultSet* pResult = createResultSet();
+ Reference< XResultSet > xRS = pResult;
+ initializeResultSet(pResult);
+ pResult->OpenImpl();
+
+ return pResult->getRowCountResult();
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::disposing" );
+ if(m_aEvaluateRow.isValid())
+ {
+ m_aEvaluateRow->get().clear();
+ m_aEvaluateRow = NULL;
+ }
+ delete m_pEvaluationKeySet;
+ OStatement_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_XStatement::queryInterface( rType);
+ return aRet.hasValue() ? aRet : OStatement_BASE2::queryInterface( rType);
+}
+// -----------------------------------------------------------------------------
+OSQLAnalyzer* OStatement_Base::createAnalyzer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createAnalyzer" );
+ return new OSQLAnalyzer(m_pConnection);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::anylizeSQL()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::anylizeSQL" );
+ OSL_ENSURE(m_pSQLAnalyzer,"OResultSet::anylizeSQL: Analyzer isn't set!");
+ // start analysing the statement
+ m_pSQLAnalyzer->setOrigColumns(m_xColNames);
+ m_pSQLAnalyzer->start(m_pParseTree);
+
+ const OSQLParseNode* pOrderbyClause = m_aSQLIterator.getOrderTree();
+ if(pOrderbyClause)
+ {
+ OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree");
+
+ for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++)
+ {
+ OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0);
+ if(!SQL_ISRULE(pColumnRef,column_ref))
+ {
+ throw SQLException();
+ }
+ OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1);
+ setOrderbyColumn(pColumnRef,pAscendingDescending);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OStatement_Base::setOrderbyColumn( OSQLParseNode* pColumnRef,
+ OSQLParseNode* pAscendingDescending)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::setOrderbyColumn" );
+ ::rtl::OUString aColumnName;
+ if (pColumnRef->count() == 1)
+ aColumnName = pColumnRef->getChild(0)->getTokenValue();
+ else if (pColumnRef->count() == 3)
+ {
+ // Nur die Table Range-Variable darf hier vorkommen:
+// if (!(pColumnRef->getChild(0)->getTokenValue() == aTableRange))
+// {
+// aStatus.Set(SQL_STAT_ERROR,
+// String::CreateFromAscii("S1000"),
+// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_INVALID_RANGE_VAR))),
+// 0, String() );
+ // return;
+ // }
+ pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), NULL, sal_False, sal_False );
+ }
+ else
+ {
+ // aStatus.SetStatementTooComplex();
+ throw SQLException();
+ }
+
+ Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY);
+ if(!xColLocate.is())
+ return;
+ // Alles geprueft und wir haben den Namen der Column.
+ // Die wievielte Column ist das?
+ try
+ {
+ m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName));
+ }
+ catch(Exception)
+ {
+ ::vos::ORef<OSQLColumns> aSelectColumns = m_aSQLIterator.getSelectColumns();
+ ::comphelper::UStringMixEqual aCase;
+ OSQLColumns::Vector::const_iterator aFind = ::connectivity::find(aSelectColumns->get().begin(),aSelectColumns->get().end(),aColumnName,aCase);
+ if ( aFind == aSelectColumns->get().end() )
+ throw SQLException();
+ m_aOrderbyColumnNumber.push_back((aFind - aSelectColumns->get().begin()) + 1);
+ }
+
+ // Ascending or Descending?
+ m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC);
+}
+
+// -----------------------------------------------------------------------------
+void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::construct" );
+ ::rtl::OUString aErr;
+ m_pParseTree = m_aParser.parseTree(aErr,sql);
+ if(m_pParseTree)
+ {
+ m_aSQLIterator.setParseTree(m_pParseTree);
+ m_aSQLIterator.traverseAll();
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+
+ // sanity checks
+ if ( xTabs.empty() )
+ // no tables -> nothing to operate on -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_NO_TABLE,*this);
+
+ if ( xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
+ // more than one table -> can't operate on them -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_MORE_TABLES,*this);
+
+ if ( (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT) && m_aSQLIterator.getSelectColumns()->get().empty() )
+ // SELECT statement without columns -> error
+ m_pConnection->throwGenericSQLException(STR_QUERY_NO_COLUMN,*this);
+
+ switch(m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_CREATE_TABLE:
+ case SQL_STATEMENT_ODBC_CALL:
+ case SQL_STATEMENT_UNKNOWN:
+ m_pConnection->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,*this);
+ break;
+ default:
+ break;
+ }
+
+ // at this moment we support only one table per select statement
+ Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY);
+ if(xTunnel.is())
+ {
+ if(m_pTable)
+ m_pTable->release();
+ m_pTable = reinterpret_cast<OFileTable*>(xTunnel->getSomething(OFileTable::getUnoTunnelImplementationId()));
+ if(m_pTable)
+ m_pTable->acquire();
+ }
+ OSL_ENSURE(m_pTable,"No table!");
+ if ( m_pTable )
+ m_xColNames = m_pTable->getColumns();
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // set the binding of the resultrow
+ m_aRow = new OValueRefVector(xNames->getCount());
+ (m_aRow->get())[0]->setBound(sal_True);
+ ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetRefBound(sal_False));
+
+ // set the binding of the resultrow
+ m_aEvaluateRow = new OValueRefVector(xNames->getCount());
+
+ (m_aEvaluateRow->get())[0]->setBound(sal_True);
+ ::std::for_each(m_aEvaluateRow->get().begin()+1,m_aEvaluateRow->get().end(),TSetRefBound(sal_False));
+
+ // set the select row
+ m_aSelectRow = new OValueRefVector(m_aSQLIterator.getSelectColumns()->get().size());
+ ::std::for_each(m_aSelectRow->get().begin(),m_aSelectRow->get().end(),TSetRefBound(sal_True));
+
+ // create the column mapping
+ createColumnMapping();
+
+ m_pSQLAnalyzer = createAnalyzer();
+
+ Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY);
+ if(xIndexSup.is())
+ m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes());
+
+ anylizeSQL();
+ }
+ else
+ throw SQLException(aErr,*this,::rtl::OUString(),0,Any());
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::createColumnMapping()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::createColumnMapping" );
+ // initialize the column index map (mapping select columns to table columns)
+ ::vos::ORef<connectivity::OSQLColumns> xColumns = m_aSQLIterator.getSelectColumns();
+ m_aColMapping.resize(xColumns->get().size() + 1);
+ for (sal_Int32 i=0; i<(sal_Int32)m_aColMapping.size(); ++i)
+ m_aColMapping[i] = i;
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // now check which columns are bound
+ OResultSet::setBoundedColumns(m_aRow,m_aSelectRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::initializeResultSet(OResultSet* _pResult)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::initializeResultSet" );
+ GetAssignValues();
+
+ _pResult->setSqlAnalyzer(m_pSQLAnalyzer);
+ _pResult->setOrderByColumns(m_aOrderbyColumnNumber);
+ _pResult->setOrderByAscending(m_aOrderbyAscending);
+ _pResult->setBindingRow(m_aRow);
+ _pResult->setColumnMapping(m_aColMapping);
+ _pResult->setEvaluationRow(m_aEvaluateRow);
+ _pResult->setAssignValues(m_aAssignValues);
+ _pResult->setSelectRow(m_aSelectRow);
+
+ m_pSQLAnalyzer->bindSelectRow(m_aRow);
+ m_pEvaluationKeySet = m_pSQLAnalyzer->bindEvaluationRow(m_aEvaluateRow); // Werte im Code des Compilers setzen
+ _pResult->setEvaluationKeySet(m_pEvaluationKeySet);
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::GetAssignValues()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::GetAssignValues" );
+ if (m_pParseTree == NULL)
+ {
+ ::dbtools::throwFunctionSequenceException(*this);
+ return;
+ }
+
+ if (SQL_ISRULE(m_pParseTree,select_statement))
+ // Keine zu setzenden Werte bei SELECT
+ return;
+ else if (SQL_ISRULE(m_pParseTree,insert_statement))
+ {
+ // Row fuer die zu setzenden Werte anlegen (Referenz durch new)
+ if(m_aAssignValues.isValid())
+ m_aAssignValues->get().clear();
+ sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+ m_aAssignValues = new OAssignValues(nCount);
+ // unbound all
+ ::std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(sal_False));
+
+ m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER);
+
+ // Liste der Columns-Namen, die in der column_commalist vorkommen (mit ; getrennt):
+ ::std::vector<String> aColumnNameList;
+
+ OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pOptColumnCommalist = m_pParseTree->getChild(3);
+ OSL_ENSURE(pOptColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(SQL_ISRULE(pOptColumnCommalist,opt_column_commalist),"OResultSet: Fehler im Parse Tree");
+ if (pOptColumnCommalist->count() == 0)
+ {
+ const Sequence< ::rtl::OUString>& aNames = m_xColNames->getElementNames();
+ const ::rtl::OUString* pBegin = aNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aNames.getLength();
+ for (; pBegin != pEnd; ++pBegin)
+ aColumnNameList.push_back(*pBegin);
+ }
+ else
+ {
+ OSL_ENSURE(pOptColumnCommalist->count() == 3,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnCommalist = pOptColumnCommalist->getChild(1);
+ OSL_ENSURE(pColumnCommalist != NULL,"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(SQL_ISRULE(pColumnCommalist,column_commalist),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pColumnCommalist->count() > 0,"OResultSet: Fehler im Parse Tree");
+
+ // Alle Columns in der column_commalist ...
+ for (sal_uInt32 i = 0; i < pColumnCommalist->count(); i++)
+ {
+ OSQLParseNode * pCol = pColumnCommalist->getChild(i);
+ OSL_ENSURE(pCol != NULL,"OResultSet: Fehler im Parse Tree");
+ aColumnNameList.push_back(pCol->getTokenValue());
+ }
+ }
+ if ( aColumnNameList.empty() )
+ throwFunctionSequenceException(*this);
+
+ // Werte ...
+ OSQLParseNode * pValuesOrQuerySpec = m_pParseTree->getChild(4);
+ OSL_ENSURE(pValuesOrQuerySpec != NULL,"OResultSet: pValuesOrQuerySpec darf nicht NULL sein!");
+ OSL_ENSURE(SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec),"OResultSet: ! SQL_ISRULE(pValuesOrQuerySpec,values_or_query_spec)");
+ OSL_ENSURE(pValuesOrQuerySpec->count() > 0,"OResultSet: pValuesOrQuerySpec->count() <= 0");
+
+ // nur "VALUES" ist erlaubt ...
+ if (! SQL_ISTOKEN(pValuesOrQuerySpec->getChild(0),VALUES))
+ throwFunctionSequenceException(*this);
+
+ OSL_ENSURE(pValuesOrQuerySpec->count() == 4,"OResultSet: pValuesOrQuerySpec->count() != 4");
+
+ // Liste von Werten
+ OSQLParseNode * pInsertAtomCommalist = pValuesOrQuerySpec->getChild(2);
+ OSL_ENSURE(pInsertAtomCommalist != NULL,"OResultSet: pInsertAtomCommalist darf nicht NULL sein!");
+ OSL_ENSURE(pInsertAtomCommalist->count() > 0,"OResultSet: pInsertAtomCommalist <= 0");
+
+ String aColumnName;
+ OSQLParseNode * pRow_Value_Const;
+ xub_StrLen nIndex=0;
+ for (sal_uInt32 i = 0; i < pInsertAtomCommalist->count(); i++)
+ {
+ pRow_Value_Const = pInsertAtomCommalist->getChild(i); // row_value_constructor
+ OSL_ENSURE(pRow_Value_Const != NULL,"OResultSet: pRow_Value_Const darf nicht NULL sein!");
+ if(SQL_ISRULE(pRow_Value_Const,parameter))
+ {
+ ParseAssignValues(aColumnNameList,pRow_Value_Const,nIndex++); // kann nur ein Columnname vorhanden sein pro Schleife
+ }
+ else if(pRow_Value_Const->isToken())
+ ParseAssignValues(aColumnNameList,pRow_Value_Const,static_cast<xub_StrLen>(i));
+ else
+ {
+ if(pRow_Value_Const->count() == aColumnNameList.size())
+ {
+ for (sal_uInt32 j = 0; j < pRow_Value_Const->count(); ++j)
+ ParseAssignValues(aColumnNameList,pRow_Value_Const->getChild(j),nIndex++);
+ }
+ else
+ throwFunctionSequenceException(*this);
+ }
+ }
+ }
+ else if (SQL_ISRULE(m_pParseTree,update_statement_searched))
+ {
+ if(m_aAssignValues.isValid())
+ m_aAssignValues->get().clear();
+ sal_Int32 nCount = Reference<XIndexAccess>(m_xColNames,UNO_QUERY)->getCount();
+ m_aAssignValues = new OAssignValues(nCount);
+ // unbound all
+ ::std::for_each(m_aAssignValues->get().begin()+1,m_aAssignValues->get().end(),TSetRefBound(sal_False));
+
+ m_aParameterIndexes.resize(nCount+1,SQL_NO_PARAMETER);
+
+ OSL_ENSURE(m_pParseTree->count() >= 4,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pAssignmentCommalist = m_pParseTree->getChild(3);
+ OSL_ENSURE(pAssignmentCommalist != NULL,"OResultSet: pAssignmentCommalist == NULL");
+ OSL_ENSURE(SQL_ISRULE(pAssignmentCommalist,assignment_commalist),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pAssignmentCommalist->count() > 0,"OResultSet: pAssignmentCommalist->count() <= 0");
+
+ // Alle Zuweisungen (Kommaliste) bearbeiten ...
+ ::std::vector< String> aList(1);
+ for (sal_uInt32 i = 0; i < pAssignmentCommalist->count(); i++)
+ {
+ OSQLParseNode * pAssignment = pAssignmentCommalist->getChild(i);
+ OSL_ENSURE(pAssignment != NULL,"OResultSet: pAssignment == NULL");
+ OSL_ENSURE(SQL_ISRULE(pAssignment,assignment),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pAssignment->count() == 3,"OResultSet: pAssignment->count() != 3");
+
+ OSQLParseNode * pCol = pAssignment->getChild(0);
+ OSL_ENSURE(pCol != NULL,"OResultSet: pCol == NULL");
+
+ OSQLParseNode * pComp = pAssignment->getChild(1);
+ OSL_ENSURE(pComp != NULL,"OResultSet: pComp == NULL");
+ OSL_ENSURE(pComp->getNodeType() == SQL_NODE_EQUAL,"OResultSet: pComp->getNodeType() != SQL_NODE_COMPARISON");
+ if (pComp->getTokenValue().toChar() != '=')
+ {
+ // aStatus.SetInvalidStatement();
+ throwFunctionSequenceException(*this);
+ }
+
+ OSQLParseNode * pVal = pAssignment->getChild(2);
+ OSL_ENSURE(pVal != NULL,"OResultSet: pVal == NULL");
+ aList[0] = pCol->getTokenValue();
+ ParseAssignValues(aList,pVal,0);
+ }
+
+ }
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::ParseAssignValues(const ::std::vector< String>& aColumnNameList,OSQLParseNode* pRow_Value_Constructor_Elem,xub_StrLen nIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::ParseAssignValues" );
+ OSL_ENSURE(nIndex <= aColumnNameList.size(),"SdbFileCursor::ParseAssignValues: nIndex > aColumnNameList.GetTokenCount()");
+ String aColumnName(aColumnNameList[nIndex]);
+ OSL_ENSURE(aColumnName.Len() > 0,"OResultSet: Column-Name nicht gefunden");
+ OSL_ENSURE(pRow_Value_Constructor_Elem != NULL,"OResultSet: pRow_Value_Constructor_Elem darf nicht NULL sein!");
+
+ if (pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_STRING ||
+ pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_INTNUM ||
+ pRow_Value_Constructor_Elem->getNodeType() == SQL_NODE_APPROXNUM)
+ {
+ // Wert setzen:
+ SetAssignValue(aColumnName, pRow_Value_Constructor_Elem->getTokenValue());
+ }
+ else if (SQL_ISTOKEN(pRow_Value_Constructor_Elem,NULL))
+ {
+ // NULL setzen
+ SetAssignValue(aColumnName, String(), TRUE);
+ }
+ else if (SQL_ISRULE(pRow_Value_Constructor_Elem,parameter))
+ parseParamterElem(aColumnName,pRow_Value_Constructor_Elem);
+ else
+ {
+ // aStatus.SetStatementTooComplex();
+ throwFunctionSequenceException(*this);
+ }
+}
+//------------------------------------------------------------------
+void OStatement_Base::SetAssignValue(const String& aColumnName,
+ const String& aValue,
+ BOOL bSetNull,
+ UINT32 nParameter)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::SetAssignValue" );
+ Reference<XPropertySet> xCol;
+ m_xColNames->getByName(aColumnName) >>= xCol;
+ sal_Int32 nId = Reference<XColumnLocate>(m_xColNames,UNO_QUERY)->findColumn(aColumnName);
+ // Kommt diese Column ueberhaupt in der Datei vor?
+
+ if (!xCol.is())
+ {
+ // Diese Column gibt es nicht!
+// aStatus.Set(SQL_STAT_ERROR,
+// String::CreateFromAscii("S0022"),
+// aStatus.CreateErrorMessage(String(SdbResId(STR_STAT_COLUMN_NOT_FOUND))),
+// 0, String() );
+ throwFunctionSequenceException(*this);
+ }
+
+ // Value an die Row mit den zuzuweisenden Werten binden:
+ // const ODbVariantRef& xValue = (*aAssignValues)[pFileColumn->GetId()];
+
+ // Alles geprueft und wir haben den Namen der Column.
+ // Jetzt eine Value allozieren, den Wert setzen und die Value an die Row binden.
+ if (bSetNull)
+ (m_aAssignValues->get())[nId]->setNull();
+ else
+ {
+ switch (::comphelper::getINT32(xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))))
+ {
+ // Kriterium je nach Typ als String oder double in die Variable packen ...
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ *(m_aAssignValues->get())[nId] = ORowSetValue(aValue);
+ // Zeichensatz ist bereits konvertiert, da ja das gesamte Statement konvertiert wurde
+ break;
+
+ case DataType::BIT:
+ {
+ if (aValue.EqualsIgnoreCaseAscii("TRUE") || aValue.GetChar(0) == '1')
+ *(m_aAssignValues->get())[nId] = sal_True;
+ else if (aValue.EqualsIgnoreCaseAscii("FALSE") || aValue.GetChar(0) == '0')
+ *(m_aAssignValues->get())[nId] = sal_False;
+ else
+ {
+ // aStatus.Set(SQL_STAT_ERROR); // nyi: genauer!
+ throwFunctionSequenceException(*this);
+ }
+ }
+ break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ {
+ *(m_aAssignValues->get())[nId] = ORowSetValue(aValue); // .ToDouble
+// try
+// {
+// double n = xValue->toDouble();
+// xValue->setDouble(n);
+// }
+// catch ( ... )
+// {
+// aStatus.SetDriverNotCapableError();
+// }
+ } break;
+ default:
+ throwFunctionSequenceException(*this);
+ }
+ }
+
+ // Parameter-Nr. merken (als User Data)
+ // SQL_NO_PARAMETER = kein Parameter.
+ m_aAssignValues->setParameterIndex(nId,nParameter);
+ if(nParameter != SQL_NO_PARAMETER)
+ m_aParameterIndexes[nParameter] = nId;
+}
+// -----------------------------------------------------------------------------
+void OStatement_Base::parseParamterElem(const String& /*_sColumnName*/,OSQLParseNode* /*pRow_Value_Constructor_Elem*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OStatement_Base::parseParamterElem" );
+ // do nothing here
+}
+// =============================================================================
+ } // namespace file
+// =============================================================================
+}// namespace connectivity
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/FStringFunctions.cxx b/connectivity/source/drivers/file/FStringFunctions.cxx
new file mode 100644
index 000000000000..0ef8fcb99b1d
--- /dev/null
+++ b/connectivity/source/drivers/file/FStringFunctions.cxx
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "file/FStringFunctions.hxx"
+#include <rtl/ustrbuf.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+//------------------------------------------------------------------
+ORowSetValue OOp_Upper::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Upper::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().toAsciiUpperCase();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Lower::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Lower::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().toAsciiLowerCase();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Ascii::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Ascii::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+ ::rtl::OString sStr(::rtl::OUStringToOString(lhs,RTL_TEXTENCODING_ASCII_US));
+ sal_Int32 nAscii = sStr.toChar();
+ return nAscii;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_CharLength::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_CharLength::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ return lhs.getString().getLength();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Char::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Char::operate" );
+ if ( lhs.empty() )
+ return ORowSetValue();
+
+ ::rtl::OUString sRet;
+ ::std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
+ ::std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( !aIter->isNull() )
+ {
+ sal_Char c = static_cast<sal_Char>(static_cast<sal_Int32>(*aIter));
+
+ sRet += ::rtl::OUString(&c,1,RTL_TEXTENCODING_ASCII_US);
+ }
+ }
+
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Concat::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Concat::operate" );
+ if ( lhs.empty() )
+ return ORowSetValue();
+
+ ::rtl::OUStringBuffer sRet;
+ ::std::vector<ORowSetValue>::const_reverse_iterator aIter = lhs.rbegin();
+ ::std::vector<ORowSetValue>::const_reverse_iterator aEnd = lhs.rend();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+
+ sRet.append(aIter->operator ::rtl::OUString());
+ }
+
+ return sRet.makeStringAndClear();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Locate::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Locate::operate" );
+ ::std::vector<ORowSetValue>::const_iterator aIter = lhs.begin();
+ ::std::vector<ORowSetValue>::const_iterator aEnd = lhs.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+ }
+ if ( lhs.size() == 2 )
+ return ::rtl::OUString::valueOf(lhs[0].getString().indexOf(lhs[1].getString())+1);
+
+ else if ( lhs.size() != 3 )
+ return ORowSetValue();
+
+ return lhs[1].getString().indexOf(lhs[2].getString(),lhs[0]) + 1;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_SubString::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_SubString::operate" );
+ ::std::vector<ORowSetValue>::const_iterator aIter = lhs.begin();
+ ::std::vector<ORowSetValue>::const_iterator aEnd = lhs.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->isNull() )
+ return ORowSetValue();
+ }
+ if ( lhs.size() == 2 && static_cast<sal_Int32>(lhs[0]) >= sal_Int32(0) )
+ return lhs[1].getString().copy(static_cast<sal_Int32>(lhs[0])-1);
+
+ else if ( lhs.size() != 3 || static_cast<sal_Int32>(lhs[1]) < sal_Int32(0))
+ return ORowSetValue();
+
+ return lhs[2].getString().copy(static_cast<sal_Int32>(lhs[1])-1,lhs[0]);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_LTrim::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_LTrim::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ ::rtl::OUString sNew = sRet.trim();
+ return sRet.copy(sRet.indexOf(sNew));
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_RTrim::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_RTrim::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ ::rtl::OUString sNew = sRet.trim();
+ return sRet.copy(0,sRet.lastIndexOf(sNew.getStr()[sNew.getLength()-1])+1);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Space::operate(const ORowSetValue& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Space::operate" );
+ if ( lhs.isNull() )
+ return lhs;
+
+ const sal_Char c = ' ';
+ ::rtl::OUStringBuffer sRet;
+ sal_Int32 nCount = lhs;
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ sRet.appendAscii(&c,1);
+ }
+ return sRet.makeStringAndClear();
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Replace::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Replace::operate" );
+ if ( lhs.size() != 3 )
+ return ORowSetValue();
+
+ ::rtl::OUString sStr = lhs[2];
+ ::rtl::OUString sFrom = lhs[1];
+ ::rtl::OUString sTo = lhs[0];
+ sal_Int32 nIndexOf = sStr.indexOf(sFrom);
+ while( nIndexOf != -1 )
+ {
+ sStr = sStr.replaceAt(nIndexOf,sFrom.getLength(),sTo);
+ nIndexOf = sStr.indexOf(sFrom,nIndexOf + sTo.getLength());
+ }
+
+ return sStr;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Repeat::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Repeat::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet;
+ sal_Int32 nCount = rhs;
+ for (sal_Int32 i=0; i < nCount; ++i)
+ {
+ sRet += lhs;
+ }
+ return sRet;
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Insert::operate(const ::std::vector<ORowSetValue>& lhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Insert::operate" );
+ if ( lhs.size() != 4 )
+ return ORowSetValue();
+
+ ::rtl::OUString sStr = lhs[3];
+
+ sal_Int32 nStart = static_cast<sal_Int32>(lhs[2]);
+ if ( nStart < 1 )
+ nStart = 1;
+ return sStr.replaceAt(nStart-1,static_cast<sal_Int32>(lhs[1]),lhs[0]);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Left::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Left::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ ::rtl::OUString sRet = lhs;
+ sal_Int32 nCount = rhs;
+ if ( nCount < 0 )
+ return ORowSetValue();
+ return sRet.copy(0,nCount);
+}
+//------------------------------------------------------------------
+ORowSetValue OOp_Right::operate(const ORowSetValue& lhs,const ORowSetValue& rhs) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_Right::operate" );
+ if ( lhs.isNull() || rhs.isNull() )
+ return lhs;
+
+ sal_Int32 nCount = rhs;
+ ::rtl::OUString sRet = lhs;
+ if ( nCount < 0 || nCount >= sRet.getLength() )
+ return ORowSetValue();
+
+ return sRet.copy(sRet.getLength()-nCount,nCount);
+}
+
diff --git a/connectivity/source/drivers/file/FTable.cxx b/connectivity/source/drivers/file/FTable.cxx
new file mode 100644
index 000000000000..7bc28fd35b64
--- /dev/null
+++ b/connectivity/source/drivers/file/FTable.cxx
@@ -0,0 +1,257 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include "file/FTable.hxx"
+#include "file/FColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <unotools/ucbstreamhelper.hxx>
+#include <tools/debug.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+DBG_NAME( file_OFileTable )
+OFileTable::OFileTable(sdbcx::OCollection* _pTables,OConnection* _pConnection)
+: OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers())
+ ,m_pConnection(_pConnection)
+ ,m_pFileStream(NULL)
+ ,m_nFilePos(0)
+ ,m_pBuffer(NULL)
+ ,m_nBufferSize(0)
+ ,m_bWriteable(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::OFileTable" );
+ DBG_CTOR( file_OFileTable, NULL );
+ construct();
+ TStringVector aVector;
+ // m_pColumns = new OColumns(this,m_aMutex,aVector);
+ m_aColumns = new OSQLColumns();
+}
+// -------------------------------------------------------------------------
+OFileTable::OFileTable( sdbcx::OCollection* _pTables,OConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OTable_TYPEDEF(_pTables,_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers(),
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_pConnection(_pConnection)
+ ,m_pFileStream(NULL)
+ ,m_nFilePos(0)
+ ,m_pBuffer(NULL)
+ ,m_nBufferSize(0)
+ ,m_bWriteable(sal_False)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::OFileTable" );
+ DBG_CTOR( file_OFileTable, NULL );
+ m_aColumns = new OSQLColumns();
+ construct();
+ // refreshColumns();
+}
+// -------------------------------------------------------------------------
+OFileTable::~OFileTable( )
+{
+ DBG_DTOR( file_OFileTable, NULL );
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshColumns" );
+ TStringVector aVector;
+ Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(Any(),
+ m_SchemaName,m_Name,::rtl::OUString::createFromAscii("%"));
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(4));
+ }
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OColumns(this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshKeys()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshKeys" );
+}
+// -------------------------------------------------------------------------
+void OFileTable::refreshIndexes()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshIndexes" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OFileTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::queryInterface" );
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ return OTable_TYPEDEF::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OFileTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::disposing" );
+ OTable::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ FileClose();
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OFileTable::getUnoTunnelImplementationId()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::getUnoTunnelImplementationId" );
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OFileTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -----------------------------------------------------------------------------
+void OFileTable::FileClose()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::FileClose" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if (m_pFileStream && m_pFileStream->IsWritable())
+ m_pFileStream->Flush();
+
+ delete m_pFileStream;
+ m_pFileStream = NULL;
+
+ if (m_pBuffer)
+ {
+ delete[] m_pBuffer;
+ m_pBuffer = NULL;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFileTable::acquire() throw()
+{
+ OTable_TYPEDEF::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFileTable::release() throw()
+{
+ OTable_TYPEDEF::release();
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::InsertRow(OValueRefVector& /*rRow*/, BOOL /*bFlush*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::InsertRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::DeleteRow(const OSQLColumns& /*_rCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::DeleteRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+BOOL OFileTable::UpdateRow(OValueRefVector& /*rRow*/, OValueRefRow& /*pOrgRow*/,const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& /*_xCols*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::UpdateRow" );
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+void OFileTable::addColumn(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& /*descriptor*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::addColumn" );
+ OSL_ENSURE( false, "OFileTable::addColumn: not implemented!" );
+}
+// -----------------------------------------------------------------------------
+void OFileTable::dropColumn(sal_Int32 /*_nPos*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::dropColumn" );
+ OSL_ENSURE( false, "OFileTable::addColumn: not implemented!" );
+}
+
+// -----------------------------------------------------------------------------
+SvStream* OFileTable::createStream_simpleError( const String& _rFileName, StreamMode _eOpenMode)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::createStream_simpleError" );
+ utl::UcbLockBytesHandler* p_null_dummy=NULL;
+ SvStream* pReturn = ::utl::UcbStreamHelper::CreateStream( _rFileName, _eOpenMode, (_eOpenMode & STREAM_NOCREATE) == STREAM_NOCREATE ,p_null_dummy);
+ if (pReturn && (ERRCODE_NONE != pReturn->GetErrorCode()))
+ {
+ delete pReturn;
+ pReturn = NULL;
+ }
+ return pReturn;
+}
+
+// -----------------------------------------------------------------------------
+void OFileTable::refreshHeader()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OFileTable::refreshHeader" );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/file/FTables.cxx b/connectivity/source/drivers/file/FTables.cxx
new file mode 100644
index 000000000000..7ac21ef50668
--- /dev/null
+++ b/connectivity/source/drivers/file/FTables.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/FTables.hxx"
+#include "file/FTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "file/FCatalog.hxx"
+#ifndef _CONNECTIVITY_FILE_BCONNECTION_HXX_
+#include "file/FConnection.hxx"
+#endif
+//#ifndef _CONNECTIVITY_FILE_OEMPTYCOLLECTION_HXX_
+//#include "file/FEmptyCollection.hxx"
+//#endif
+
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+namespace starutil = ::com::sun::star::util;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& /*_rName*/)
+{
+ return sdbcx::ObjectType();
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OFileCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+//------------------------------------------------------------------
+Any SAL_CALL OTables::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XColumnLocate>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0) ||
+ rType == ::getCppuType((const Reference<XAppend>*)0) ||
+ rType == ::getCppuType((const Reference<XDrop>*)0))
+ return Any();
+
+ typedef sdbcx::OCollection OTables_BASE;
+ return OTables_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/fanalyzer.cxx b/connectivity/source/drivers/file/fanalyzer.cxx
new file mode 100644
index 000000000000..7abf10191f21
--- /dev/null
+++ b/connectivity/source/drivers/file/fanalyzer.cxx
@@ -0,0 +1,322 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/fanalyzer.hxx"
+#include "connectivity/sqlparse.hxx"
+#include <osl/diagnose.h>
+#include <tools/debug.hxx>
+#include <comphelper/extract.hxx>
+#include "connectivity/sqlnode.hxx"
+#include "connectivity/dbexception.hxx"
+#include "file/FConnection.hxx"
+#include "resource/file_res.hrc"
+
+using namespace ::connectivity;
+using namespace ::connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+DBG_NAME( file_OSQLAnalyzer )
+//------------------------------------------------------------------
+OSQLAnalyzer::OSQLAnalyzer(OConnection* _pConnection)
+ :m_pConnection(_pConnection)
+ ,m_bHasSelectionCode(sal_False)
+ ,m_bSelectionFirstTime(sal_True)
+{
+ DBG_CTOR( file_OSQLAnalyzer, NULL );
+ m_aCompiler = new OPredicateCompiler(this);
+ m_aInterpreter = new OPredicateInterpreter(m_aCompiler);
+}
+
+// -----------------------------------------------------------------------------
+OSQLAnalyzer::~OSQLAnalyzer()
+{
+ DBG_DTOR( file_OSQLAnalyzer, NULL );
+}
+
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setIndexes(const Reference< XNameAccess>& _xIndexes)
+{
+ m_aCompiler->m_xIndexes = _xIndexes;
+}
+//------------------------------------------------------------------
+void OSQLAnalyzer::start(OSQLParseNode* pSQLParseNode)
+{
+ if (SQL_ISRULE(pSQLParseNode,select_statement))
+ {
+ DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ // check that we don't use anything other than count(*) as function
+ OSQLParseNode* pSelection = pSQLParseNode->getChild(2);
+ if ( SQL_ISRULE(pSelection,scalar_exp_commalist) )
+ {
+ for (sal_uInt32 i = 0; i < pSelection->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelection->getChild(i)->getChild(0);
+ if ( ( SQL_ISRULE(pColumnRef,set_fct_spec) && pColumnRef->count() == 4 )
+ || SQL_ISRULE(pColumnRef,char_value_fct)
+ || SQL_ISRULE(pColumnRef,char_substring_fct)
+ || SQL_ISRULE(pColumnRef,position_exp)
+ || SQL_ISRULE(pColumnRef,fold)
+ || SQL_ISRULE(pColumnRef,length_exp)
+ || SQL_ISRULE(pColumnRef,num_value_exp)
+ || SQL_ISRULE(pColumnRef,term)
+ || SQL_ISRULE(pColumnRef,factor)
+ || SQL_ISRULE(pColumnRef,set_fct_spec) )
+ {
+ ::vos::ORef<OPredicateCompiler> pCompiler = new OPredicateCompiler(this);
+ pCompiler->setOrigColumns(m_aCompiler->getOrigColumns());
+ ::vos::ORef<OPredicateInterpreter> pInterpreter = new OPredicateInterpreter(pCompiler);
+ pCompiler->execute( pColumnRef );
+ m_aSelectionEvaluations.push_back( TPredicates(pCompiler,pInterpreter) );
+ }
+ else if ( ( SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->count() != 4 ) )
+ {
+ m_pConnection->throwGenericSQLException(STR_QUERY_COMPLEX_COUNT,NULL);
+ }
+ else
+ m_aSelectionEvaluations.push_back( TPredicates() );
+ }
+ }
+ }
+
+ m_aCompiler->start(pSQLParseNode);
+}
+
+//------------------------------------------------------------------
+void OSQLAnalyzer::bindRow(OCodeList& rCodeList,const OValueRefRow& _pRow,OEvaluateSetList& _rEvaluateSetList)
+{
+ // Zaehlen, wieviele Kriterien
+ // wenn nur ein Kriterium, und das entsprechende Feld ist indiziert
+ // dann wird der Index verwendet
+
+ OEvaluateSet* pEvaluateSet = NULL;
+
+ for (OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end(); ++aIter)
+ {
+ OOperandAttr* pAttr = PTR_CAST(OOperandAttr,(*aIter));
+ if (pAttr)
+ {
+ if (pAttr->isIndexed() && !m_aCompiler->hasORCondition())
+ {
+ OCode* pCode1 = *(aIter + 1);
+ OCode* pCode2 = *(aIter + 2);
+
+ if (PTR_CAST(OOperand,pCode1))
+ pEvaluateSet = pAttr->preProcess(PTR_CAST(OBoolOperator,pCode2), PTR_CAST(OOperand,pCode1));
+ else
+ pEvaluateSet = pAttr->preProcess(PTR_CAST(OBoolOperator,pCode1));
+ }
+
+ if (pEvaluateSet)
+ {
+ _rEvaluateSetList.push_back(pEvaluateSet);
+ pEvaluateSet = NULL;
+ }
+ pAttr->bindValue(_pRow);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OSQLAnalyzer::bindSelectRow(const OValueRefRow& _pRow)
+{
+ // first the select part
+ OEvaluateSetList aEvaluateSetList;
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ bindRow( aIter->first->m_aCodeList,_pRow,aEvaluateSetList);
+ }
+}
+//------------------------------------------------------------------
+::std::vector<sal_Int32>* OSQLAnalyzer::bindEvaluationRow(OValueRefRow& _pRow)
+{
+ OEvaluateSetList aEvaluateSetList;
+ bindRow( m_aCompiler->m_aCodeList,_pRow,aEvaluateSetList);
+
+ ::std::vector<sal_Int32>* pKeySet = NULL;
+ OEvaluateSet* pEvaluateSet = NULL;
+
+ // Keyset erzeugen mit kleinster Liste
+ if(!aEvaluateSetList.empty())
+ {
+ // welche Liste hat den kleinsten count ?
+ OEvaluateSetList::iterator i = aEvaluateSetList.begin();
+ pEvaluateSet = *(i);
+ for(++i; i != aEvaluateSetList.end();++i)
+ {
+ OEvaluateSet* pEvaluateSetComp = (*i);
+ for(OEvaluateSet::reverse_iterator j = pEvaluateSet->rbegin(); j != pEvaluateSet->rend(); ++j)
+ {
+ if (pEvaluateSetComp->find(j->second) != pEvaluateSetComp->end())
+ pEvaluateSet->erase(j->second);
+ }
+ }
+ pKeySet = new ::std::vector<sal_Int32>(pEvaluateSet->size());
+ sal_Int32 k=0;
+ for(OEvaluateSet::iterator j = pEvaluateSet->begin(); j != pEvaluateSet->end(); ++j,++k)
+ {
+ (*pKeySet)[k] = j->second;
+ }
+
+ // alle loeschen
+ for(i = aEvaluateSetList.begin(); i != aEvaluateSetList.end();++i)
+ delete (*i);
+ }
+
+ return pKeySet;
+}
+
+//------------------------------------------------------------------
+void OSQLAnalyzer::describeParam(::vos::ORef<OSQLColumns> rParameterColumns)
+{
+ OCodeList& rCodeList = m_aCompiler->m_aCodeList;
+ OCodeStack aCodeStack;
+
+ if (!rCodeList.size())
+ return; // kein Praedikat
+ if (!rParameterColumns->get().size())
+ return; // keine Parameter
+
+ // Anlegen von Columns, die eine genauere Beschreibung fuer die enthalten
+ ::vos::ORef<OSQLColumns> aNewParamColumns = new OSQLColumns(*rParameterColumns);
+
+
+ // Anlegen einer Testzeile, wird benoetigt um die Parameter zu beschreiben
+ OValueRefRow aParameterRow = new OValueRefVector(rParameterColumns->get().size());
+ bindParameterRow(aParameterRow);
+
+ OValueRefRow aTestRow = new OValueRefVector(Reference< XIndexAccess>(m_aCompiler->getOrigColumns(),UNO_QUERY)->getCount());
+ delete bindEvaluationRow(aTestRow); // Binden der Attribute an die Values
+
+ for(OCodeList::iterator aIter = rCodeList.begin(); aIter != rCodeList.end(); ++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ OOperator* pOperator = PTR_CAST(OOperator,(*aIter));
+ if (pOperand)
+ aCodeStack.push(pOperand);
+ else
+ {
+ if (pOperator->getRequestedOperands() == 2) // bei zwei Operatoren ist es moeglich
+ { // einen Parameter weiter zu spezifizieren
+ OOperandParam *pParam = PTR_CAST(OOperandParam,aCodeStack.top());
+ if (pParam) // Anpassen des ParameterTyps, wenn der linke Operand ein Attribut ist
+ {
+ OOperandAttr *pLeft = PTR_CAST(OOperandAttr,*(rCodeList.end() - 2));
+ if (pLeft)
+ {
+ Reference< XPropertySet> xCol;
+ Reference< XIndexAccess>(m_aCompiler->getOrigColumns(),UNO_QUERY)->getByIndex(pLeft->getRowPos()) >>= xCol;
+ OSL_ENSURE(xCol.is(), "Ungueltige Struktur");
+ pParam->describe(xCol, aNewParamColumns);
+ }
+ }
+ }
+ pOperator->Exec(aCodeStack);
+ }
+ }
+ OOperand* pOperand = aCodeStack.top();
+ aCodeStack.pop();
+
+ OSL_ENSURE(aCodeStack.size() == 0, "StackFehler");
+ OSL_ENSURE(pOperand, "StackFehler");
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+ else
+ OSL_ENSURE(0,"Illegal here!");
+
+ rParameterColumns = aNewParamColumns;
+ // m_aCompiler->setParameterColumns(rParameterColumns);
+}
+
+// -----------------------------------------------------------------------------
+OOperandAttr* OSQLAnalyzer::createOperandAttr(sal_Int32 _nPos,
+ const Reference< XPropertySet>& _xCol,
+ const Reference< XNameAccess>& /*_xIndexes*/)
+{
+ return new OOperandAttr(static_cast<sal_uInt16>(_nPos),_xCol);
+}
+// -----------------------------------------------------------------------------
+BOOL OSQLAnalyzer::hasRestriction() const
+{
+ return m_aCompiler->hasCode();
+}
+// -----------------------------------------------------------------------------
+BOOL OSQLAnalyzer::hasFunctions() const
+{
+ if ( m_bSelectionFirstTime )
+ {
+ m_bSelectionFirstTime = sal_False;
+ for ( ::std::vector< TPredicates >::const_iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end() && !m_bHasSelectionCode ;++aIter)
+ {
+ if ( aIter->first.isValid() )
+ m_bHasSelectionCode = aIter->first->hasCode();
+ }
+ }
+ return m_bHasSelectionCode;;
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setSelectionEvaluationResult(OValueRefRow& _pRow,const ::std::vector<sal_Int32>& _rColumnMapping)
+{
+ sal_Int32 nPos = 1;
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter,++nPos)
+ {
+ if ( aIter->second.isValid() )
+ {
+ sal_Int32 map = nPos;
+ // the first column (index 0) is for convenience only. The first real select column is no 1.
+ if ( (nPos > 0) && (nPos < static_cast<sal_Int32>(_rColumnMapping.size())) )
+ map = _rColumnMapping[nPos];
+ aIter->second->startSelection((_pRow->get())[map]);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::dispose()
+{
+ m_aCompiler->dispose();
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ aIter->first->dispose();
+ }
+}
+// -----------------------------------------------------------------------------
+void OSQLAnalyzer::setOrigColumns(const OFileColumns& rCols)
+{
+ m_aCompiler->setOrigColumns(rCols);
+ for ( ::std::vector< TPredicates >::iterator aIter = m_aSelectionEvaluations.begin(); aIter != m_aSelectionEvaluations.end();++aIter)
+ {
+ if ( aIter->first.isValid() )
+ aIter->first->setOrigColumns(rCols);
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/file/fcode.cxx b/connectivity/source/drivers/file/fcode.cxx
new file mode 100644
index 000000000000..9d4e1644d370
--- /dev/null
+++ b/connectivity/source/drivers/file/fcode.cxx
@@ -0,0 +1,519 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/fcode.hxx"
+#include <osl/diagnose.h>
+#include "connectivity/sqlparse.hxx"
+#include <i18npool/mslangid.hxx>
+#include <tools/debug.hxx>
+#include <tools/string.hxx>
+#include "TConnection.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::file;
+//using namespace ::com::sun::star::uno;
+//using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::sdb;
+//using namespace ::com::sun::star::container;
+//using namespace ::com::sun::star::beans;
+//using namespace ::com::sun::star::sdbcx;
+
+TYPEINIT0(OCode);
+TYPEINIT1(OOperand, OCode);
+TYPEINIT1(OOperandRow, OOperand);
+TYPEINIT1(OOperandAttr, OOperandRow);
+TYPEINIT1(OOperandParam, OOperandRow);
+TYPEINIT1(OOperandValue, OOperand);
+TYPEINIT1(OOperandConst, OOperandValue);
+TYPEINIT1(OOperandResult, OOperandValue);
+TYPEINIT1(OStopOperand, OOperandValue);
+
+TYPEINIT1(OOperator, OCode);
+TYPEINIT1(OBoolOperator,OOperator);
+TYPEINIT1(OOp_NOT, OBoolOperator);
+TYPEINIT1(OOp_AND, OBoolOperator);
+TYPEINIT1(OOp_OR, OBoolOperator);
+TYPEINIT1(OOp_ISNULL, OBoolOperator);
+TYPEINIT1(OOp_ISNOTNULL, OOp_ISNULL);
+TYPEINIT1(OOp_LIKE, OBoolOperator);
+TYPEINIT1(OOp_NOTLIKE, OOp_LIKE);
+TYPEINIT1(OOp_COMPARE, OBoolOperator);
+TYPEINIT1(ONumOperator, OOperator);
+TYPEINIT1(ONthOperator, OOperator);
+TYPEINIT1(OBinaryOperator, OOperator);
+TYPEINIT1(OUnaryOperator, OOperator);
+
+//------------------------------------------------------------------
+DBG_NAME(OCode )
+OCode::OCode()
+{
+ DBG_CTOR(OCode ,NULL);
+}
+// -----------------------------------------------------------------------------
+OCode::~OCode()
+{
+ DBG_DTOR(OCode,NULL);
+}
+
+//------------------------------------------------------------------
+OEvaluateSet* OOperand::preProcess(OBoolOperator* /*pOp*/, OOperand* /*pRight*/)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+OOperandRow::OOperandRow(sal_uInt16 _nPos, sal_Int32 _rType)
+ : OOperand(_rType)
+ , m_nRowPos(_nPos)
+{}
+//------------------------------------------------------------------
+void OOperandRow::bindValue(const OValueRefRow& _pRow)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::OOperandRow" );
+ OSL_ENSURE(_pRow.isValid(),"NO EMPTY row allowed!");
+ m_pRow = _pRow;
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ (m_pRow->get())[m_nRowPos]->setBound(sal_True);
+}
+// -----------------------------------------------------------------------------
+void OOperandRow::setValue(const ORowSetValue& _rVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::setValue" );
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ (*(m_pRow->get())[m_nRowPos]) = _rVal;
+}
+//------------------------------------------------------------------
+const ORowSetValue& OOperandRow::getValue() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandRow::getValue" );
+ OSL_ENSURE(m_pRow.isValid() && m_nRowPos < m_pRow->get().size(),"Invalid RowPos is >= vector.size()");
+ return (m_pRow->get())[m_nRowPos]->getValue();
+}
+
+// -----------------------------------------------------------------------------
+void OOperandValue::setValue(const ORowSetValue& _rVal)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandValue::setValue" );
+ m_aValue = _rVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool OOperandAttr::isIndexed() const
+{
+ return sal_False;
+}
+//------------------------------------------------------------------
+OOperandParam::OOperandParam(OSQLParseNode* pNode, sal_Int32 _nPos)
+ : OOperandRow(static_cast<sal_uInt16>(_nPos), DataType::VARCHAR) // Standard-Typ
+{
+ OSL_ENSURE(SQL_ISRULE(pNode,parameter),"Argument ist kein Parameter");
+ OSL_ENSURE(pNode->count() > 0,"Fehler im Parse Tree");
+ OSQLParseNode *pMark = pNode->getChild(0);
+
+ String aParameterName;
+ if (SQL_ISPUNCTUATION(pMark,"?"))
+ aParameterName = '?';
+ else if (SQL_ISPUNCTUATION(pMark,":"))
+ aParameterName = pNode->getChild(1)->getTokenValue();
+ else
+ {
+ OSL_ASSERT("Fehler im Parse Tree");
+ }
+
+ // Parameter-Column aufsetzen mit defult typ, kann zu einem spaeteren Zeitpunkt ueber DescribeParameter
+ // genauer spezifiziert werden
+
+ // Identitaet merken (hier eigentlich nicht erforderlich, aber aus
+ // Symmetriegruenden ...)
+
+ // todo
+ // OColumn* pColumn = new OFILEColumn(aParameterName,eDBType,255,0,SQL_FLAGS_NULLALLOWED);
+ // rParamColumns->AddColumn(pColumn);
+
+ // der Wert wird erst kurz vor der Auswertung gesetzt
+}
+
+
+//------------------------------------------------------------------
+const ORowSetValue& OOperandValue::getValue() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandValue::getValue" );
+ return m_aValue;
+}
+
+//------------------------------------------------------------------
+OOperandConst::OOperandConst(const OSQLParseNode& rColumnRef, const rtl::OUString& aStrValue)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandConst::OOperandConst" );
+ switch (rColumnRef.getNodeType())
+ {
+ case SQL_NODE_STRING:
+ m_aValue = aStrValue;
+ m_eDBType = DataType::VARCHAR;
+ m_aValue.setBound(sal_True);
+ return;
+ case SQL_NODE_INTNUM:
+ case SQL_NODE_APPROXNUM:
+ {
+ m_aValue = aStrValue.toDouble();
+ m_eDBType = DataType::DOUBLE;
+ m_aValue.setBound(sal_True);
+ return;
+ }
+ default:
+ break;
+ }
+
+ if (SQL_ISTOKEN(&rColumnRef,TRUE))
+ {
+ m_aValue = 1.0;
+ m_eDBType = DataType::BIT;
+ }
+ else if (SQL_ISTOKEN(&rColumnRef,FALSE))
+ {
+ m_aValue = 0.0;
+ m_eDBType = DataType::BIT;
+ }
+ else
+ {
+ OSL_ASSERT("Parse Error");
+ }
+ m_aValue.setBound(sal_True);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Implementation of the operators
+
+//------------------------------------------------------------------
+sal_uInt16 OOperator::getRequestedOperands() const {return 2;}
+
+//------------------------------------------------------------------
+sal_Bool OBoolOperator::operate(const OOperand*, const OOperand*) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBoolOperator::operate" );
+ return sal_False;
+}
+
+
+//------------------------------------------------------------------
+void OBoolOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBoolOperator::Exec" );
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pLeft, pRight)));
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+}
+//------------------------------------------------------------------
+sal_Bool OOp_NOT::operate(const OOperand* pLeft, const OOperand* ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_AND::operate" );
+ return !pLeft->isValid();
+}
+//------------------------------------------------------------------
+void OOp_NOT::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::Exec" );
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pOperand)));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+//------------------------------------------------------------------
+sal_uInt16 OOp_NOT::getRequestedOperands() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_NOT::getRequestedOperands" );
+ return 1;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_AND::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_AND::operate" );
+ return pLeft->isValid() && pRight->isValid();
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_OR::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_OR::operate" );
+ return pLeft->isValid() || pRight->isValid();
+}
+
+//------------------------------------------------------------------
+sal_uInt16 OOp_ISNULL::getRequestedOperands() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::getRequestedOperands" );
+ return 1;
+}
+
+//------------------------------------------------------------------
+void OOp_ISNULL::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::Exec" );
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultBOOL(operate(pOperand)));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_ISNULL::operate(const OOperand* pOperand, const OOperand*) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::operate" );
+ return pOperand->getValue().isNull();
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_ISNOTNULL::operate(const OOperand* pOperand, const OOperand*) const
+{
+ return !OOp_ISNULL::operate(pOperand);
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_LIKE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ISNULL::operate" );
+ sal_Bool bMatch;
+ ORowSetValue aLH(pLeft->getValue());
+ ORowSetValue aRH(pRight->getValue());
+
+ if (aLH.isNull() || aRH.isNull())
+ bMatch = sal_False;
+ else
+ {
+ bMatch = match(aRH.getString(), aLH.getString(), cEscape);
+ }
+ return bMatch;
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_NOTLIKE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_NOTLIKE::operate" );
+ return !OOp_LIKE::operate(pLeft, pRight);
+}
+
+//------------------------------------------------------------------
+sal_Bool OOp_COMPARE::operate(const OOperand* pLeft, const OOperand* pRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_COMPARE::operate" );
+ ORowSetValue aLH(pLeft->getValue());
+ ORowSetValue aRH(pRight->getValue());
+
+ if (aLH.isNull() || aRH.isNull()) // if (!aLH.getValue() || !aRH.getValue())
+ return sal_False;
+
+ sal_Bool bResult = sal_False;
+ sal_Int32 eDBType = pLeft->getDBType();
+
+ // Vergleich (je nach Datentyp):
+ switch (eDBType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ {
+ rtl::OUString sLH = aLH, sRH = aRH;
+ INT32 nRes = rtl_ustr_compareIgnoreAsciiCase_WithLength
+ (
+ sLH.pData->buffer,
+ sLH.pData->length,
+ sRH.pData->buffer,
+ sRH.pData->length );
+ switch(aPredicateType)
+ {
+ case SQLFilterOperator::EQUAL: bResult = (nRes == 0); break;
+ case SQLFilterOperator::NOT_EQUAL: bResult = (nRes != 0); break;
+ case SQLFilterOperator::LESS: bResult = (nRes < 0); break;
+ case SQLFilterOperator::LESS_EQUAL: bResult = (nRes <= 0); break;
+ case SQLFilterOperator::GREATER: bResult = (nRes > 0); break;
+ case SQLFilterOperator::GREATER_EQUAL: bResult = (nRes >= 0); break;
+ default: bResult = sal_False;
+ }
+ } break;
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::BIT:
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ double n = aLH ,m = aRH;
+
+ switch (aPredicateType)
+ {
+ case SQLFilterOperator::EQUAL: bResult = (n == m); break;
+ case SQLFilterOperator::LIKE: bResult = (n == m); break;
+ case SQLFilterOperator::NOT_EQUAL: bResult = (n != m); break;
+ case SQLFilterOperator::NOT_LIKE: bResult = (n != m); break;
+ case SQLFilterOperator::LESS: bResult = (n < m); break;
+ case SQLFilterOperator::LESS_EQUAL: bResult = (n <= m); break;
+ case SQLFilterOperator::GREATER: bResult = (n > m); break;
+ case SQLFilterOperator::GREATER_EQUAL: bResult = (n >= m); break;
+ default: bResult = sal_False;
+ }
+ } break;
+ default:
+ bResult = aLH == aRH;
+ }
+ return bResult;
+}
+
+//------------------------------------------------------------------
+void ONumOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ONumOperator::Exec" );
+
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResultNUM(operate(pLeft->getValue(), pRight->getValue())));
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+}
+//------------------------------------------------------------------
+double OOp_ADD::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_ADD::operate" );
+ return fLeft + fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_SUB::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_SUB::operate" );
+ return fLeft - fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_MUL::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_MUL::operate" );
+ return fLeft * fRight;
+}
+
+//------------------------------------------------------------------
+double OOp_DIV::operate(const double& fLeft,const double& fRight) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOp_DIV::operate" );
+ return fLeft / fRight;
+}
+// -----------------------------------------------------------------------------
+OEvaluateSet* OOperandAttr::preProcess(OBoolOperator* /*pOp*/, OOperand* /*pRight*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OOperandAttr::preProcess" );
+ return NULL;
+}
+//------------------------------------------------------------------
+void ONthOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "ONthOperator::Exec" );
+ ::std::vector<ORowSetValue> aValues;
+ ::std::vector<OOperand*> aOperands;
+ OOperand* pOperand;
+ do
+ {
+ OSL_ENSURE(!rCodeStack.empty(),"Stack must be none empty!");
+ pOperand = rCodeStack.top();
+ rCodeStack.pop();
+ if ( !IS_TYPE(OStopOperand,pOperand) )
+ aValues.push_back( pOperand->getValue() );
+ aOperands.push_back( pOperand );
+ }
+ while ( !IS_TYPE(OStopOperand,pOperand) );
+
+ rCodeStack.push(new OOperandResult(operate(aValues)));
+
+ ::std::vector<OOperand*>::iterator aIter = aOperands.begin();
+ ::std::vector<OOperand*>::iterator aEnd = aOperands.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if (IS_TYPE(OOperandResult,*aIter))
+ delete *aIter;
+ }
+}
+//------------------------------------------------------------------
+void OBinaryOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OBinaryOperator::Exec" );
+ OOperand *pRight = rCodeStack.top();
+ rCodeStack.pop();
+ OOperand *pLeft = rCodeStack.top();
+ rCodeStack.pop();
+
+ if ( !rCodeStack.empty() && IS_TYPE(OStopOperand,rCodeStack.top()) )
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResult(operate(pLeft->getValue(),pRight->getValue())));
+ if (IS_TYPE(OOperandResult,pRight))
+ delete pRight;
+ if (IS_TYPE(OOperandResult,pLeft))
+ delete pLeft;
+}
+//------------------------------------------------------------------
+void OUnaryOperator::Exec(OCodeStack& rCodeStack)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "OUnaryOperator::Exec" );
+ OSL_ENSURE(!rCodeStack.empty(),"Stack is empty!");
+ OOperand* pOperand = rCodeStack.top();
+ rCodeStack.pop();
+
+ rCodeStack.push(new OOperandResult(operate(pOperand->getValue())));
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+// -----------------------------------------------------------------------------
+sal_uInt16 OUnaryOperator::getRequestedOperands() const {return 1;}
+
+
+
diff --git a/connectivity/source/drivers/file/fcomp.cxx b/connectivity/source/drivers/file/fcomp.cxx
new file mode 100644
index 000000000000..eeaec1ff40f1
--- /dev/null
+++ b/connectivity/source/drivers/file/fcomp.cxx
@@ -0,0 +1,917 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/fcomp.hxx"
+#include <tools/debug.hxx>
+#include "TConnection.hxx"
+#include "connectivity/sqlparse.hxx"
+#include "file/fanalyzer.hxx"
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbconversion.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+#include "resource/file_res.hrc"
+#include "file/FStringFunctions.hxx"
+#include "file/FDateFunctions.hxx"
+#include "file/FNumericFunctions.hxx"
+#include "file/FConnection.hxx"
+#include <com/sun/star/sdb/SQLFilterOperator.hpp>
+
+using namespace connectivity;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdb;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::util;
+
+DBG_NAME(OPredicateCompiler)
+//------------------------------------------------------------------
+OPredicateCompiler::OPredicateCompiler(OSQLAnalyzer* pAnalyzer)//,OCursor& rCurs)
+ // : m_rCursor(rCurs)
+ : m_pAnalyzer(pAnalyzer)
+ , m_nParamCounter(0)
+ , m_bORCondition(FALSE)
+{
+ DBG_CTOR(OPredicateCompiler,NULL);
+}
+
+//------------------------------------------------------------------
+OPredicateCompiler::~OPredicateCompiler()
+{
+ Clean();
+ DBG_DTOR(OPredicateCompiler,NULL);
+}
+// -----------------------------------------------------------------------------
+void OPredicateCompiler::dispose()
+{
+ Clean();
+ m_orgColumns = NULL;
+m_xIndexes.clear();
+}
+//------------------------------------------------------------------
+// inline OCursor& OPredicateCompiler::Cursor() const {return m_rCursor;}
+//------------------------------------------------------------------
+void OPredicateCompiler::start(OSQLParseNode* pSQLParseNode)
+{
+ if (!pSQLParseNode)
+ return;
+
+ m_nParamCounter = 0;
+ // Parse Tree analysieren (je nach Statement-Typ)
+ // und Zeiger auf WHERE-Klausel setzen:
+ OSQLParseNode * pWhereClause = NULL;
+ OSQLParseNode * pOrderbyClause = NULL;
+
+ if (SQL_ISRULE(pSQLParseNode,select_statement))
+ {
+ DBG_ASSERT(pSQLParseNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode * pTableExp = pSQLParseNode->getChild(3);
+ DBG_ASSERT(pTableExp != NULL,"Fehler im Parse Tree");
+ DBG_ASSERT(SQL_ISRULE(pTableExp,table_exp)," Fehler im Parse Tree");
+ DBG_ASSERT(pTableExp->count() == 5,"Fehler im Parse Tree");
+
+ // check that we don't use anything other than count(*) as function
+ OSQLParseNode* pSelection = pSQLParseNode->getChild(2);
+ if ( SQL_ISRULE(pSelection,scalar_exp_commalist) )
+ {
+ for (sal_uInt32 i = 0; i < pSelection->count(); i++)
+ {
+ OSQLParseNode *pColumnRef = pSelection->getChild(i)->getChild(0);
+ if ( SQL_ISRULE(pColumnRef,general_set_fct) && pColumnRef->count() != 4 )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_COMPLEX_COUNT,NULL);
+ }
+ }
+ }
+
+
+ pWhereClause = pTableExp->getChild(1);
+ pOrderbyClause = pTableExp->getChild(4);
+ }
+ else if (SQL_ISRULE(pSQLParseNode,update_statement_searched))
+ {
+ DBG_ASSERT(pSQLParseNode->count() == 5,"OFILECursor: Fehler im Parse Tree");
+ pWhereClause = pSQLParseNode->getChild(4);
+ }
+ else if (SQL_ISRULE(pSQLParseNode,delete_statement_searched))
+ {
+ DBG_ASSERT(pSQLParseNode->count() == 4,"Fehler im Parse Tree");
+ pWhereClause = pSQLParseNode->getChild(3);
+ }
+ else
+ // Anderes Statement. Keine Selektionskriterien.
+ return;
+
+ if (SQL_ISRULE(pWhereClause,where_clause))
+ {
+ // Wenn es aber eine where_clause ist, dann darf sie nicht leer sein:
+ DBG_ASSERT(pWhereClause->count() == 2,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode * pComparisonPredicate = pWhereClause->getChild(1);
+ DBG_ASSERT(pComparisonPredicate != NULL,"OFILECursor: Fehler im Parse Tree");
+
+ execute( pComparisonPredicate );
+ }
+ else
+ {
+ // Die Where Clause ist meistens optional, d. h. es koennte sich auch
+ // um "optional_where_clause" handeln.
+ DBG_ASSERT(SQL_ISRULE(pWhereClause,opt_where_clause),"OPredicateCompiler: Fehler im Parse Tree");
+ }
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute(OSQLParseNode* pPredicateNode)
+{
+ OOperand* pOperand = NULL;
+ if (pPredicateNode->count() == 3 && // Ausdruck is geklammert
+ SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(pPredicateNode->getChild(2),")"))
+ {
+ execute(pPredicateNode->getChild(1));
+ }
+ else if ((SQL_ISRULE(pPredicateNode,search_condition) || (SQL_ISRULE(pPredicateNode,boolean_term)))
+ && // AND/OR-Verknuepfung:
+ pPredicateNode->count() == 3)
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+
+ if (SQL_ISTOKEN(pPredicateNode->getChild(1),OR)) // OR-Operator
+ {
+ m_aCodeList.push_back(new OOp_OR());
+ m_bORCondition = sal_True;
+ }
+ else if (SQL_ISTOKEN(pPredicateNode->getChild(1),AND)) // AND-Operator
+ m_aCodeList.push_back(new OOp_AND());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree");
+ }
+ }
+ else if (SQL_ISRULE(pPredicateNode,boolean_factor))
+ {
+ execute(pPredicateNode->getChild(1));
+ m_aCodeList.push_back(new OOp_NOT());
+ }
+ else if (SQL_ISRULE(pPredicateNode,comparison_predicate))
+ {
+ execute_COMPARE(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,like_predicate))
+ {
+ execute_LIKE(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,between_predicate))
+ {
+ execute_BETWEEN(pPredicateNode);
+ }
+ else if (SQL_ISRULE(pPredicateNode,test_for_null))
+ {
+ execute_ISNULL(pPredicateNode);
+ }
+ else if(SQL_ISRULE(pPredicateNode,num_value_exp))
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+ if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"+"))
+ {
+ m_aCodeList.push_back(new OOp_ADD());
+ }
+ else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"-"))
+ m_aCodeList.push_back(new OOp_SUB());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
+ }
+ }
+ else if(SQL_ISRULE(pPredicateNode,term))
+ {
+ execute(pPredicateNode->getChild(0)); // Bearbeiten des linken Zweigs
+ execute(pPredicateNode->getChild(2)); // Bearbeiten des rechten Zweigs
+ if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"*"))
+ {
+ m_aCodeList.push_back(new OOp_MUL());
+ }
+ else if (SQL_ISPUNCTUATION(pPredicateNode->getChild(1),"/"))
+ m_aCodeList.push_back(new OOp_DIV());
+ else
+ {
+ DBG_ERROR("OPredicateCompiler: Fehler im Parse Tree num_value_exp");
+ }
+ }
+ else
+ pOperand = execute_Operand(pPredicateNode); // jetzt werden nur einfache Operanden verarbeitet
+
+ return pOperand;
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_COMPARE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 3,"OFILECursor: Fehler im Parse Tree");
+
+ if ( !(SQL_ISRULE(pPredicateNode->getChild(0),column_ref) ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_STRING ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_INTNUM ||
+ pPredicateNode->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM ||
+ SQL_ISTOKEN(pPredicateNode->getChild(2),TRUE) ||
+ SQL_ISTOKEN(pPredicateNode->getChild(2),FALSE) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),parameter) ||
+ // odbc date
+ SQL_ISRULE(pPredicateNode->getChild(2),set_fct_spec) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),position_exp) ||
+ SQL_ISRULE(pPredicateNode->getChild(2),char_substring_fct) ||
+ // upper, lower etc.
+ SQL_ISRULE(pPredicateNode->getChild(2),fold)) )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+ return NULL;
+ }
+
+ sal_Int32 ePredicateType( SQLFilterOperator::EQUAL );
+ OSQLParseNode *pPrec = pPredicateNode->getChild(1);
+
+ if (pPrec->getNodeType() == SQL_NODE_EQUAL)
+ ePredicateType = SQLFilterOperator::EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL)
+ ePredicateType = SQLFilterOperator::NOT_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_LESS)
+ ePredicateType = SQLFilterOperator::LESS;
+ else if (pPrec->getNodeType() == SQL_NODE_LESSEQ)
+ ePredicateType = SQLFilterOperator::LESS_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_GREATEQ)
+ ePredicateType = SQLFilterOperator::GREATER_EQUAL;
+ else if (pPrec->getNodeType() == SQL_NODE_GREAT)
+ ePredicateType = SQLFilterOperator::GREATER;
+ else
+ OSL_ENSURE( false, "OPredicateCompiler::execute_COMPARE: unexpected node type!" );
+
+ execute(pPredicateNode->getChild(0));
+ execute(pPredicateNode->getChild(2));
+ m_aCodeList.push_back( new OOp_COMPARE(ePredicateType) );
+
+ return NULL;
+}
+
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_LIKE(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
+ const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
+
+ sal_Unicode cEscape = L'\0';
+ const bool bNotLike = pPart2->getChild(0)->isToken();
+
+ OSQLParseNode* pAtom = pPart2->getChild(pPart2->count()-2);
+ OSQLParseNode* pOptEscape = pPart2->getChild(pPart2->count()-1);
+
+ if (!(pAtom->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(pAtom,parameter)))
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ if (pOptEscape->count() != 0)
+ {
+ if (pOptEscape->count() != 2)
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ OSQLParseNode *pEscNode = pOptEscape->getChild(1);
+ if (pEscNode->getNodeType() != SQL_NODE_STRING)
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_LIKE_STRING,NULL);
+ }
+ else
+ cEscape = pEscNode->getTokenValue().toChar();
+ }
+
+ execute(pPredicateNode->getChild(0));
+ execute(pAtom);
+
+ OBoolOperator* pOperator = bNotLike
+ ? new OOp_NOTLIKE(cEscape)
+ : new OOp_LIKE(cEscape);
+ m_aCodeList.push_back(pOperator);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_BETWEEN(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
+
+ OSQLParseNode* pColumn = pPredicateNode->getChild(0);
+ const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
+ OSQLParseNode* p1stValue = pPart2->getChild(2);
+ OSQLParseNode* p2ndtValue = pPart2->getChild(4);
+
+ if (
+ !(p1stValue->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(p1stValue,parameter))
+ && !(p2ndtValue->getNodeType() == SQL_NODE_STRING || SQL_ISRULE(p2ndtValue,parameter))
+ )
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_INVALID_BETWEEN,NULL);
+ }
+
+ sal_Bool bNot = SQL_ISTOKEN(pPart2->getChild(0),NOT);
+
+ OOperand* pColumnOp = execute(pColumn);
+ OOperand* pOb1 = execute(p1stValue);
+ OBoolOperator* pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::LESS_EQUAL : SQLFilterOperator::GREATER);
+ m_aCodeList.push_back(pOperator);
+
+ execute(pColumn);
+ OOperand* pOb2 = execute(p2ndtValue);
+ pOperator = new OOp_COMPARE(bNot ? SQLFilterOperator::GREATER_EQUAL : SQLFilterOperator::LESS);
+ m_aCodeList.push_back(pOperator);
+
+ if ( pColumnOp && pOb1 && pOb2 )
+ {
+ switch(pColumnOp->getDBType())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ pOb1->setValue(pOb1->getValue().getString());
+ pOb2->setValue(pOb2->getValue().getString());
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ pOb1->setValue((double)pOb1->getValue());
+ pOb2->setValue((double)pOb2->getValue());
+ break;
+ case DataType::FLOAT:
+ pOb1->setValue((float)pOb1->getValue());
+ pOb2->setValue((float)pOb2->getValue());
+ break;
+ case DataType::DOUBLE:
+ case DataType::REAL:
+ pOb1->setValue((double)pOb1->getValue());
+ pOb2->setValue((double)pOb2->getValue());
+ break;
+ case DataType::DATE:
+ pOb1->setValue((Date)pOb1->getValue());
+ pOb2->setValue((Date)pOb2->getValue());
+ break;
+ case DataType::TIME:
+ pOb1->setValue((Time)pOb1->getValue());
+ pOb2->setValue((Time)pOb2->getValue());
+ break;
+ case DataType::TIMESTAMP:
+ pOb1->setValue((DateTime)pOb1->getValue());
+ pOb2->setValue((DateTime)pOb2->getValue());
+ break;
+ }
+ }
+
+
+
+ OBoolOperator* pBoolOp = NULL;
+ if ( bNot )
+ pBoolOp = new OOp_OR();
+ else
+ pBoolOp = new OOp_AND();
+ m_aCodeList.push_back(pBoolOp);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_ISNULL(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() == 2,"OFILECursor: Fehler im Parse Tree");
+ const OSQLParseNode* pPart2 = pPredicateNode->getChild(1);
+ DBG_ASSERT(SQL_ISTOKEN(pPart2->getChild(0),IS),"OFILECursor: Fehler im Parse Tree");
+
+ sal_Int32 ePredicateType;
+ if (SQL_ISTOKEN(pPart2->getChild(1),NOT))
+ ePredicateType = SQLFilterOperator::NOT_SQLNULL;
+ else
+ ePredicateType = SQLFilterOperator::SQLNULL;
+
+ execute(pPredicateNode->getChild(0));
+ OBoolOperator* pOperator = (ePredicateType == SQLFilterOperator::SQLNULL) ?
+ new OOp_ISNULL() : new OOp_ISNOTNULL();
+ m_aCodeList.push_back(pOperator);
+
+ return NULL;
+}
+//------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_Operand(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ OOperand* pOperand = NULL;
+
+ if (SQL_ISRULE(pPredicateNode,column_ref))
+ {
+ ::rtl::OUString aColumnName;
+ if (pPredicateNode->count() == 1)
+ {
+ aColumnName = pPredicateNode->getChild(0)->getTokenValue();
+ }
+ else if (pPredicateNode->count() == 3)
+ {
+ ::rtl::OUString aTableName = pPredicateNode->getChild(0)->getTokenValue();
+ if(SQL_ISRULE(pPredicateNode->getChild(2),column_val))
+ aColumnName = pPredicateNode->getChild(2)->getChild(0)->getTokenValue();
+ else
+ aColumnName = pPredicateNode->getChild(2)->getTokenValue();
+ }
+
+ if(!m_orgColumns->hasByName(aColumnName))
+ {
+ const ::rtl::OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", aColumnName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, NULL );
+ }
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> xCol;
+ try
+ {
+ if (m_orgColumns->getByName(aColumnName) >>= xCol)
+ {
+ pOperand = m_pAnalyzer->createOperandAttr(Reference< XColumnLocate>(m_orgColumns,UNO_QUERY)->findColumn(aColumnName),xCol,m_xIndexes);
+ }
+ else
+ {// Column existiert nicht im Resultset
+ const ::rtl::OUString sError( m_pAnalyzer->getConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", aColumnName
+ ) );
+ ::dbtools::throwGenericSQLException( sError, NULL );
+ }
+ }
+ catch(Exception &)
+ {
+ OSL_ENSURE(0,"OPredicateCompiler::execute_Operand Exception");
+ }
+ }
+ else if (SQL_ISRULE(pPredicateNode,parameter))
+ {
+ pOperand = new OOperandParam(pPredicateNode, ++m_nParamCounter);
+ }
+ else if (pPredicateNode->getNodeType() == SQL_NODE_STRING ||
+ pPredicateNode->getNodeType() == SQL_NODE_INTNUM ||
+ pPredicateNode->getNodeType() == SQL_NODE_APPROXNUM ||
+ pPredicateNode->getNodeType() == SQL_NODE_NAME ||
+ SQL_ISTOKEN(pPredicateNode,TRUE) ||
+ SQL_ISTOKEN(pPredicateNode,FALSE) ||
+ SQL_ISRULE(pPredicateNode,parameter))
+ {
+ pOperand = new OOperandConst(*pPredicateNode, pPredicateNode->getTokenValue());
+ }
+ else if((pPredicateNode->count() == 2) &&
+ (SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"+") || SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"-")) &&
+ pPredicateNode->getChild(1)->getNodeType() == SQL_NODE_INTNUM)
+ { // falls -1 bzw. +1 vorhanden ist
+ ::rtl::OUString aValue(pPredicateNode->getChild(0)->getTokenValue());
+ aValue += pPredicateNode->getChild(1)->getTokenValue();
+ pOperand = new OOperandConst(*pPredicateNode->getChild(1), aValue);
+ }
+ else if( SQL_ISRULE(pPredicateNode,set_fct_spec) && SQL_ISPUNCTUATION(pPredicateNode->getChild(0),"{") )
+ {
+ const OSQLParseNode* pODBCNode = pPredicateNode->getChild(1);
+ const OSQLParseNode* pODBCNodeChild = pODBCNode->getChild(0);
+
+ // Odbc Date or time
+ if (pODBCNodeChild->getNodeType() == SQL_NODE_KEYWORD && (
+ SQL_ISTOKEN(pODBCNodeChild,D) ||
+ SQL_ISTOKEN(pODBCNodeChild,T) ||
+ SQL_ISTOKEN(pODBCNodeChild,TS) ))
+ {
+ ::rtl::OUString sDateTime = pODBCNode->getChild(1)->getTokenValue();
+ pOperand = new OOperandConst(*pODBCNode->getChild(1), sDateTime);
+ if(SQL_ISTOKEN(pODBCNodeChild,D))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(sDateTime)));
+ }
+ else if(SQL_ISTOKEN(pODBCNodeChild,T))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(sDateTime)));
+ }
+ else if(SQL_ISTOKEN(pODBCNodeChild,TS))
+ {
+ pOperand->setValue(::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(sDateTime)));
+ }
+ }
+ else
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+
+ }
+ else if( SQL_ISRULE(pPredicateNode,fold) )
+ {
+ execute_Fold(pPredicateNode);
+ }
+ else if( SQL_ISRULE(pPredicateNode,set_fct_spec)
+ || SQL_ISRULE(pPredicateNode,position_exp)
+ || SQL_ISRULE(pPredicateNode,char_substring_fct)
+ )
+ {
+ executeFunction(pPredicateNode);
+ }
+ else if( SQL_ISRULE(pPredicateNode,length_exp) )
+ {
+ executeFunction(pPredicateNode->getChild(0));
+ }
+ else
+ {
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_TOO_COMPLEX,NULL);
+ }
+ if (pOperand)
+ m_aCodeList.push_back(pOperand);
+ return pOperand;
+}
+
+////////////////////////////////////////////////////////////////////////////////////////
+sal_Bool OPredicateInterpreter::evaluate(OCodeList& rCodeList)
+{
+ static sal_Bool bResult;
+
+ OCodeList::iterator aIter = rCodeList.begin();
+ if (!(*aIter))
+ return sal_True; // kein Praedikat
+
+ for(;aIter != rCodeList.end();++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ if (pOperand)
+ m_aStack.push(pOperand);
+ else
+ ((OOperator *)(*aIter))->Exec(m_aStack);
+ }
+
+ OOperand* pOperand = m_aStack.top();
+ m_aStack.pop();
+
+ DBG_ASSERT(m_aStack.size() == 0, "StackFehler");
+ DBG_ASSERT(pOperand, "StackFehler");
+
+ bResult = pOperand->isValid();
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+ return bResult;
+}
+// -----------------------------------------------------------------------------
+void OPredicateInterpreter::evaluateSelection(OCodeList& rCodeList,ORowSetValueDecoratorRef& _rVal)
+{
+ OCodeList::iterator aIter = rCodeList.begin();
+ if (!(*aIter))
+ return ; // kein Praedikat
+
+ for(;aIter != rCodeList.end();++aIter)
+ {
+ OOperand* pOperand = PTR_CAST(OOperand,(*aIter));
+ if (pOperand)
+ m_aStack.push(pOperand);
+ else
+ ((OOperator *)(*aIter))->Exec(m_aStack);
+ }
+
+ OOperand* pOperand = m_aStack.top();
+ m_aStack.pop();
+
+ DBG_ASSERT(m_aStack.size() == 0, "StackFehler");
+ DBG_ASSERT(pOperand, "StackFehler");
+
+ (*_rVal) = pOperand->getValue();
+ if (IS_TYPE(OOperandResult,pOperand))
+ delete pOperand;
+}
+// -----------------------------------------------------------------------------
+OOperand* OPredicateCompiler::execute_Fold(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ DBG_ASSERT(pPredicateNode->count() >= 4,"OFILECursor: Fehler im Parse Tree");
+
+ sal_Bool bUpper = SQL_ISTOKEN(pPredicateNode->getChild(0),UPPER);
+
+ execute(pPredicateNode->getChild(2));
+ OOperator* pOperator = NULL;
+ if ( bUpper )
+ pOperator = new OOp_Upper();
+ else
+ pOperator = new OOp_Lower();
+
+ m_aCodeList.push_back(pOperator);
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+OOperand* OPredicateCompiler::executeFunction(OSQLParseNode* pPredicateNode) throw(SQLException, RuntimeException)
+{
+ OOperator* pOperator = NULL;
+
+ OSL_ENSURE(pPredicateNode->getChild(0)->isToken(),"The first one must be the name of the function!");
+ sal_Int32 nTokenId = pPredicateNode->getChild(0)->getTokenID();
+ switch ( nTokenId )
+ {
+ case SQL_TOKEN_CHAR_LENGTH:
+ case SQL_TOKEN_LENGTH:
+ case SQL_TOKEN_OCTET_LENGTH:
+ case SQL_TOKEN_ASCII:
+ case SQL_TOKEN_LCASE:
+ case SQL_TOKEN_LTRIM:
+ case SQL_TOKEN_RTRIM:
+ case SQL_TOKEN_SPACE:
+ case SQL_TOKEN_UCASE:
+ case SQL_TOKEN_ABS:
+ case SQL_TOKEN_ACOS:
+ case SQL_TOKEN_ASIN:
+ case SQL_TOKEN_ATAN:
+ case SQL_TOKEN_CEILING:
+ case SQL_TOKEN_COS:
+ case SQL_TOKEN_DEGREES:
+ case SQL_TOKEN_EXP:
+ case SQL_TOKEN_FLOOR:
+ case SQL_TOKEN_LOG10:
+ case SQL_TOKEN_LN:
+ case SQL_TOKEN_RADIANS:
+ case SQL_TOKEN_SIGN:
+ case SQL_TOKEN_SIN:
+ case SQL_TOKEN_SQRT:
+ case SQL_TOKEN_TAN:
+ case SQL_TOKEN_DAYNAME:
+ case SQL_TOKEN_DAYOFMONTH:
+ case SQL_TOKEN_DAYOFWEEK:
+ case SQL_TOKEN_DAYOFYEAR:
+ case SQL_TOKEN_HOUR:
+ case SQL_TOKEN_MINUTE:
+ case SQL_TOKEN_MONTH:
+ case SQL_TOKEN_MONTHNAME:
+ case SQL_TOKEN_QUARTER:
+ case SQL_TOKEN_SECOND:
+ case SQL_TOKEN_YEAR:
+
+ execute(pPredicateNode->getChild(2));
+
+ switch( nTokenId )
+ {
+ case SQL_TOKEN_CHAR_LENGTH:
+ case SQL_TOKEN_LENGTH:
+ case SQL_TOKEN_OCTET_LENGTH:
+ pOperator = new OOp_CharLength();
+ break;
+ case SQL_TOKEN_ASCII:
+ pOperator = new OOp_Ascii();
+ break;
+ case SQL_TOKEN_LCASE:
+ pOperator = new OOp_Lower();
+ break;
+
+ case SQL_TOKEN_LTRIM:
+ pOperator = new OOp_LTrim();
+ break;
+ case SQL_TOKEN_RTRIM:
+ pOperator = new OOp_RTrim();
+ break;
+ case SQL_TOKEN_SPACE:
+ pOperator = new OOp_Space();
+ break;
+ case SQL_TOKEN_UCASE:
+ pOperator = new OOp_Upper();
+ break;
+ case SQL_TOKEN_ABS:
+ pOperator = new OOp_Abs();
+ break;
+ case SQL_TOKEN_ACOS:
+ pOperator = new OOp_ACos();
+ break;
+ case SQL_TOKEN_ASIN:
+ pOperator = new OOp_ASin();
+ break;
+ case SQL_TOKEN_ATAN:
+ pOperator = new OOp_ATan();
+ break;
+ case SQL_TOKEN_CEILING:
+ pOperator = new OOp_Ceiling();
+ break;
+ case SQL_TOKEN_COS:
+ pOperator = new OOp_Cos();
+ break;
+ case SQL_TOKEN_DEGREES:
+ pOperator = new OOp_Degrees();
+ break;
+ case SQL_TOKEN_EXP:
+ pOperator = new OOp_Exp();
+ break;
+ case SQL_TOKEN_FLOOR:
+ pOperator = new OOp_Floor();
+ break;
+ case SQL_TOKEN_LOG10:
+ pOperator = new OOp_Log10();
+ break;
+ case SQL_TOKEN_LN:
+ pOperator = new OOp_Ln();
+ break;
+ case SQL_TOKEN_RADIANS:
+ pOperator = new OOp_Radians();
+ break;
+ case SQL_TOKEN_SIGN:
+ pOperator = new OOp_Sign();
+ break;
+ case SQL_TOKEN_SIN:
+ pOperator = new OOp_Sin();
+ break;
+ case SQL_TOKEN_SQRT:
+ pOperator = new OOp_Sqrt();
+ break;
+ case SQL_TOKEN_TAN:
+ pOperator = new OOp_Tan();
+ break;
+ case SQL_TOKEN_DAYOFWEEK:
+ pOperator = new OOp_DayOfWeek();
+ break;
+ case SQL_TOKEN_DAYOFMONTH:
+ pOperator = new OOp_DayOfMonth();
+ break;
+ case SQL_TOKEN_DAYOFYEAR:
+ pOperator = new OOp_DayOfYear();
+ break;
+ case SQL_TOKEN_MONTH:
+ pOperator = new OOp_Month();
+ break;
+ case SQL_TOKEN_DAYNAME:
+ pOperator = new OOp_DayName();
+ break;
+ case SQL_TOKEN_MONTHNAME:
+ pOperator = new OOp_MonthName();
+ break;
+ case SQL_TOKEN_QUARTER:
+ pOperator = new OOp_Quarter();
+ break;
+ case SQL_TOKEN_YEAR:
+ pOperator = new OOp_Year();
+ break;
+ case SQL_TOKEN_HOUR:
+ pOperator = new OOp_Hour();
+ break;
+ case SQL_TOKEN_MINUTE:
+ pOperator = new OOp_Minute();
+ break;
+ case SQL_TOKEN_SECOND:
+ pOperator = new OOp_Second();
+ break;
+ default:
+ OSL_ENSURE(0,"Error in switch!");
+ }
+ break;
+ case SQL_TOKEN_CHAR:
+ case SQL_TOKEN_CONCAT:
+ case SQL_TOKEN_INSERT:
+ case SQL_TOKEN_LEFT:
+ case SQL_TOKEN_LOCATE:
+ case SQL_TOKEN_LOCATE_2:
+ case SQL_TOKEN_REPEAT:
+ case SQL_TOKEN_REPLACE:
+ case SQL_TOKEN_RIGHT:
+ case SQL_TOKEN_MOD:
+ case SQL_TOKEN_ROUND:
+ case SQL_TOKEN_LOGF:
+ case SQL_TOKEN_LOG:
+ case SQL_TOKEN_POWER:
+ case SQL_TOKEN_ATAN2:
+ case SQL_TOKEN_PI:
+ case SQL_TOKEN_CURDATE:
+ case SQL_TOKEN_CURTIME:
+ case SQL_TOKEN_NOW:
+ case SQL_TOKEN_WEEK:
+ {
+ m_aCodeList.push_back(new OStopOperand);
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+
+ switch( nTokenId )
+ {
+ case SQL_TOKEN_CHAR:
+ pOperator = new OOp_Char();
+ break;
+ case SQL_TOKEN_CONCAT:
+ pOperator = new OOp_Concat();
+ break;
+ case SQL_TOKEN_INSERT:
+ pOperator = new OOp_Insert();
+ break;
+ case SQL_TOKEN_LEFT:
+ pOperator = new OOp_Left();
+ break;
+ case SQL_TOKEN_LOCATE:
+ case SQL_TOKEN_LOCATE_2:
+ pOperator = new OOp_Locate();
+ break;
+ case SQL_TOKEN_REPEAT:
+ pOperator = new OOp_Repeat();
+ break;
+ case SQL_TOKEN_REPLACE:
+ pOperator = new OOp_Replace();
+ break;
+ case SQL_TOKEN_RIGHT:
+ pOperator = new OOp_Right();
+ break;
+ case SQL_TOKEN_MOD:
+ pOperator = new OOp_Mod();
+ break;
+ case SQL_TOKEN_ROUND:
+ pOperator = new OOp_Round();
+ break;
+ case SQL_TOKEN_LOGF:
+ case SQL_TOKEN_LOG:
+ pOperator = new OOp_Log();
+ break;
+ case SQL_TOKEN_POWER:
+ pOperator = new OOp_Pow();
+ break;
+ case SQL_TOKEN_ATAN2:
+ pOperator = new OOp_ATan2();
+ break;
+ case SQL_TOKEN_PI:
+ pOperator = new OOp_Pi();
+ break;
+ case SQL_TOKEN_CURDATE:
+ pOperator = new OOp_CurDate();
+ break;
+ case SQL_TOKEN_CURTIME:
+ pOperator = new OOp_CurTime();
+ break;
+ case SQL_TOKEN_NOW:
+ pOperator = new OOp_Now();
+ break;
+ case SQL_TOKEN_WEEK:
+ pOperator = new OOp_Week();
+ break;
+ default:
+ OSL_ENSURE(0,"Error in switch!");
+ }
+ }
+ break;
+
+ case SQL_TOKEN_SUBSTRING:
+ m_aCodeList.push_back(new OStopOperand);
+ if ( pPredicateNode->count() == 4 ) //char_substring_fct
+ {
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+ }
+ else
+ {
+ execute(pPredicateNode->getChild(2));
+ execute(pPredicateNode->getChild(4));
+ execute(pPredicateNode->getChild(5)->getChild(1));
+ }
+ pOperator = new OOp_SubString();
+ break;
+
+ case SQL_TOKEN_POSITION:
+ m_aCodeList.push_back(new OStopOperand);
+ if ( pPredicateNode->count() == 4 ) //position_exp
+ {
+ OSQLParseNode* pList = pPredicateNode->getChild(2);
+ for (sal_uInt32 i=0; i < pList->count(); ++i)
+ execute(pList->getChild(i));
+ }
+ else
+ {
+ execute(pPredicateNode->getChild(2));
+ execute(pPredicateNode->getChild(4));
+ }
+ pOperator = new OOp_Locate();
+ break;
+ default:
+ m_pAnalyzer->getConnection()->throwGenericSQLException(STR_QUERY_FUNCTION_NOT_SUPPORTED,NULL);
+ }
+
+ m_aCodeList.push_back(pOperator);
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/file/file.xml b/connectivity/source/drivers/file/file.xml
new file mode 100644
index 000000000000..9e8fc7e7a095
--- /dev/null
+++ b/connectivity/source/drivers/file/file.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Ocke Jannsen</author>
+ <name>com.sun.star.sdbc.driver.file.Driver</name>
+ <description>This library implements basic functionallity for file-base drivers.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/file/makefile.mk b/connectivity/source/drivers/file/makefile.mk
new file mode 100644
index 000000000000..6cc615a0cc32
--- /dev/null
+++ b/connectivity/source/drivers/file/makefile.mk
@@ -0,0 +1,108 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=file
+
+USE_DEFFILE=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+CDEFS += -DOOO_DLLIMPLEMENTATION_FILE
+
+# --- Files -------------------------------------
+EXCEPTIONSFILES=\
+ $(SLO)$/FNoException.obj \
+ $(SLO)$/FConnection.obj \
+ $(SLO)$/FResultSetMetaData.obj \
+ $(SLO)$/FColumns.obj \
+ $(SLO)$/FTables.obj \
+ $(SLO)$/FTable.obj \
+ $(SLO)$/FCatalog.obj \
+ $(SLO)$/FResultSet.obj \
+ $(SLO)$/FStatement.obj \
+ $(SLO)$/FPreparedStatement.obj \
+ $(SLO)$/FDatabaseMetaData.obj \
+ $(SLO)$/FDriver.obj \
+ $(SLO)$/fanalyzer.obj \
+ $(SLO)$/fcomp.obj \
+ $(SLO)$/fcode.obj
+
+SLOFILES=\
+ $(EXCEPTIONSFILES) \
+ $(SLO)$/FStringFunctions.obj \
+ $(SLO)$/FDateFunctions.obj \
+ $(SLO)$/FNumericFunctions.obj \
+ $(SLO)$/quotedstring.obj
+
+
+# --- Library -----------------------------------
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SVLLIB) \
+ $(TOOLSLIB) \
+ $(UCBHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \
+ $(SLB)$/$(TARGET).lib
+DEFLIB1NAME=$(TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+
+# --- filter file ------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo _TI >$@
+ @echo _real >>$@
+
diff --git a/connectivity/source/drivers/file/quotedstring.cxx b/connectivity/source/drivers/file/quotedstring.cxx
new file mode 100644
index 000000000000..9b315f8cce85
--- /dev/null
+++ b/connectivity/source/drivers/file/quotedstring.cxx
@@ -0,0 +1,164 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "file/quotedstring.hxx"
+#include <rtl/logfile.hxx>
+
+namespace connectivity
+{
+ //==================================================================
+ //= QuotedTokenizedString
+ //==================================================================
+ //------------------------------------------------------------------
+ xub_StrLen QuotedTokenizedString::GetTokenCount( sal_Unicode cTok, sal_Unicode cStrDel ) const
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
+ const xub_StrLen nLen = m_sString.Len();
+ if ( !nLen )
+ return 0;
+
+ xub_StrLen nTokCount = 1;
+ BOOL bStart = TRUE; // Stehen wir auf dem ersten Zeichen im Token?
+ BOOL bInString = FALSE; // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = 0; i < nLen; ++i )
+ {
+ const sal_Unicode cChar = m_sString.GetChar(i);
+ if (bStart)
+ {
+ bStart = FALSE;
+ // Erstes Zeichen ein String-Delimiter?
+ if ( cChar == cStrDel )
+ {
+ bInString = TRUE; // dann sind wir jetzt INNERHALB des Strings!
+ continue; // dieses Zeichen ueberlesen!
+ }
+ }
+
+ if (bInString)
+ {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( cChar == cStrDel )
+ {
+ if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ ++i; // kein String-Ende, naechstes Zeichen ueberlesen.
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ }
+ }
+ } // if (bInString)
+ else
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe TokCount
+ if ( cChar == cTok )
+ {
+ ++nTokCount;
+ bStart = TRUE;
+ }
+ }
+ }
+ //OSL_TRACE("QuotedTokenizedString::nTokCount = %d\n", ((OUtoCStr(::rtl::OUString(nTokCount))) ? (OUtoCStr(::rtl::OUString(nTokCount))):("NULL")) );
+
+ return nTokCount;
+ }
+
+ //------------------------------------------------------------------
+ void QuotedTokenizedString::GetTokenSpecial( String& _rStr,xub_StrLen& nStartPos, sal_Unicode cTok, sal_Unicode cStrDel ) const
+ {
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "file", "Ocke.Janssen@sun.com", "QuotedTokenizedString::GetTokenCount" );
+ _rStr.Erase();
+ const xub_StrLen nLen = m_sString.Len();
+ if ( nLen )
+ {
+ BOOL bInString = (nStartPos < nLen) && (m_sString.GetChar(nStartPos) == cStrDel); // Befinden wir uns INNERHALB eines (cStrDel delimited) String?
+
+ // Erstes Zeichen ein String-Delimiter?
+ if (bInString )
+ ++nStartPos; // dieses Zeichen ueberlesen!
+ if ( nStartPos >= nLen )
+ return;
+
+ sal_Unicode* pData = _rStr.AllocBuffer( nLen - nStartPos + 1 );
+ const sal_Unicode* pStart = pData;
+ // Suche bis Stringende nach dem ersten nicht uebereinstimmenden Zeichen
+ for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ {
+ const sal_Unicode cChar = m_sString.GetChar(i);
+ if (bInString)
+ {
+ // Wenn jetzt das String-Delimiter-Zeichen auftritt ...
+ if ( cChar == cStrDel )
+ {
+ if ((i+1 < nLen) && (m_sString.GetChar(i+1) == cStrDel))
+ {
+ // Verdoppeltes String-Delimiter-Zeichen:
+ // kein String-Ende, naechstes Zeichen ueberlesen.
+ ++i;
+ *pData++ = m_sString.GetChar(i); // Zeichen gehoert zum Resultat-String
+ }
+ else
+ {
+ // String-Ende
+ bInString = FALSE;
+ *pData = 0;
+ }
+ }
+ else
+ {
+ *pData++ = cChar; // Zeichen gehoert zum Resultat-String
+ }
+
+ }
+ else
+ {
+ // Stimmt das Tokenzeichen ueberein, dann erhoehe nTok
+ if ( cChar == cTok )
+ {
+ // Vorzeitiger Abbruch der Schleife moeglich, denn
+ // wir haben, was wir wollten.
+ nStartPos = i+1;
+ break;
+ }
+ else
+ {
+ *pData++ = cChar; // Zeichen gehoert zum Resultat-String
+ }
+ }
+ } // for( xub_StrLen i = nStartPos; i < nLen; ++i )
+ *pData = 0;
+ _rStr.ReleaseBufferAccess(xub_StrLen(pData - pStart));
+ }
+ }
+}
diff --git a/connectivity/source/drivers/flat/ECatalog.cxx b/connectivity/source/drivers/flat/ECatalog.cxx
new file mode 100644
index 000000000000..2e498cc45b29
--- /dev/null
+++ b/connectivity/source/drivers/flat/ECatalog.cxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "flat/ECatalog.hxx"
+
+#ifndef _CONNECTIVITY_FLAT_DCONNECTION_HXX_
+#include "flat/EConnection.hxx"
+#endif
+#include "flat/ETables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+// -------------------------------------------------------------------------
+using namespace connectivity::flat;
+// -------------------------------------------------------------------------
+OFlatCatalog::OFlatCatalog(OFlatConnection* _pCon) : file::OFileCatalog(_pCon)
+{
+}
+// -------------------------------------------------------------------------
+void OFlatCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString::createFromAscii("%"),::rtl::OUString::createFromAscii("%"),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ aVector.push_back(xRow->getString(3));
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OFlatTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/flat/EColumns.cxx b/connectivity/source/drivers/flat/EColumns.cxx
new file mode 100644
index 000000000000..29ac131dd21b
--- /dev/null
+++ b/connectivity/source/drivers/flat/EColumns.cxx
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/EColumns.hxx"
+#include "flat/ETable.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+sdbcx::ObjectType OFlatColumns::createObject(const ::rtl::OUString& _rName)
+{
+
+ OFlatTable* pTable = (OFlatTable*)m_pTable;
+ ::vos::ORef<OSQLColumns> aCols = pTable->getTableColumns();
+ OSQLColumns::Vector::const_iterator aIter = find(aCols->get().begin(),aCols->get().end(),_rName,::comphelper::UStringMixEqual(isCaseSensitive()));
+ sdbcx::ObjectType xRet;
+ if(aIter != aCols->get().end())
+ xRet = sdbcx::ObjectType(*aIter,UNO_QUERY);
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EConnection.cxx b/connectivity/source/drivers/flat/EConnection.cxx
new file mode 100644
index 000000000000..c9cec7b5ee10
--- /dev/null
+++ b/connectivity/source/drivers/flat/EConnection.cxx
@@ -0,0 +1,181 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/EConnection.hxx"
+#include "flat/EDatabaseMetaData.hxx"
+#include "flat/ECatalog.hxx"
+#ifndef _CONNECTIVITY_FLAT_ODRIVER_HXX_
+#include "flat/EDriver.hxx"
+#endif
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <tools/urlobj.hxx>
+#include "flat/EPreparedStatement.hxx"
+#ifndef _CONNECTIVITY_FLAT_DSTATEMENT_HXX_
+#include "flat/EStatement.hxx"
+#endif
+#include <comphelper/extract.hxx>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+
+typedef connectivity::file::OConnection OConnection_B;
+
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+// --------------------------------------------------------------------------------
+OFlatConnection::OFlatConnection(ODriver* _pDriver) : OConnection(_pDriver)
+ ,m_bHeaderLine(sal_True)
+ ,m_cFieldDelimiter(';')
+ ,m_cStringDelimiter('"')
+ ,m_cDecimalDelimiter(',')
+ ,m_cThousandDelimiter('.')
+{
+}
+//-----------------------------------------------------------------------------
+OFlatConnection::~OFlatConnection()
+{
+}
+
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatConnection, "com.sun.star.sdbc.drivers.flat.Connection", "com.sun.star.sdbc.Connection")
+
+//-----------------------------------------------------------------------------
+void OFlatConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ ::rtl::OUString aExt;
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!pBegin->Name.compareToAscii("HeaderLine"))
+ OSL_VERIFY( pBegin->Value >>= m_bHeaderLine );
+ else if(!pBegin->Name.compareToAscii("FieldDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cFieldDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("StringDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cStringDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("DecimalDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cDecimalDelimiter = aVal.toChar();
+ }
+ else if(!pBegin->Name.compareToAscii("ThousandDelimiter"))
+ {
+ ::rtl::OUString aVal;
+ OSL_VERIFY( pBegin->Value >>= aVal );
+ m_cThousandDelimiter = aVal.toChar();
+ }
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+ OConnection::construct(url,info);
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OFlatConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new OFlatDatabaseMetaData(this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+//------------------------------------------------------------------------------
+::com::sun::star::uno::Reference< XTablesSupplier > OFlatConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!xTab.is())
+ {
+ OFlatCatalog *pCat = new OFlatCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OFlatConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+ OFlatStatement* pStmt = new OFlatStatement(this);
+
+ Reference< XStatement > xStmt = pStmt;
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OFlatConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+
+ OFlatPreparedStatement* pStmt = new OFlatPreparedStatement(this);
+ Reference< XPreparedStatement > xStmt = pStmt;
+ pStmt->construct(sql);
+
+ m_aStatements.push_back(WeakReferenceHelper(*pStmt));
+ return xStmt;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OFlatConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_B::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+
+
diff --git a/connectivity/source/drivers/flat/EDatabaseMetaData.cxx b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
new file mode 100644
index 000000000000..5b01ac3396ef
--- /dev/null
+++ b/connectivity/source/drivers/flat/EDatabaseMetaData.cxx
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include "flat/EDatabaseMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/beans/XFastPropertySet.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
+#include <com/sun/star/sdbcx/XIndexesSupplier.hpp>
+#include <tools/urlobj.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace connectivity::flat;
+// using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+
+
+
+OFlatDatabaseMetaData::OFlatDatabaseMetaData(::connectivity::file::OConnection* _pCon) :ODatabaseMetaData(_pCon)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::OFlatDatabaseMetaData" );
+}
+// -------------------------------------------------------------------------
+OFlatDatabaseMetaData::~OFlatDatabaseMetaData()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::~OFlatDatabaseMetaData" );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OFlatDatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::impl_getTypeInfo_throw" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR")));
+ aRow.push_back(new ORowSetValueDecorator(DataType::CHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)254));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("VARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::VARCHAR);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("LONGVARCHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::LONGVARCHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)65535);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DATE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DATE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)10);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIME"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIME);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)8);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)19);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("BOOL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::BIT);
+ aRow[3] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[9] = ODatabaseMetaDataResultSet::getBasicValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DECIMAL"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DECIMAL);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("DOUBLE"));
+ aRow[2] = new ORowSetValueDecorator(DataType::DOUBLE);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NUMERIC"));
+ aRow[2] = new ORowSetValueDecorator(DataType::NUMERIC);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)20);
+ aRows.push_back(aRow);
+ }
+
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OFlatDatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::getColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTables = m_pConnection->createCatalog();
+ if(!xTables.is())
+ throw SQLException();
+
+ Reference< XNameAccess> xNames = xTables->getTables();
+ if(!xNames.is())
+ throw SQLException();
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ Sequence< ::rtl::OUString> aTabNames(xNames->getElementNames());
+ const ::rtl::OUString* pTabBegin = aTabNames.getConstArray();
+ const ::rtl::OUString* pTabEnd = pTabBegin + aTabNames.getLength();
+ for(;pTabBegin != pTabEnd;++pTabBegin)
+ {
+ if(match(tableNamePattern,*pTabBegin,'\0'))
+ {
+ Reference< XColumnsSupplier> xTable;
+ ::cppu::extractInterface(xTable,xNames->getByName(*pTabBegin));
+ aRow[3] = new ORowSetValueDecorator(*pTabBegin);
+
+ Reference< XNameAccess> xColumns = xTable->getColumns();
+ if(!xColumns.is())
+ throw SQLException();
+
+ Sequence< ::rtl::OUString> aColNames(xColumns->getElementNames());
+
+ const ::rtl::OUString* pBegin = aColNames.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + aColNames.getLength();
+ Reference< XPropertySet> xColumn;
+ for(sal_Int32 i=1;pBegin != pEnd;++pBegin,++i)
+ {
+ if(match(columnNamePattern,*pBegin,'\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(*pBegin);
+
+ ::cppu::extractInterface(xColumn,xColumns->getByName(*pBegin));
+ OSL_ENSURE(xColumn.is(),"Columns contains a column who isn't a fastpropertyset!");
+ aRow[5] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))));
+ aRow[6] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME))));
+ aRow[7] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION))));
+ aRow[9] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE))));
+ aRow[11] = new ORowSetValueDecorator(getINT32(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE))));
+ aRow[13] = new ORowSetValueDecorator(getString(xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DEFAULTVALUE))));
+
+ switch((sal_Int32)aRow[5]->getValue())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)254);
+ break;
+ case DataType::LONGVARCHAR:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)65535);
+ break;
+ default:
+ aRow[16] = new ORowSetValueDecorator((sal_Int32)0);
+ }
+ aRow[17] = new ORowSetValueDecorator(i);
+ switch(sal_Int32(aRow[11]->getValue()))
+ {
+ case ColumnValue::NO_NULLS:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("NO"));
+ break;
+ case ColumnValue::NULLABLE:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+ break;
+ default:
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString());
+ }
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ pResult->setRows(aRows);
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFlatDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatDatabaseMetaData::getURL" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:flat:")) + m_pConnection->getURL();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EDriver.cxx b/connectivity/source/drivers/flat/EDriver.cxx
new file mode 100644
index 000000000000..9aab07bee74f
--- /dev/null
+++ b/connectivity/source/drivers/flat/EDriver.cxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/EDriver.hxx"
+#include "flat/EConnection.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include <comphelper/sequence.hxx>
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.flat.ODriver");
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::flat::ODriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ODriver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (ODriver_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ OFlatConnection* pCon = new OFlatConnection(this);
+ pCon->construct(url,info);
+ Reference< XConnection > xCon = pCon;
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return url.compareTo(::rtl::OUString::createFromAscii("sdbc:flat:"),10) == 0;
+}
+// -----------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBoolean(2);
+ aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
+ aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FieldDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Field separator."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeaderLine"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text contains headers."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StringDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Text separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DecimalDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Decimal separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ThousandDelimiter"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Thousands separator."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ return ::comphelper::concatSequences(OFileDriver::getPropertyInfo(url,info ),
+ Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size()));
+ }
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/flat/EPreparedStatement.cxx b/connectivity/source/drivers/flat/EPreparedStatement.cxx
new file mode 100644
index 000000000000..2ddead6acfc0
--- /dev/null
+++ b/connectivity/source/drivers/flat/EPreparedStatement.cxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef _CONNECTIVITY_FLAT_EPREPAREDSTATEMENT_HXX_
+#include "flat/EPreparedStatement.hxx"
+#endif
+#include "flat/EResultSet.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OFlatPreparedStatement::createResultSet()
+{
+ return new OFlatResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatPreparedStatement,"com.sun.star.sdbc.driver.flat.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
diff --git a/connectivity/source/drivers/flat/EResultSet.cxx b/connectivity/source/drivers/flat/EResultSet.cxx
new file mode 100644
index 000000000000..c4833f310d62
--- /dev/null
+++ b/connectivity/source/drivers/flat/EResultSet.cxx
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include "flat/EResultSet.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// using namespace com::sun::star::container;
+// using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OFlatResultSet::OFlatResultSet( OStatement_Base* pStmt,connectivity::OSQLParseTreeIterator& _aSQLIterator)
+ : file::OResultSet(pStmt,_aSQLIterator)
+ ,m_bBookmarkable(sal_True)
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE), PROPERTY_ID_ISBOOKMARKABLE, PropertyAttribute::READONLY,&m_bBookmarkable, ::getBooleanCppuType());
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OFlatResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.flat.ResultSet");
+}
+// -------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OFlatResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OFlatResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if(rType == ::getCppuType((const Reference<XDeleteRows>*)0) || rType == ::getCppuType((const Reference<XResultSetUpdate>*)0)
+ || rType == ::getCppuType((const Reference<XRowUpdate>*)0))
+ return Any();
+
+ const Any aRet = OResultSet::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OFlatResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFlatResultSet::getTypes( ) throw( RuntimeException)
+{
+ Sequence< Type > aTypes = OResultSet::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XDeleteRows>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XResultSetUpdate>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRowUpdate>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ Sequence< Type > aRet(pTypes, aOwnTypes.size());
+ return ::comphelper::concatSequences(aRet,OFlatResultSet_BASE::getTypes());
+}
+
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OFlatResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return makeAny((sal_Int32)(m_aRow->get())[0]->getValue());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ return Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_bRowDeleted = m_bRowInserted = m_bRowUpdated = sal_False;
+
+ Move(IResultSetHelper::BOOKMARK,comphelper::getINT32(bookmark),sal_False);
+
+ return relative(rows);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFlatResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ return (lhs == rhs) ? 0 : 2;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OFlatResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OFlatResultSet::hashBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ return comphelper::getINT32(bookmark);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OFlatResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OFlatResultSet::getInfoHelper()
+{
+ return *OFlatResultSet_BASE3::getArrayHelper();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFlatResultSet::acquire() throw()
+{
+ OFlatResultSet_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OFlatResultSet::release() throw()
+{
+ OFlatResultSet_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OFlatResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/flat/EStatement.cxx b/connectivity/source/drivers/flat/EStatement.cxx
new file mode 100644
index 000000000000..e3dfcd686aa7
--- /dev/null
+++ b/connectivity/source/drivers/flat/EStatement.cxx
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/EStatement.hxx"
+#include "flat/EResultSet.hxx"
+
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace com::sun::star::uno;
+// -------------------------------------------------------------------------
+OResultSet* OFlatStatement::createResultSet()
+{
+ return new OFlatResultSet(this,m_aSQLIterator);
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OFlatStatement,"com.sun.star.sdbc.driver.flat.Statement","com.sun.star.sdbc.Statement");
+
diff --git a/connectivity/source/drivers/flat/ETable.cxx b/connectivity/source/drivers/flat/ETable.cxx
new file mode 100644
index 000000000000..eff2464ce533
--- /dev/null
+++ b/connectivity/source/drivers/flat/ETable.cxx
@@ -0,0 +1,844 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <ctype.h>
+#include "flat/ETable.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <svl/converter.hxx>
+#include "flat/EConnection.hxx"
+#include "flat/EColumns.hxx"
+#include <osl/thread.h>
+#include <tools/config.hxx>
+#include <comphelper/sequence.hxx>
+#include <svl/zforlist.hxx>
+#include <rtl/math.hxx>
+#include <stdio.h> //sprintf
+#include <comphelper/extract.hxx>
+#include <comphelper/numbers.hxx>
+#include "flat/EDriver.hxx"
+#include <com/sun/star/util/NumberFormat.hpp>
+#include <unotools/configmgr.hxx>
+#include <i18npool/mslangid.hxx>
+#include "connectivity/dbconversion.hxx"
+#include <comphelper/types.hxx>
+#include "file/quotedstring.hxx"
+#include <unotools/syslocale.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::cppu;
+using namespace utl;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::ucb;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+void OFlatTable::fillColumns(const ::com::sun::star::lang::Locale& _aLocale)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fillColumns" );
+ BOOL bRead = TRUE;
+
+ QuotedTokenizedString aHeaderLine;
+ OFlatConnection* pConnection = (OFlatConnection*)m_pConnection;
+ const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
+ const sal_Bool bHasHeaderLine = pConnection->isHeaderLine();
+ if ( bHasHeaderLine )
+ {
+ while(bRead && !aHeaderLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aHeaderLine,nEncoding);
+ }
+ m_nStartRowFilePos = m_pFileStream->Tell();
+ }
+
+ // read first row
+ QuotedTokenizedString aFirstLine;
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding);
+
+ if ( !bHasHeaderLine || !aHeaderLine.Len())
+ {
+ while(bRead && !aFirstLine.Len())
+ {
+ bRead = m_pFileStream->ReadByteStringLine(aFirstLine,nEncoding);
+ }
+ // use first row as headerline because we need the number of columns
+ aHeaderLine = aFirstLine;
+ }
+ // column count
+ const xub_StrLen nFieldCount = aHeaderLine.GetTokenCount(m_cFieldDelimiter,m_cStringDelimiter);
+
+ if(!m_aColumns.isValid())
+ m_aColumns = new OSQLColumns();
+ else
+ m_aColumns->get().clear();
+
+ m_aTypes.clear();
+ m_aPrecisions.clear();
+ m_aScales.clear();
+ // reserve some space
+ m_aColumns->get().reserve(nFieldCount+1);
+ m_aTypes.reserve(nFieldCount+1);
+ m_aPrecisions.reserve(nFieldCount+1);
+ m_aScales.reserve(nFieldCount+1);
+
+ const sal_Bool bCase = m_pConnection->getMetaData()->storesMixedCaseQuotedIdentifiers();
+ CharClass aCharClass(pConnection->getDriver()->getFactory(),_aLocale);
+ // read description
+ const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ String aColumnName;
+ ::rtl::OUString aTypeName;
+ ::comphelper::UStringMixEqual aCase(bCase);
+ xub_StrLen nStartPosHeaderLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine = 0; // use for eficient way to get the tokens
+ xub_StrLen nStartPosFirstLine2 = 0;
+ for (xub_StrLen i = 0; i < nFieldCount; i++)
+ {
+ if ( bHasHeaderLine )
+ {
+ aHeaderLine.GetTokenSpecial(aColumnName,nStartPosHeaderLine,m_cFieldDelimiter,m_cStringDelimiter);
+ if ( !aColumnName.Len() )
+ {
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+ }
+ }
+ else
+ {
+ // no column name so ...
+ aColumnName = 'C';
+ aColumnName += String::CreateFromInt32(i+1);
+ }
+ sal_Int32 eType;
+ UINT16 nPrecision = 0;
+ UINT16 nScale = 0;
+
+ BOOL bNumeric = FALSE;
+ ULONG nIndex = 0;
+
+ // first without fielddelimiter
+ String aField;
+ aFirstLine.GetTokenSpecial(aField,nStartPosFirstLine,m_cFieldDelimiter,'\0');
+ if (aField.Len() == 0 ||
+ (m_cStringDelimiter && m_cStringDelimiter == aField.GetChar(0)))
+ {
+ bNumeric = FALSE;
+ nStartPosFirstLine2 = nStartPosFirstLine;
+ }
+ else
+ {
+ String aField2;
+ if ( m_cStringDelimiter != '\0' )
+ aFirstLine.GetTokenSpecial(aField2,nStartPosFirstLine2,m_cFieldDelimiter,m_cStringDelimiter);
+ else
+ aField2 = aField;
+
+ if (aField2.Len() == 0)
+ {
+ bNumeric = FALSE;
+ }
+ else
+ {
+ bNumeric = TRUE;
+ xub_StrLen nDot = 0;
+ xub_StrLen nDecimalDelCount = 0;
+ for (xub_StrLen j = 0; j < aField2.Len(); j++)
+ {
+ const sal_Unicode c = aField2.GetChar(j);
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if ( ( !cDecimalDelimiter || c != cDecimalDelimiter ) &&
+ ( !cThousandDelimiter || c != cThousandDelimiter ) &&
+ !aCharClass.isDigit(aField2,j) &&
+ ( j != 0 || (c != '+' && c != '-' ) ) )
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ if (cDecimalDelimiter && c == cDecimalDelimiter)
+ {
+ nPrecision = 15; // we have an decimal value
+ nScale = 2;
+ ++nDecimalDelCount;
+ } // if (cDecimalDelimiter && c == cDecimalDelimiter)
+ if ( c == '.' )
+ ++nDot;
+ }
+
+ if (nDecimalDelCount > 1 || nDot > 1 ) // if there is more than one dot it isn't a number
+ bNumeric = FALSE;
+ if (bNumeric && cThousandDelimiter)
+ {
+ // Ist der Trenner richtig angegeben?
+ const String aValue = aField2.GetToken(0,cDecimalDelimiter);
+ for (sal_Int32 j = aValue.Len() - 4; j >= 0; j -= 4)
+ {
+ const sal_Unicode c = aValue.GetChar(static_cast<sal_uInt16>(j));
+ // nur Ziffern und Dezimalpunkt und Tausender-Trennzeichen?
+ if (c == cThousandDelimiter && j)
+ continue;
+ else
+ {
+ bNumeric = FALSE;
+ break;
+ }
+ }
+ }
+
+ // jetzt koennte es noch ein Datumsfeld sein
+ if (!bNumeric)
+ {
+ try
+ {
+ nIndex = m_xNumberFormatter->detectNumberFormat(::com::sun::star::util::NumberFormat::ALL,aField2);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ }
+
+ sal_Int32 nFlags = 0;
+ if (bNumeric)
+ {
+ if (cDecimalDelimiter)
+ {
+ if(nPrecision)
+ {
+ eType = DataType::DECIMAL;
+ static const ::rtl::OUString s_sDECIMAL(RTL_CONSTASCII_USTRINGPARAM("DECIMAL"));
+ aTypeName = s_sDECIMAL;
+ }
+ else
+ {
+ eType = DataType::DOUBLE;
+ static const ::rtl::OUString s_sDOUBLE(RTL_CONSTASCII_USTRINGPARAM("DOUBLE"));
+ aTypeName = s_sDOUBLE;
+ }
+ }
+ else
+ eType = DataType::INTEGER;
+ nFlags = ColumnSearch::BASIC;
+ }
+ else
+ {
+
+ switch (comphelper::getNumberFormatType(m_xNumberFormatter,nIndex))
+ {
+ case NUMBERFORMAT_DATE:
+ eType = DataType::DATE;
+ {
+ static const ::rtl::OUString s_sDATE(RTL_CONSTASCII_USTRINGPARAM("DATE"));
+ aTypeName = s_sDATE;
+ }
+ break;
+ case NUMBERFORMAT_DATETIME:
+ eType = DataType::TIMESTAMP;
+ {
+ static const ::rtl::OUString s_sTIMESTAMP(RTL_CONSTASCII_USTRINGPARAM("TIMESTAMP"));
+ aTypeName = s_sTIMESTAMP;
+ }
+ break;
+ case NUMBERFORMAT_TIME:
+ eType = DataType::TIME;
+ {
+ static const ::rtl::OUString s_sTIME(RTL_CONSTASCII_USTRINGPARAM("TIME"));
+ aTypeName = s_sTIME;
+ }
+ break;
+ default:
+ eType = DataType::VARCHAR;
+ nPrecision = 0; // nyi: Daten koennen aber laenger sein!
+ nScale = 0;
+ {
+ static const ::rtl::OUString s_sVARCHAR(RTL_CONSTASCII_USTRINGPARAM("VARCHAR"));
+ aTypeName = s_sVARCHAR;
+ }
+ };
+ nFlags |= ColumnSearch::CHAR;
+ }
+
+ // check if the columname already exists
+ String aAlias(aColumnName);
+ OSQLColumns::Vector::const_iterator aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ sal_Int32 nExprCnt = 0;
+ while(aFind != m_aColumns->get().end())
+ {
+ (aAlias = aColumnName) += String::CreateFromInt32(++nExprCnt);
+ aFind = connectivity::find(m_aColumns->get().begin(),m_aColumns->get().end(),aAlias,aCase);
+ }
+
+ sdbcx::OColumn* pColumn = new sdbcx::OColumn(aAlias,aTypeName,::rtl::OUString(),::rtl::OUString(),
+ ColumnValue::NULLABLE,
+ nPrecision,
+ nScale,
+ eType,
+ sal_False,
+ sal_False,
+ sal_False,
+ bCase);
+ Reference< XPropertySet> xCol = pColumn;
+ m_aColumns->get().push_back(xCol);
+ m_aTypes.push_back(eType);
+ m_aPrecisions.push_back(nPrecision);
+ m_aScales.push_back(nScale);
+ }
+ m_pFileStream->Seek(m_nStartRowFilePos);
+}
+// -------------------------------------------------------------------------
+OFlatTable::OFlatTable(sdbcx::OCollection* _pTables,OFlatConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : OFlatTable_BASE(_pTables,_pConnection,_Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ ,m_nStartRowFilePos(0)
+ ,m_nRowPos(0)
+ ,m_nMaxRowCount(0)
+ ,m_cStringDelimiter(_pConnection->getStringDelimiter())
+ ,m_cFieldDelimiter(_pConnection->getFieldDelimiter())
+ ,m_bNeedToReadLine(false)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::OFlatTable" );
+
+}
+// -----------------------------------------------------------------------------
+void OFlatTable::construct()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::construct" );
+ SvtSysLocale aLocale;
+ ::com::sun::star::lang::Locale aAppLocale(aLocale.GetLocaleDataPtr()->getLocale());
+ Sequence< ::com::sun::star::uno::Any > aArg(1);
+ aArg[0] <<= aAppLocale;
+
+ Reference< ::com::sun::star::util::XNumberFormatsSupplier > xSupplier(m_pConnection->getDriver()->getFactory()->createInstanceWithArguments(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatsSupplier"),aArg),UNO_QUERY);
+ m_xNumberFormatter = Reference< ::com::sun::star::util::XNumberFormatter >(m_pConnection->getDriver()->getFactory()->createInstance(::rtl::OUString::createFromAscii("com.sun.star.util.NumberFormatter")),UNO_QUERY);
+ m_xNumberFormatter->attachNumberFormatsSupplier(xSupplier);
+ Reference<XPropertySet> xProp(xSupplier->getNumberFormatSettings(),UNO_QUERY);
+ xProp->getPropertyValue(::rtl::OUString::createFromAscii("NullDate")) >>= m_aNullDate;
+
+ INetURLObject aURL;
+ aURL.SetURL(getEntry());
+
+ if(aURL.getExtension() != rtl::OUString(m_pConnection->getExtension()))
+ aURL.setExtension(m_pConnection->getExtension());
+
+ String aFileName = aURL.GetMainURL(INetURLObject::NO_DECODE);
+
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READWRITE | STREAM_NOCREATE | STREAM_SHARE_DENYWRITE);
+
+ if(!m_pFileStream)
+ m_pFileStream = createStream_simpleError( aFileName,STREAM_READ | STREAM_NOCREATE | STREAM_SHARE_DENYNONE);
+
+ if(m_pFileStream)
+ {
+ m_pFileStream->Seek(STREAM_SEEK_TO_END);
+ sal_Int32 nSize = m_pFileStream->Tell();
+ m_pFileStream->Seek(STREAM_SEEK_TO_BEGIN);
+
+ // Buffersize abhaengig von der Filegroesse
+ m_pFileStream->SetBufferSize(nSize > 1000000 ? 32768 :
+ nSize > 100000 ? 16384 :
+ nSize > 10000 ? 4096 : 1024);
+
+ fillColumns(aAppLocale);
+
+ refreshColumns();
+ }
+}
+// -------------------------------------------------------------------------
+String OFlatTable::getEntry()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::getEntry" );
+ ::rtl::OUString sURL;
+ try
+ {
+ Reference< XResultSet > xDir = m_pConnection->getDir()->getStaticResultSet();
+ Reference< XRow> xRow(xDir,UNO_QUERY);
+ ::rtl::OUString sName;
+ ::rtl::OUString sExt;
+
+ INetURLObject aURL;
+ xDir->beforeFirst();
+ static const ::rtl::OUString s_sSeparator(RTL_CONSTASCII_USTRINGPARAM("/"));
+ while(xDir->next())
+ {
+ sName = xRow->getString(1);
+ aURL.SetSmartProtocol(INET_PROT_FILE);
+ String sUrl = m_pConnection->getURL() + s_sSeparator + sName;
+ aURL.SetSmartURL( sUrl );
+
+ // cut the extension
+ sExt = aURL.getExtension();
+
+ // name and extension have to coincide
+ if ( m_pConnection->matchesExtension( sExt ) )
+ {
+ sName = sName.replaceAt(sName.getLength()-(sExt.getLength()+1),sExt.getLength()+1,::rtl::OUString());
+ if ( sName == m_Name )
+ {
+ Reference< XContentAccess > xContentAccess( xDir, UNO_QUERY );
+ sURL = xContentAccess->queryContentIdentifierString();
+ break;
+ }
+ }
+ }
+ xDir->beforeFirst(); // move back to before first record
+ }
+ catch(Exception&)
+ {
+ OSL_ASSERT(0);
+ }
+ return sURL.getStr();
+}
+// -------------------------------------------------------------------------
+void OFlatTable::refreshColumns()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::refreshColumns" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ TStringVector aVector;
+ aVector.reserve(m_aColumns->get().size());
+
+ for(OSQLColumns::Vector::const_iterator aIter = m_aColumns->get().begin();aIter != m_aColumns->get().end();++aIter)
+ aVector.push_back(Reference< XNamed>(*aIter,UNO_QUERY)->getName());
+
+ if(m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new OFlatColumns(this,m_aMutex,aVector);
+}
+
+// -------------------------------------------------------------------------
+void SAL_CALL OFlatTable::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::disposing" );
+ OFileTable::disposing();
+ ::osl::MutexGuard aGuard(m_aMutex);
+ m_aColumns = NULL;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OFlatTable::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OTable_TYPEDEF::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!(*pBegin == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XRename>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ *pBegin == ::getCppuType((const Reference<XDataDescriptorFactory>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OFlatTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( rType == ::getCppuType((const Reference<XKeysSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XIndexesSupplier>*)0) ||
+ rType == ::getCppuType((const Reference<XRename>*)0) ||
+ rType == ::getCppuType((const Reference<XAlterTable>*)0) ||
+ rType == ::getCppuType((const Reference<XDataDescriptorFactory>*)0))
+ return Any();
+
+ Any aRet = OTable_TYPEDEF::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< ::com::sun::star::lang::XUnoTunnel*> (this));
+}
+
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OFlatTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OFlatTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::getSomething" );
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OFlatTable_BASE::getSomething(rId);
+}
+//------------------------------------------------------------------
+sal_Bool OFlatTable::fetchRow(OValueRefRow& _rRow,const OSQLColumns & _rCols,sal_Bool bIsTable,sal_Bool bRetrieveData)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::fetchRow" );
+ *(_rRow->get())[0] = m_nFilePos;
+
+ if (!bRetrieveData)
+ return TRUE;
+ if ( m_bNeedToReadLine )
+ {
+ sal_Int32 nCurrentPos = 0;
+ m_pFileStream->Seek(m_nFilePos);
+ readLine(nCurrentPos);
+ m_bNeedToReadLine = false;
+ }
+
+ OFlatConnection* pConnection = (OFlatConnection*)m_pConnection;
+ const sal_Unicode cDecimalDelimiter = pConnection->getDecimalDelimiter();
+ const sal_Unicode cThousandDelimiter = pConnection->getThousandDelimiter();
+ // Felder:
+ xub_StrLen nStartPos = 0;
+ String aStr;
+ OSQLColumns::Vector::const_iterator aIter = _rCols.get().begin();
+ OSQLColumns::Vector::const_iterator aEnd = _rCols.get().end();
+ const OValueRefVector::Vector::size_type nCount = _rRow->get().size();
+ for (OValueRefVector::Vector::size_type i = 1; aIter != aEnd && i < nCount;
+ ++aIter, i++)
+ {
+ m_aCurrentLine.GetTokenSpecial(aStr,nStartPos,m_cFieldDelimiter,m_cStringDelimiter);
+
+ if (aStr.Len() == 0)
+ (_rRow->get())[i]->setNull();
+ else
+ {
+ // Laengen je nach Datentyp:
+ sal_Int32 nLen,
+ nType = 0;
+ if(bIsTable)
+ {
+ nLen = m_aPrecisions[i-1];
+ nType = m_aTypes[i-1];
+ }
+ else
+ {
+ Reference< XPropertySet> xColumn = *aIter;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)) >>= nLen;
+ xColumn->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)) >>= nType;
+ }
+ switch(nType)
+ {
+ case DataType::TIMESTAMP:
+ case DataType::DATE:
+ case DataType::TIME:
+ {
+ try
+ {
+ double nRes = m_xNumberFormatter->convertStringToNumber(::com::sun::star::util::NumberFormat::ALL,aStr);
+
+ switch(nType)
+ {
+ case DataType::DATE:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDate(nRes,m_aNullDate));
+ break;
+ case DataType::TIMESTAMP:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toDateTime(nRes,m_aNullDate));
+ break;
+ default:
+ *(_rRow->get())[i] = ::dbtools::DBTypeConversion::toDouble(::dbtools::DBTypeConversion::toTime(nRes));
+ }
+ }
+ catch(Exception&)
+ {
+ (_rRow->get())[i]->setNull();
+ }
+ } break;
+ case DataType::DOUBLE:
+ case DataType::INTEGER:
+ case DataType::DECIMAL: // #99178# OJ
+ case DataType::NUMERIC:
+ {
+
+ String aStrConverted;
+ if ( DataType::INTEGER != nType )
+ {
+ sal_Unicode* pData = aStrConverted.AllocBuffer(aStr.Len());
+ const sal_Unicode* pStart = pData;
+
+ OSL_ENSURE(cDecimalDelimiter && nType != DataType::INTEGER ||
+ !cDecimalDelimiter && nType == DataType::INTEGER,
+ "FalscherTyp");
+
+ // In Standard-Notation (DezimalPUNKT ohne Tausender-Komma) umwandeln:
+ for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ {
+ const sal_Unicode cChar = aStr.GetChar(j);
+ if (cDecimalDelimiter && cChar == cDecimalDelimiter)
+ *pData++ = '.';
+ //aStrConverted.Append( '.' );
+ else if ( cChar == '.' ) // special case, if decimal seperator isn't '.' we have to put the string after it
+ continue; // #99189# OJ
+ else if (cThousandDelimiter && cChar == cThousandDelimiter)
+ {
+ // weglassen
+ }
+ else
+ *pData++ = cChar;
+ //aStrConverted.Append(cChar);
+ } // for (xub_StrLen j = 0; j < aStr.Len(); ++j)
+ aStrConverted.ReleaseBufferAccess(xub_StrLen(pData - pStart));
+ } // if ( DataType::INTEGER != nType )
+ else
+ {
+ aStrConverted = aStr;
+ if ( cThousandDelimiter )
+ aStrConverted.EraseAllChars(cThousandDelimiter);
+ }
+ const double nVal = ::rtl::math::stringToDouble(aStrConverted,'.',',',NULL,NULL);
+
+ // #99178# OJ
+ if ( DataType::DECIMAL == nType || DataType::NUMERIC == nType )
+ *(_rRow->get())[i] = ::rtl::OUString::valueOf(nVal);
+ else
+ *(_rRow->get())[i] = nVal;
+ } break;
+
+ default:
+ {
+ // Wert als String in Variable der Row uebernehmen
+ *(_rRow->get())[i] = ORowSetValue(aStr);
+ }
+ break;
+ } // switch(nType)
+ (_rRow->get())[i]->setTypeKind(nType);
+ }
+ }
+ return sal_True;
+}
+void OFlatTable::refreshHeader()
+{
+ m_nRowPos = 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFlatTable::seekRow(IResultSetHelper::Movement eCursorPosition, sal_Int32 nOffset, sal_Int32& nCurPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::seekRow" );
+ OSL_ENSURE(m_pFileStream,"OFlatTable::seekRow: FileStream is NULL!");
+ // ----------------------------------------------------------
+ // Positionierung vorbereiten:
+ m_nFilePos = nCurPos;
+
+ switch(eCursorPosition)
+ {
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 0;
+ // run through
+ case IResultSetHelper::NEXT:
+ {
+ ++m_nRowPos;
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::const_iterator aFind = m_aRowPosToFilePos.find(m_nRowPos);
+ m_bNeedToReadLine = aFind != m_aRowPosToFilePos.end();
+ if ( m_bNeedToReadLine )
+ {
+ m_nFilePos = aFind->second->first;
+ nCurPos = aFind->second->second;
+ } // if ( m_bNeedToReadLine )
+ else
+ {
+ if ( m_nRowPos == 1 )
+ m_nFilePos = m_nStartRowFilePos;
+ m_pFileStream->Seek(m_nFilePos);
+ if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
+ {
+ m_nMaxRowCount = m_nRowPos -1;
+ return sal_False;
+ } // if ( m_pFileStream->IsEof() || !readLine(nCurPos) /*|| !checkHeaderLine()*/)
+
+ TRowPositionsInFile::iterator aPos = m_aFilePosToEndLinePos.insert(TRowPositionsInFile::value_type(m_nFilePos,nCurPos)).first;
+ m_aRowPosToFilePos.insert(::std::map<sal_Int32,TRowPositionsInFile::iterator>::value_type(m_nRowPos,aPos));
+ }
+ }
+
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ if(m_nRowPos > 0)
+ {
+ TRowPositionsInFile::iterator aPositions = m_aRowPosToFilePos[m_nRowPos];
+ m_nFilePos = aPositions->first;
+ nCurPos = aPositions->second;
+ m_bNeedToReadLine = true;
+ }
+ else
+ m_nRowPos = 0;
+
+ break;
+ case IResultSetHelper::LAST:
+ if ( m_nMaxRowCount )
+ {
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::reverse_iterator aLastPos = m_aRowPosToFilePos.rbegin();
+ m_nRowPos = aLastPos->first;
+ m_nFilePos = aLastPos->second->first;
+ nCurPos = aLastPos->second->second;
+
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ else
+ {
+ while(seekRow(IResultSetHelper::NEXT,1,nCurPos)) ; // run through after last row
+ // now I know all
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::RELATIVE:
+ if(nOffset > 0)
+ {
+ for(sal_Int32 i = 0;i<nOffset;++i)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else if(nOffset < 0)
+ {
+ for(sal_Int32 i = nOffset;i;++i)
+ seekRow(IResultSetHelper::PRIOR,1,nCurPos);
+ }
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ {
+ if(nOffset < 0)
+ nOffset = m_nRowPos + nOffset;
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::const_iterator aIter = m_aRowPosToFilePos.find(nOffset);
+ if(aIter != m_aRowPosToFilePos.end())
+ {
+ m_nFilePos = aIter->second->first;
+ nCurPos = aIter->second->second;
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ else if(m_nMaxRowCount && nOffset > m_nMaxRowCount) // offset is outside the table
+ {
+ m_nRowPos = m_nMaxRowCount;
+ return sal_False;
+ }
+ else
+ {
+ aIter = m_aRowPosToFilePos.upper_bound(nOffset);
+ if(aIter == m_aRowPosToFilePos.end())
+ {
+ ::std::map<sal_Int32,TRowPositionsInFile::iterator>::reverse_iterator aLastPos = m_aRowPosToFilePos.rbegin();
+ m_nRowPos = aLastPos->first;
+ nCurPos = m_nFilePos = aLastPos->second->first;
+ while(m_nRowPos != nOffset)
+ seekRow(IResultSetHelper::NEXT,1,nCurPos);
+ }
+ else
+ {
+ --aIter;
+ m_nRowPos = aIter->first;
+ m_nFilePos = aIter->second->first;
+ nCurPos = aIter->second->second;
+ //m_pFileStream->Seek(m_nFilePos);
+ m_bNeedToReadLine = true;
+ //if ( m_pFileStream->IsEof() /*|| !checkHeaderLine()*/ || !readLine(nCurPos) )
+ // return sal_False;
+ }
+ }
+ }
+
+ break;
+ case IResultSetHelper::BOOKMARK:
+ {
+ TRowPositionsInFile::const_iterator aFind = m_aFilePosToEndLinePos.find(nOffset);
+ m_bNeedToReadLine = aFind != m_aFilePosToEndLinePos.end();
+ if ( m_bNeedToReadLine )
+ {
+ m_nFilePos = aFind->first;
+ nCurPos = aFind->second;
+ }
+ else
+ {
+ m_nFilePos = nOffset;
+ m_pFileStream->Seek(nOffset);
+ if (m_pFileStream->IsEof() || !readLine(nCurPos) )
+ return sal_False;
+ }
+ break;
+ }
+ }
+
+ //nCurPos = m_nFilePos;
+
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OFlatTable::readLine(sal_Int32& _rnCurrentPos)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "flat", "Ocke.Janssen@sun.com", "OFlatTable::readLine" );
+ const rtl_TextEncoding nEncoding = m_pConnection->getTextEncoding();
+ m_pFileStream->ReadByteStringLine(m_aCurrentLine,nEncoding);
+ if (m_pFileStream->IsEof())
+ return sal_False;
+
+ QuotedTokenizedString sLine = m_aCurrentLine; // check if the string continues on next line
+ while( (sLine.GetString().GetTokenCount(m_cStringDelimiter) % 2) != 1 )
+ {
+ m_pFileStream->ReadByteStringLine(sLine,nEncoding);
+ if ( !m_pFileStream->IsEof() )
+ {
+ m_aCurrentLine.GetString().Append('\n');
+ m_aCurrentLine.GetString() += sLine.GetString();
+ sLine = m_aCurrentLine;
+ }
+ else
+ break;
+ }
+ _rnCurrentPos = m_pFileStream->Tell();
+ return sal_True;
+}
+
diff --git a/connectivity/source/drivers/flat/ETables.cxx b/connectivity/source/drivers/flat/ETables.cxx
new file mode 100644
index 000000000000..6b795a08957d
--- /dev/null
+++ b/connectivity/source/drivers/flat/ETables.cxx
@@ -0,0 +1,62 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/ETables.hxx"
+#include "flat/ETable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "file/FCatalog.hxx"
+#include "file/FConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace connectivity::flat;
+using namespace connectivity::file;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::container;
+namespace starutil = ::com::sun::star::util;
+
+sdbcx::ObjectType OFlatTables::createObject(const ::rtl::OUString& _rName)
+{
+ OFlatTable* pRet = new OFlatTable(this,(OFlatConnection*)static_cast<OFileCatalog&>(m_rParent).getConnection(),
+ _rName,::rtl::OUString::createFromAscii("TABLE"));
+ sdbcx::ObjectType xRet = pRet;
+ pRet->construct();
+ return xRet;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/flat/Eservices.cxx b/connectivity/source/drivers/flat/Eservices.cxx
new file mode 100644
index 000000000000..a0445c1ca70f
--- /dev/null
+++ b/connectivity/source/drivers/flat/Eservices.cxx
@@ -0,0 +1,175 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "flat/EDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::flat;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "FILE::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "FILE::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriver::getImplementationName_Static(),
+ ODriver::getSupportedServiceNames_Static(),
+ ODriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
diff --git a/connectivity/source/drivers/flat/exports.dxp b/connectivity/source/drivers/flat/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/flat/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/flat/flat.mxp.map b/connectivity/source/drivers/flat/flat.mxp.map
new file mode 100644
index 000000000000..54a8532f7840
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.mxp.map
@@ -0,0 +1,141 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___builtin_vec_delete
+___builtin_vec_new
+___check_eh_spec
+___cp_pop_exception
+___cp_push_exception
+___eh_alloc
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+_terminate__Fv
+dyld_stub_binding_helper
+rest_world
+save_world
+___eh_rtime_match
+___builtin_new
+___tf9bad_alloc
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+__._Q312connectivity4flat18UStringDescription
+___Q312connectivity4flat18UStringDescriptionPFv_PCc
+_getPropertySetInfo__Q312connectivity4flat14OFlatResultSet
+_release__Q312connectivity4flat14OFlatResultSet
+_acquire__Q312connectivity4flat14OFlatResultSet
+__._Q312connectivity4flat14OFlatResultSet
+__._Q312connectivity4flat14OFlatStatement
+__._Q312connectivity4flat22OFlatPreparedStatement
+__._Q312connectivity4flat10OFlatTable
+_toDouble__FRC10ByteString
+_checkHeaderLine__Q312connectivity4flat10OFlatTable
+_refreshColumns__Q312connectivity4flat10OFlatTable
+_AllocBuffer__Q312connectivity4flat10OFlatTable
+_fillColumns__Q312connectivity4flat10OFlatTable
+_getEntry__Q312connectivity4flat10OFlatTable
+_GetToken__CQ312connectivity4flat11OFlatStringUsUcUc
+_GetTokenCount__CQ312connectivity4flat11OFlatStringUcUc
+_refreshTables__Q312connectivity4flat12OFlatCatalog
+_getPropertySetInfo__Q312connectivity4file26ODatabaseMetaDataResultSet
+_release__Q312connectivity4file26ODatabaseMetaDataResultSet
+_acquire__Q312connectivity4file26ODatabaseMetaDataResultSet
+_getPropertySetInfo__Q312connectivity4file10OResultSet
+_release__Q312connectivity4file10OResultSet
+_acquire__Q312connectivity4file10OResultSet
+_scanParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRQ24_STLt6vector2ZPB1ZQ24_STLt9allocator1ZPB1
+_AddParameter__Q312connectivity4file10OResultSetPQ212connectivity13OSQLParseNodeRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star5beans12XPropertySet
+_SetAssignValue__Q312connectivity4file10OResultSetRC6Stringn1UcUl
+_ParseAssignValues__Q312connectivity4file10OResultSetRCQ24_STLt6vector2Z6StringZQ24_STLt9allocator1ZB2PQ212connectivity13OSQLParseNodeUs
+_getUnoTunnelImplementationId__Q312connectivity4file10OResultSet
+_setOrderbyColumn__Q312connectivity4file10OResultSetUsPQ212connectivity13OSQLParseNoden1
+_CreateKeySet__Q312connectivity4file14OFILESortIndex
+___Q312connectivity4file14OFILESortIndexPCQ312connectivity4file8OKeyTypePCUclUs
+_anylizeSQL__Q312connectivity4file10OResultSet
+_GetAssignValues__Q312connectivity4file10OResultSet
+_moveAbsolute__Q312connectivity4file10OResultSetlUc
+_ExecuteRow__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUcn2
+_AddKeyValue__Q312connectivity4file14OFILESortIndexPQ312connectivity4file13OFILEKeyValue
+_GetOrderbyKeyValue__Q312connectivity4file10OResultSetGQ23vost4ORef1ZQ312connectivity4file12OValueVector
+_evaluate__Q312connectivity4file10OResultSet
+_SkipDeleted__Q312connectivity4file10OResultSetQ412connectivity4file10OFileTable12FilePositionlUc
+__._Q312connectivity4file14OFILESortIndex
+_construct__Q312connectivity4file10OResultSet
+_isCount__CQ312connectivity4file10OResultSet
+__._Q312connectivity4file18UStringDescription
+___Q312connectivity4file18UStringDescriptionPFv_PCc
+_disposing__Q312connectivity4file15OStatement_Base
+_acquire__Q312connectivity4file15OStatement_Base
+__._Q312connectivity4file16OStatement_BASE2
+__._Q312connectivity4file10OStatement
+_disposeResultSet__Q312connectivity4file15OStatement_Base
+_getImplementationName_Static__Q312connectivity4file11OFileDriver
+_operate__CQ312connectivity4file8OOp_LIKEPCQ312connectivity4file8OOperandn1
+_operate__CQ312connectivity4file10OOp_ISNULLPCQ312connectivity4file8OOperandn1
+_IsOf__Q312connectivity4file12ONumOperatorPFv_Pv
+_StaticType__Q312connectivity4file12ONumOperator
+_IsOf__Q312connectivity4file11OOp_COMPAREPFv_Pv
+_StaticType__Q312connectivity4file11OOp_COMPARE
+_IsOf__Q312connectivity4file11OOp_NOTLIKEPFv_Pv
+_StaticType__Q312connectivity4file11OOp_NOTLIKE
+_IsOf__Q312connectivity4file8OOp_LIKEPFv_Pv
+_StaticType__Q312connectivity4file8OOp_LIKE
+_IsOf__Q312connectivity4file13OOp_ISNOTNULLPFv_Pv
+_StaticType__Q312connectivity4file13OOp_ISNOTNULL
+_IsOf__Q312connectivity4file10OOp_ISNULLPFv_Pv
+_StaticType__Q312connectivity4file10OOp_ISNULL
+_IsOf__Q312connectivity4file6OOp_ORPFv_Pv
+_StaticType__Q312connectivity4file6OOp_OR
+_IsOf__Q312connectivity4file7OOp_ANDPFv_Pv
+_StaticType__Q312connectivity4file7OOp_AND
+_IsOf__Q312connectivity4file13OBoolOperatorPFv_Pv
+_IsOf__Q312connectivity4file9OOperatorPFv_Pv
+_IsOf__Q312connectivity4file14OOperandResultPFv_Pv
+_IsOf__Q312connectivity4file13OOperandConstPFv_Pv
+_IsOf__Q312connectivity4file13OOperandValuePFv_Pv
+_StaticType__Q312connectivity4file13OOperandValue
+_IsOf__Q312connectivity4file13OOperandParamPFv_Pv
+_IsOf__Q312connectivity4file16OFILEOperandAttrPFv_Pv
+_StaticType__Q312connectivity4file16OFILEOperandAttr
+_IsOf__Q312connectivity4file12OOperandAttrPFv_Pv
+_IsOf__Q312connectivity4file11OOperandRowPFv_Pv
+_StaticType__Q312connectivity4file11OOperandRow
+_IsOf__Q312connectivity4file8OOperandPFv_Pv
+_IsOf__Q312connectivity4file5OCodePFv_Pv
+_StaticType__Q312connectivity4file5OCode
+__._Q312connectivity4file5OCode
+_execute_Operand__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_ISNULL__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_LIKE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+_execute_COMPARE__Q312connectivity4file18OPredicateCompilerPQ212connectivity13OSQLParseNode
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/flat/flat.xcu b/connectivity/source/drivers/flat/flat.xcu
new file mode 100755
index 000000000000..d00d1f98c38c
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.xcu
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:flat:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.flat.ODriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Text</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="Extension" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="HeaderLine" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FieldDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>,</value>
+ </prop>
+ </node>
+ <node oor:name="StringDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>"</value>
+ </prop>
+ </node>
+ <node oor:name="DecimalDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>.</value>
+ </prop>
+ </node>
+ <node oor:name="ThousandDelimiter" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="EnableSQL92Check" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FileSystemBased" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="MediaType" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>text/csv</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/flat/flat.xml b/connectivity/source/drivers/flat/flat.xml
new file mode 100644
index 000000000000..7af53b2c0dda
--- /dev/null
+++ b/connectivity/source/drivers/flat/flat.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description>
+ <module-name>file</module-name>
+ <component-description>
+ <author>Ocke Jannsen</author>
+ <name>com.sun.star.comp.sdbc.flat.ODriver</name>
+ <description>This library implements the database driver for flat file formats.
+</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>file</runtime-module-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>svtools-light1</runtime-module-dependency>
+ <runtime-module-dependency>svtools</runtime-module-dependency>
+ <runtime-module-dependency>ucbhelper</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>unotools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
diff --git a/connectivity/source/drivers/flat/makefile.mk b/connectivity/source/drivers/flat/makefile.mk
new file mode 100644
index 000000000000..2d1f99f759c7
--- /dev/null
+++ b/connectivity/source/drivers/flat/makefile.mk
@@ -0,0 +1,107 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=flat
+
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/EResultSet.obj \
+ $(SLO)$/EStatement.obj \
+ $(SLO)$/EPreparedStatement.obj \
+ $(SLO)$/ETable.obj \
+ $(SLO)$/EDatabaseMetaData.obj \
+ $(SLO)$/ECatalog.obj \
+ $(SLO)$/EColumns.obj \
+ $(SLO)$/ETables.obj \
+ $(SLO)$/EConnection.obj \
+ $(SLO)$/Eservices.obj \
+ $(SLO)$/EDriver.obj
+
+EXCEPTIONSFILES=\
+ $(SLO)$/EResultSet.obj \
+ $(SLO)$/EStatement.obj \
+ $(SLO)$/EPreparedStatement.obj \
+ $(SLO)$/ETable.obj \
+ $(SLO)$/EDatabaseMetaData.obj \
+ $(SLO)$/ECatalog.obj \
+ $(SLO)$/EColumns.obj \
+ $(SLO)$/ETables.obj \
+ $(SLO)$/EConnection.obj \
+ $(SLO)$/Eservices.obj \
+ $(SLO)$/EDriver.obj
+
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+SHL1TARGET=$(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(TOOLSLIB) \
+ $(SVLLIB) \
+ $(UNOTOOLSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(DBFILELIB) \
+ $(COMPHELPERLIB)
+
+.IF "$(DBFILELIB)" == ""
+SHL1STDLIBS+= ifile.lib
+.ENDIF
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/hsqldb/HCatalog.cxx b/connectivity/source/drivers/hsqldb/HCatalog.cxx
new file mode 100644
index 000000000000..48ae5dbdb9a3
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HCatalog.cxx
@@ -0,0 +1,166 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HCatalog.hxx"
+#include "hsqldb/HUsers.hxx"
+#include "hsqldb/HTables.hxx"
+#include "hsqldb/HViews.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+//using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OHCatalog::OHCatalog(const Reference< XConnection >& _xConnection) : sdbcx::OCatalog(_xConnection)
+ ,m_xConnection(_xConnection)
+{
+}
+// -----------------------------------------------------------------------------
+void OHCatalog::refreshObjects(const Sequence< ::rtl::OUString >& _sKindOfObject,TStringVector& _rNames)
+{
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ _sKindOfObject);
+ fillNames(xResult,_rNames);
+}
+// -------------------------------------------------------------------------
+void OHCatalog::refreshTables()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ static const ::rtl::OUString s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+
+ Sequence< ::rtl::OUString > sTableTypes(2);
+ sTableTypes[0] = s_sTableTypeView;
+ sTableTypes[1] = s_sTableTypeTable;
+
+ refreshObjects(sTableTypes,aVector);
+
+ if ( m_pTables )
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OHCatalog::refreshViews()
+{
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+
+ sal_Bool bSupportsViews = sal_False;
+ try
+ {
+ Reference<XResultSet> xRes = m_xMetaData->getTableTypes();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while ( xRow.is() && xRes->next() )
+ {
+ if ( (bSupportsViews = xRow->getString(1).equalsIgnoreAsciiCase(aTypes[0])) )
+ {
+ break;
+ }
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+
+ TStringVector aVector;
+ if ( bSupportsViews )
+ refreshObjects(aTypes,aVector);
+
+ if ( m_pViews )
+ m_pViews->reFill(aVector);
+ else
+ m_pViews = new HViews( m_xConnection, *this, m_aMutex, aVector );
+}
+// -------------------------------------------------------------------------
+void OHCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void OHCatalog::refreshUsers()
+{
+ TStringVector aVector;
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ Reference< XResultSet > xResult = xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("select User from hsqldb.user group by User")));
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ TString2IntMap aMap;
+ while( xResult->next() )
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_xConnection,this);
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OHCatalog::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if ( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) )
+ return Any();
+
+ return OCatalog::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OHCatalog::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OCatalog::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if ( !(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ const Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/hsqldb/HColumns.cxx b/connectivity/source/drivers/hsqldb/HColumns.cxx
new file mode 100644
index 000000000000..be9bf65b3f69
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HColumns.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HColumns.hxx"
+#include "TConnection.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::hsqldb;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLColumns::OHSQLColumns( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef
+ ) : OColumnsHelper(_rParent,_bCase,_rMutex,_rVector,_bUseHardRef)
+{
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OHSQLColumns::createDescriptor()
+{
+ return new OHSQLColumn(sal_True);
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+OHSQLColumn::OHSQLColumn( sal_Bool _bCase)
+ : connectivity::sdbcx::OColumn( _bCase )
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OHSQLColumn::construct()
+{
+ m_sAutoIncrement = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IDENTITY"));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),PROPERTY_ID_AUTOINCREMENTCREATION,0,&m_sAutoIncrement, ::getCppuType(&m_sAutoIncrement));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OHSQLColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL OHSQLColumn::getInfoHelper()
+{
+ return *OHSQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OHSQLColumn::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/HConnection.cxx b/connectivity/source/drivers/hsqldb/HConnection.cxx
new file mode 100644
index 000000000000..a786eac84398
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HConnection.cxx
@@ -0,0 +1,422 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "hsqldb/HConnection.hxx"
+#include "hsqldb/HTools.hxx"
+#include "hsqlui.hrc"
+
+#include <connectivity/dbtools.hxx>
+
+/** === begin UNO includes === **/
+#include <com/sun/star/beans/NamedValue.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/sdbcx/XDataDefinitionSupplier.hpp>
+#include <com/sun/star/lang/ServiceNotRegisteredException.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/graphic/XGraphicProvider.hpp>
+#include <com/sun/star/graphic/GraphicColorMode.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/sdbc/XDatabaseMetaData2.hpp>
+/** === end UNO includes === **/
+
+#include <comphelper/componentcontext.hxx>
+#include <comphelper/listenernotification.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "resource/sharedresources.hxx"
+#include "resource/hsqldb_res.hrc"
+
+/** === begin UNO using === **/
+using ::com::sun::star::util::XFlushListener;
+using ::com::sun::star::lang::EventObject;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Exception;
+using ::com::sun::star::uno::RuntimeException;
+using ::com::sun::star::uno::UNO_QUERY;
+using ::com::sun::star::uno::UNO_QUERY_THROW;
+using ::com::sun::star::sdbc::XStatement;
+using ::com::sun::star::sdbc::XConnection;
+using ::com::sun::star::sdbcx::XDataDefinitionSupplier;
+using ::com::sun::star::sdbcx::XTablesSupplier;
+using ::com::sun::star::container::XNameAccess;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::beans::NamedValue;
+using ::com::sun::star::lang::WrappedTargetException;
+using ::com::sun::star::lang::ServiceNotRegisteredException;
+using ::com::sun::star::sdbc::XDriver;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::graphic::XGraphic;
+using ::com::sun::star::graphic::XGraphicProvider;
+using ::com::sun::star::uno::XInterface;
+using ::com::sun::star::lang::IllegalArgumentException;
+using ::com::sun::star::ui::dialogs::XExecutableDialog;
+using ::com::sun::star::uno::Any;
+using ::com::sun::star::uno::makeAny;
+using ::com::sun::star::sdbc::XResultSet;
+using ::com::sun::star::sdbc::XDatabaseMetaData;
+using ::com::sun::star::sdbc::XDatabaseMetaData2;
+using ::com::sun::star::sdbc::XRow;
+using ::com::sun::star::sdb::application::XDatabaseDocumentUI;
+using ::com::sun::star::beans::PropertyValue;
+/** === end UNO using === **/
+namespace GraphicColorMode = ::com::sun::star::graphic::GraphicColorMode;
+
+namespace connectivity { namespace hsqldb
+{
+ // =============================================================================
+ // = FlushListeners
+ // =============================================================================
+ typedef ::comphelper::OListenerContainerBase< XFlushListener, EventObject > FlushListeners_Base;
+ class FlushListeners : public FlushListeners_Base
+ {
+ public:
+ FlushListeners( ::osl::Mutex& _rMutex ) :FlushListeners_Base( _rMutex ) { }
+
+ protected:
+ virtual bool implTypedNotify(
+ const Reference< XFlushListener >& _rxListener,
+ const EventObject& _rEvent
+ ) SAL_THROW( ( Exception ) );
+ };
+
+ // -----------------------------------------------------------------------------
+ bool FlushListeners::implTypedNotify( const Reference< XFlushListener >& _rxListener, const EventObject& _rEvent ) SAL_THROW( ( Exception ) )
+ {
+ _rxListener->flushed( _rEvent );
+ return true; // continue notifying the other listeners, if any
+ }
+
+ // =============================================================================
+ // = OHsqlConnection
+ // =============================================================================
+ // -----------------------------------------------------------------------------
+ void SAL_CALL OHsqlConnection::disposing(void)
+ {
+ m_aFlushListeners.disposeAndClear( EventObject( *this ) );
+ OHsqlConnection_BASE::disposing();
+ OConnectionWrapper::disposing();
+ }
+ // -----------------------------------------------------------------------------
+ OHsqlConnection::OHsqlConnection( const Reference< XDriver > _rxDriver,
+ const Reference< XConnection >& _xConnection ,const Reference< XMultiServiceFactory>& _xORB )
+ :OHsqlConnection_BASE( m_aMutex )
+ ,m_aFlushListeners( m_aMutex )
+ ,m_xDriver( _rxDriver )
+ ,m_xORB( _xORB )
+ ,m_bIni(true)
+ ,m_bReadOnly(false)
+ {
+ setDelegation(_xConnection,_xORB,m_refCount);
+ }
+ // -----------------------------------------------------------------------------
+ OHsqlConnection::~OHsqlConnection()
+ {
+ if ( !OHsqlConnection_BASE::rBHelper.bDisposed )
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+ }
+ // -----------------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2(OHsqlConnection,OHsqlConnection_BASE,OConnectionWrapper)
+ IMPLEMENT_SERVICE_INFO(OHsqlConnection, "com.sun.star.sdbc.drivers.hsqldb.OHsqlConnection", "com.sun.star.sdbc.Connection")
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2(OHsqlConnection,OHsqlConnection_BASE,OConnectionWrapper)
+
+ //--------------------------------------------------------------------
+ ::osl::Mutex& OHsqlConnection::getMutex() const
+ {
+ return m_aMutex;
+ }
+
+ //--------------------------------------------------------------------
+ void OHsqlConnection::checkDisposed() const
+ {
+ ::connectivity::checkDisposed( rBHelper.bDisposed );
+ }
+
+ // XFlushable
+ //--------------------------------------------------------------------
+ void SAL_CALL OHsqlConnection::flush( ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ try
+ {
+ if ( m_xConnection.is() )
+ {
+ if ( m_bIni )
+ {
+ m_bIni = false;
+ Reference< XDatabaseMetaData2 > xMeta2(m_xConnection->getMetaData(),UNO_QUERY_THROW);
+ const Sequence< PropertyValue > aInfo = xMeta2->getConnectionInfo();
+ const PropertyValue* pIter = aInfo.getConstArray();
+ const PropertyValue* pEnd = pIter + aInfo.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if ( pIter->Name.compareToAscii("readonly") == 0 )
+ m_bReadOnly = true;
+ }
+ }
+ if ( !m_bReadOnly )
+ {
+ Reference< XStatement > xStmt( m_xConnection->createStatement(), UNO_QUERY_THROW );
+ xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CHECKPOINT" ) ) );
+ }
+ }
+
+ EventObject aFlushedEvent( *this );
+ m_aFlushListeners.notifyEach( &XFlushListener::flushed, aFlushedEvent );
+ }
+ catch(const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHsqlConnection::addFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aFlushListeners.addInterface( l );
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL OHsqlConnection::removeFlushListener( const Reference< XFlushListener >& l ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+ m_aFlushListeners.removeInterface( l );
+ }
+
+ // -------------------------------------------------------------------
+ Reference< XGraphic > SAL_CALL OHsqlConnection::getTableIcon( const ::rtl::OUString& _TableName, ::sal_Int32 _ColorMode ) throw (RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ impl_checkExistingTable_throw( _TableName );
+ if ( !impl_isTextTable_nothrow( _TableName ) )
+ return NULL;
+
+ return impl_getTextTableIcon_nothrow( _ColorMode );
+ }
+
+ // -------------------------------------------------------------------
+ Reference< XInterface > SAL_CALL OHsqlConnection::getTableEditor( const Reference< XDatabaseDocumentUI >& _DocumentUI, const ::rtl::OUString& _TableName ) throw (IllegalArgumentException, WrappedTargetException, RuntimeException)
+ {
+ MethodGuard aGuard( *this );
+
+ impl_checkExistingTable_throw( _TableName );
+ if ( !impl_isTextTable_nothrow( _TableName ) )
+ return NULL;
+
+ if ( !_DocumentUI.is() )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_DOCUMENTUI));
+ throw IllegalArgumentException(
+ sError,
+ *this,
+ 0
+ );
+ } // if ( !_DocumentUI.is() )
+
+
+// Reference< XExecutableDialog > xEditor = impl_createLinkedTableEditor_throw( _DocumentUI, _TableName );
+// return xEditor.get();
+ return NULL;
+ // editor not yet implemented in this CWS
+ }
+
+ // -------------------------------------------------------------------
+ Reference< XNameAccess > OHsqlConnection::impl_getTableContainer_throw()
+ {
+ Reference< XNameAccess > xTables;
+ try
+ {
+ Reference< XConnection > xMe( *this, UNO_QUERY );
+ Reference< XDataDefinitionSupplier > xDefinitionsSupp( m_xDriver, UNO_QUERY_THROW );
+ Reference< XTablesSupplier > xTablesSupp( xDefinitionsSupp->getDataDefinitionByConnection( xMe ), UNO_QUERY_THROW );
+ xTables.set( xTablesSupp->getTables(), UNO_QUERY_THROW );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_TABLE_CONTAINER));
+ throw WrappedTargetException( sError ,*this, ::cppu::getCaughtException() );
+ }
+
+ OSL_POSTCOND( xTables.is(), "OHsqlConnection::impl_getTableContainer_throw: post condition not met!" );
+ return xTables;
+ }
+
+ //TODO: resource
+#if 0
+ // -------------------------------------------------------------------
+ Reference< XExecutableDialog > OHsqlConnection::impl_createLinkedTableEditor_throw( const Reference< XDatabaseDocumentUI >& _rxDocumentUI, const ::rtl::OUString& _rTableName )
+ {
+ OSL_PRECOND( _rxDocumentUI.is(), "OHsqlConnection::impl_createLinkedTableEditor_throw: illegal document UI!" );
+ Reference< XExecutableDialog > xDialog;
+ try
+ {
+ ::comphelper::ComponentContext aContext( m_xORB );
+ Sequence< Any > aArguments(3);
+ aArguments[0] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TableContainer" ) ),
+ makeAny( impl_getTableContainer_throw() )
+ );
+ aArguments[1] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "TableName" ) ),
+ makeAny( _rTableName )
+ );
+ aArguments[2] <<= NamedValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" ) ),
+ makeAny( _rxDocumentUI->getApplicationMainWindow() )
+ );
+
+ aContext.createComponentWithArguments( "com.sun.star.sdb.hsql.LinkedTableEditor", aArguments, xDialog );
+ if ( !xDialog.is() )
+ throw ServiceNotRegisteredException( ::rtl::OUString::createFromAscii( "com.sun.star.sdb.hsql.LinkedTableEditor" ), *this );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const Exception& )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_TABLE_EDITOR_DIALOG));
+ throw WrappedTargetException( sError ,*this, ::cppu::getCaughtException() );
+ }
+ return xDialog;
+ }
+#endif
+
+ // -------------------------------------------------------------------
+ void OHsqlConnection::impl_checkExistingTable_throw( const ::rtl::OUString& _rTableName )
+ {
+ bool bDoesExist = false;
+ try
+ {
+ Reference< XNameAccess > xTables( impl_getTableContainer_throw(), UNO_QUERY_THROW );
+ if ( xTables.is() )
+ bDoesExist = xTables->hasByName( _rTableName );
+ }
+ catch( const Exception& )
+ {
+ // that's a serious error in impl_getTableContainer_throw, or hasByName, however, we're only
+ // allowed to throw an IllegalArgumentException ourself
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ if ( !bDoesExist )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_TABLENAME,
+ "$tablename$", _rTableName
+ ));
+ throw IllegalArgumentException( sError,*this, 0 );
+ } // if ( !bDoesExist )
+ }
+
+ // -------------------------------------------------------------------
+ bool OHsqlConnection::impl_isTextTable_nothrow( const ::rtl::OUString& _rTableName )
+ {
+ bool bIsTextTable = false;
+ try
+ {
+ Reference< XConnection > xMe( *this, UNO_QUERY_THROW );
+
+ // split the fully qualified name
+ Reference< XDatabaseMetaData > xMetaData( xMe->getMetaData(), UNO_QUERY_THROW );
+ ::rtl::OUString sCatalog, sSchema, sName;
+ ::dbtools::qualifiedNameComponents( xMetaData, _rTableName, sCatalog, sSchema, sName, ::dbtools::eComplete );
+
+ // get the table information
+ ::rtl::OUStringBuffer sSQL;
+ sSQL.appendAscii( "SELECT HSQLDB_TYPE FROM INFORMATION_SCHEMA.SYSTEM_TABLES" );
+ HTools::appendTableFilterCrit( sSQL, sCatalog, sSchema, sName, true );
+ sSQL.appendAscii( " AND TABLE_TYPE = 'TABLE'" );
+
+ Reference< XStatement > xStatement( xMe->createStatement(), UNO_QUERY_THROW );
+ Reference< XResultSet > xTableHsqlType( xStatement->executeQuery( sSQL.makeStringAndClear() ), UNO_QUERY_THROW );
+
+ if ( xTableHsqlType->next() ) // might not succeed in case of VIEWs
+ {
+ Reference< XRow > xValueAccess( xTableHsqlType, UNO_QUERY_THROW );
+ ::rtl::OUString sTableType = xValueAccess->getString( 1 );
+ bIsTextTable = sTableType.equalsAscii( "TEXT" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return bIsTextTable;
+ }
+
+ // -------------------------------------------------------------------
+ Reference< XGraphic > OHsqlConnection::impl_getTextTableIcon_nothrow( ::sal_Int32 _ColorMode )
+ {
+ Reference< XGraphic > xGraphic;
+ try
+ {
+ // create a graphic provider
+ Reference< XGraphicProvider > xProvider;
+ if ( m_xORB.is() )
+ xProvider.set( m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ), UNO_QUERY_THROW );
+
+ // assemble the image URL
+ ::rtl::OUStringBuffer aImageURL;
+ aImageURL.appendAscii( "private:graphicrepository/" ); // load the graphic from the global graphic repository
+ aImageURL.appendAscii( "database/" ); // the relative path within the images.zip
+ if ( _ColorMode == GraphicColorMode::NORMAL )
+ aImageURL.appendAscii( LINKED_TEXT_TABLE_IMAGE_RESOURCE );
+ else
+ aImageURL.appendAscii( LINKED_TEXT_TABLE_IMAGE_RESOURCE_HC );
+ // the name of the graphic to use
+ ::rtl::OUString sImageURL( aImageURL.makeStringAndClear() );
+
+ // ask the provider to obtain a graphic
+ Sequence< PropertyValue > aMediaProperties( 1 );
+ aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) );
+ aMediaProperties[0].Value <<= sImageURL;
+ xGraphic = xProvider->queryGraphic( aMediaProperties );
+ OSL_ENSURE( xGraphic.is(), "OHsqlConnection::impl_getTextTableIcon_nothrow: the provider did not give us a graphic object!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return xGraphic;
+ }
+
+} } // namespace connectivity::hsqldb
diff --git a/connectivity/source/drivers/hsqldb/HDriver.cxx b/connectivity/source/drivers/hsqldb/HDriver.cxx
new file mode 100644
index 000000000000..14758afafb3f
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HDriver.cxx
@@ -0,0 +1,886 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HDriver.hxx"
+#include "hsqldb/HConnection.hxx"
+#include <osl/diagnose.h>
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include "TConnection.hxx"
+#include "hsqldb/HStorageMap.hxx"
+#include <jvmfwk/framework.h>
+#include <com/sun/star/reflection/XProxyFactory.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <com/sun/star/lang/Locale.hpp>
+#include "HTerminateListener.hxx"
+#include "hsqldb/HCatalog.hxx"
+#include "diagnose_ex.h"
+#include <rtl/ustrbuf.hxx>
+#include <osl/file.h>
+#include <osl/process.h>
+#include <connectivity/dbexception.hxx>
+#include <comphelper/namedvaluecollection.hxx>
+#include <unotools/confignode.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+#include "resource/hsqldb_res.hrc"
+#include "resource/sharedresources.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+ using namespace hsqldb;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::io;
+ using namespace ::com::sun::star::task;
+ using namespace ::com::sun::star::reflection;
+
+ namespace hsqldb
+ {
+ Reference< XInterface > SAL_CALL ODriverDelegator_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
+ {
+ return *(new ODriverDelegator(_rxFac));
+ }
+ }
+
+
+
+ //====================================================================
+ //= ODriverDelegator
+ //====================================================================
+ //--------------------------------------------------------------------
+ ODriverDelegator::ODriverDelegator(const Reference< XMultiServiceFactory >& _rxFactory)
+ : ODriverDelegator_BASE(m_aMutex)
+ ,m_xFactory(_rxFactory)
+ ,m_bInShutDownConnections(sal_False)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ODriverDelegator::~ODriverDelegator()
+ {
+ try
+ {
+ ::comphelper::disposeComponent(m_xDriver);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ // --------------------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::disposing()
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ try
+ {
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); m_aConnections.end() != i; ++i)
+ {
+ Reference<XInterface > xTemp = i->first.get();
+ ::comphelper::disposeComponent(xTemp);
+ }
+ }
+ catch(Exception&)
+ {
+ // not interested in
+ }
+ m_aConnections.clear();
+ TWeakPairVector().swap(m_aConnections);
+
+ cppu::WeakComponentImplHelperBase::disposing();
+ }
+ //--------------------------------------------------------------------
+ Reference< XDriver > ODriverDelegator::loadDriver( )
+ {
+ if ( !m_xDriver.is() )
+ {
+ ::rtl::OUString sURL(RTL_CONSTASCII_USTRINGPARAM("jdbc:hsqldb:db"));
+ Reference<XDriverAccess> xDriverAccess(m_xFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager")) ),UNO_QUERY);
+ OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
+ if ( xDriverAccess.is() )
+ m_xDriver = xDriverAccess->getDriverByURL(sURL);
+ }
+
+ return m_xDriver;
+ }
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ ::rtl::OUString lcl_getPermittedJavaMethods_nothrow( const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ ::rtl::OUStringBuffer aConfigPath;
+ aConfigPath.appendAscii( "/org.openoffice.Office.DataAccess/DriverSettings/" );
+ aConfigPath.append ( ODriverDelegator::getImplementationName_Static() );
+ aConfigPath.appendAscii( "/PermittedJavaMethods" );
+ ::utl::OConfigurationTreeRoot aConfig( ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ _rxORB, aConfigPath.makeStringAndClear() ) );
+
+ ::rtl::OUStringBuffer aPermittedMethods;
+ Sequence< ::rtl::OUString > aNodeNames( aConfig.getNodeNames() );
+ for ( const ::rtl::OUString* pNodeNames = aNodeNames.getConstArray();
+ pNodeNames != aNodeNames.getConstArray() + aNodeNames.getLength();
+ ++pNodeNames
+ )
+ {
+ ::rtl::OUString sPermittedMethod;
+ OSL_VERIFY( aConfig.getNodeValue( *pNodeNames ) >>= sPermittedMethod );
+
+ if ( aPermittedMethods.getLength() )
+ aPermittedMethods.append( (sal_Unicode)';' );
+ aPermittedMethods.append( sPermittedMethod );
+ }
+
+ return aPermittedMethods.makeStringAndClear();;
+ }
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection > SAL_CALL ODriverDelegator::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ Reference< XConnection > xConnection;
+ if ( acceptsURL(url) )
+ {
+ Reference< XDriver > xDriver = loadDriver();
+ if ( xDriver.is() )
+ {
+ ::rtl::OUString sURL;
+ Reference<XStorage> xStorage;
+ const PropertyValue* pIter = info.getConstArray();
+ const PropertyValue* pEnd = pIter + info.getLength();
+
+ for (;pIter != pEnd; ++pIter)
+ {
+ if ( pIter->Name.equalsAscii("Storage") )
+ {
+ xStorage.set(pIter->Value,UNO_QUERY);
+ }
+ else if ( pIter->Name.equalsAscii("URL") )
+ {
+ pIter->Value >>= sURL;
+ }
+ }
+
+ if ( !xStorage.is() || !sURL.getLength() )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_NO_STROAGE);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ ::rtl::OUString sSystemPath;
+ osl_getSystemPathFromFileURL( sURL.pData, &sSystemPath.pData );
+ sal_Int32 nIndex = sSystemPath.lastIndexOf('.');
+ if ( !sURL.getLength() || !sSystemPath.getLength() )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_INVALID_FILE_URL);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ bool bIsNewDatabase = !xStorage->hasElements();
+
+ ::comphelper::NamedValueCollection aProperties;
+
+ // properties for accessing the embedded storage
+ ::rtl::OUString sConnPartURL = sSystemPath.copy( 0, ::std::max< sal_Int32 >( nIndex, sSystemPath.getLength() ) );
+ ::rtl::OUString sKey = StorageContainer::registerStorage( xStorage, sConnPartURL );
+ aProperties.put( "storage_key", sKey );
+ aProperties.put( "storage_class_name",
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbcx.comp.hsqldb.StorageAccess" ) ) );
+ aProperties.put( "fileaccess_class_name",
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sdbcx.comp.hsqldb.StorageFileAccess" ) ) );
+
+ // JDBC driver and driver's classpath
+ aProperties.put( "JavaDriverClass",
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "org.hsqldb.jdbcDriver" ) ) );
+ aProperties.put( "JavaDriverClassPath",
+ ::rtl::OUString(
+#ifdef SYSTEM_HSQLDB
+ RTL_CONSTASCII_USTRINGPARAM(HSQLDB_JAR
+ " vnd.sun.star.expand:$OOO_BASE_DIR/program/classes/sdbc_hsqldb.jar" )
+#else
+ RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.expand:$OOO_BASE_DIR/program/classes/hsqldb.jar"
+ " vnd.sun.star.expand:$OOO_BASE_DIR/program/classes/sdbc_hsqldb.jar" )
+#endif
+ ) );
+
+ // auto increment handling
+ aProperties.put( "IsAutoRetrievingEnabled", true );
+ aProperties.put( "AutoRetrievingStatement",
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CALL IDENTITY()" ) ) );
+ aProperties.put( "IgnoreDriverPrivileges", true );
+
+ // don't want to expose HSQLDB's schema capabilities which exist since 1.8.0RC10
+ aProperties.put( "default_schema",
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
+
+ // security: permitted Java classes
+ NamedValue aPermittedClasses(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "hsqldb.method_class_names" ) ),
+ makeAny( lcl_getPermittedJavaMethods_nothrow( m_xFactory ) )
+ );
+ aProperties.put( "SystemProperties", Sequence< NamedValue >( &aPermittedClasses, 1 ) );
+
+ const ::rtl::OUString sProperties( RTL_CONSTASCII_USTRINGPARAM( "properties" ) );
+ ::rtl::OUString sMessage;
+ try
+ {
+ if ( !bIsNewDatabase && xStorage->isStreamElement(sProperties) )
+ {
+ Reference<XStream > xStream = xStorage->openStreamElement(sProperties,ElementModes::READ);
+ if ( xStream.is() )
+ {
+ ::std::auto_ptr<SvStream> pStream( ::utl::UcbStreamHelper::CreateStream(xStream) );
+ if ( pStream.get() )
+ {
+ ByteString sLine;
+ while ( pStream->ReadLine(sLine) )
+ {
+ if ( sLine.Equals("version=",0,sizeof("version=")-1) )
+ {
+ sLine = sLine.GetToken(1,'=');
+ const sal_Int32 nMajor = sLine.GetToken(0,'.').ToInt32();
+ const sal_Int32 nMinor = sLine.GetToken(1,'.').ToInt32();
+ const sal_Int32 nMicro = sLine.GetToken(2,'.').ToInt32();
+ if ( nMajor > 1
+ || ( nMajor == 1 && nMinor > 8 )
+ || ( nMajor == 1 && nMinor == 8 && nMicro > 0 ) )
+ {
+ ::connectivity::SharedResources aResources;
+ sMessage = aResources.getResourceString(STR_ERROR_NEW_VERSION);
+ }
+ break;
+ }
+ }
+ }
+ } // if ( xStream.is() )
+ ::comphelper::disposeComponent(xStream);
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ if ( sMessage.getLength() )
+ {
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ // readonly?
+ Reference<XPropertySet> xProp(xStorage,UNO_QUERY);
+ if ( xProp.is() )
+ {
+ sal_Int32 nMode = 0;
+ xProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OpenMode"))) >>= nMode;
+ if ( (nMode & ElementModes::WRITE) != ElementModes::WRITE )
+ {
+ aProperties.put( "readonly", ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) ) );
+ }
+ }
+
+ Sequence< PropertyValue > aConnectionArgs;
+ aProperties >>= aConnectionArgs;
+
+ ::rtl::OUString sConnectURL(RTL_CONSTASCII_USTRINGPARAM("jdbc:hsqldb:"));
+
+ sConnectURL += sConnPartURL;
+ Reference<XConnection> xOrig;
+ try
+ {
+ xOrig = xDriver->connect( sConnectURL, aConnectionArgs );
+ }
+ catch(const Exception& e)
+ {
+ StorageContainer::revokeStorage(sKey,NULL);
+ (void)e;
+ throw;
+ }
+
+ // if the storage is completely empty, then we just created a new HSQLDB
+ // In this case, do some initializations.
+ if ( bIsNewDatabase && xOrig.is() )
+ onConnectedNewDatabase( xOrig );
+
+ if ( xOrig.is() )
+ {
+ OMetaConnection* pMetaConnection = NULL;
+ // now we have to set the URL to get the correct answer for metadata()->getURL()
+ Reference< XUnoTunnel> xTunnel(xOrig,UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+ pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
+ if ( pMetaConnection )
+ pMetaConnection->setURL(url);
+ }
+
+ Reference<XComponent> xComp(xOrig,UNO_QUERY);
+ if ( xComp.is() )
+ xComp->addEventListener(this);
+
+ // we want to close all connections when the office shuts down
+ static Reference< XTerminateListener> s_xTerminateListener;
+ if( !s_xTerminateListener.is() )
+ {
+ Reference< XDesktop > xDesktop( m_xFactory->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.frame.Desktop")) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ {
+ s_xTerminateListener = new OConnectionController(this);
+ xDesktop->addTerminateListener(s_xTerminateListener);
+ }
+ }
+ Reference< XComponent> xIfc = new OHsqlConnection( this, xOrig, m_xFactory );
+ xConnection.set(xIfc,UNO_QUERY);
+ m_aConnections.push_back(TWeakPair(WeakReferenceHelper(xOrig),TWeakConnectionPair(sKey,TWeakRefPair(WeakReferenceHelper(xConnection),WeakReferenceHelper()))));
+
+ Reference<XTransactionBroadcaster> xBroad(xStorage,UNO_QUERY);
+ if ( xBroad.is() )
+ {
+ Reference<XTransactionListener> xListener(*this,UNO_QUERY);
+ xBroad->addTransactionListener(xListener);
+ }
+ }
+ }
+ }
+ return xConnection;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ODriverDelegator::acceptsURL( const ::rtl::OUString& url ) throw (SQLException, RuntimeException)
+ {
+ sal_Bool bEnabled = sal_False;
+ OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
+ return bEnabled && url.compareToAscii("sdbc:embedded:hsqldb",sizeof("sdbc:embedded:hsqldb")) == 0;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw (SQLException, RuntimeException)
+ {
+ if ( !acceptsURL(url) )
+ return Sequence< DriverPropertyInfo >();
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Storage"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines the storage where the database will be stored."))
+ ,sal_True
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines the url of the data source."))
+ ,sal_True
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoRetrievingStatement"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines the statement which will be executed to retrieve auto increment values."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CALL IDENTITY()"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverDelegator::getMajorVersion( ) throw (RuntimeException)
+ {
+ return 1;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverDelegator::getMinorVersion( ) throw (RuntimeException)
+ {
+ return 0;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByConnection( const Reference< XConnection >& connection ) throw (SQLException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);
+
+ Reference< XTablesSupplier > xTab;
+
+ TWeakPairVector::iterator aEnd = m_aConnections.end();
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ if ( i->second.second.first.get() == connection.get() )
+ {
+ xTab = Reference< XTablesSupplier >(i->second.second.second.get().get(),UNO_QUERY);
+ if ( !xTab.is() )
+ {
+ xTab = new OHCatalog(connection);
+ i->second.second.second = WeakReferenceHelper(xTab);
+ }
+ break;
+ }
+ }
+
+ return xTab;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ if ( ! acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ }
+
+ return getDataDefinitionByConnection(connect(url,info));
+ }
+
+ // XServiceInfo
+ // --------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------
+ rtl::OUString ODriverDelegator::getImplementationName_Static( ) throw(RuntimeException)
+ {
+ return rtl::OUString::createFromAscii("com.sun.star.sdbcx.comp.hsqldb.Driver");
+ }
+ //------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ODriverDelegator::getSupportedServiceNames_Static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver"));
+ aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver");
+ return aSNS;
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ODriverDelegator::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool SAL_CALL ODriverDelegator::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ODriverDelegator::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::createCatalog( const Sequence< PropertyValue >& /*info*/ ) throw (SQLException, ::com::sun::star::container::ElementExistException, RuntimeException)
+ {
+ ::dbtools::throwFeatureNotImplementedException( "XCreateCatalog::createCatalog", *this );
+ }
+ //------------------------------------------------------------------
+ void ODriverDelegator::shutdownConnection(const TWeakPairVector::iterator& _aIter )
+ {
+ OSL_ENSURE(m_aConnections.end() != _aIter,"Iterator equals .end()");
+ sal_Bool bLastOne = sal_True;
+ try
+ {
+ Reference<XConnection> _xConnection(_aIter->first.get(),UNO_QUERY);
+
+ if ( _xConnection.is() )
+ {
+ Reference<XStatement> xStmt = _xConnection->createStatement();
+ if ( xStmt.is() )
+ {
+ Reference<XResultSet> xRes(xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT COUNT(*) FROM INFORMATION_SCHEMA.SYSTEM_SESSIONS WHERE USER_NAME ='SA'"))),UNO_QUERY);
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ if ( xRow.is() && xRes->next() )
+ bLastOne = xRow->getInt(1) == 1;
+ if ( bLastOne )
+ xStmt->execute(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SHUTDOWN")));
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ if ( bLastOne )
+ {
+ // Reference<XTransactionListener> xListener(*this,UNO_QUERY);
+ // a shutdown should commit all changes to the db files
+ StorageContainer::revokeStorage(_aIter->second.first,NULL);
+ }
+ if ( !m_bInShutDownConnections )
+ m_aConnections.erase(_aIter);
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::disposing( const ::com::sun::star::lang::EventObject& Source ) throw(::com::sun::star::uno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ Reference<XConnection> xCon(Source.Source,UNO_QUERY);
+ if ( xCon.is() )
+ {
+ TWeakPairVector::iterator i = m_aConnections.begin();
+ for (; m_aConnections.end() != i; ++i)
+ {
+ if ( i->first.get() == xCon.get() )
+ {
+ shutdownConnection(i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ Reference< XStorage> xStorage(Source.Source,UNO_QUERY);
+ if ( xStorage.is() )
+ {
+ ::rtl::OUString sKey = StorageContainer::getRegisteredKey(xStorage);
+ TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1(
+ ::std::bind2nd(::std::equal_to< ::rtl::OUString >(),sKey)
+ ,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< TWeakPair >())));
+ if ( i != m_aConnections.end() )
+ shutdownConnection(i);
+ }
+ }
+ }
+ //------------------------------------------------------------------
+ void ODriverDelegator::shutdownConnections()
+ {
+ m_bInShutDownConnections = sal_True;
+ TWeakPairVector::iterator aEnd = m_aConnections.end();
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ try
+ {
+ Reference<XConnection> xCon(i->first,UNO_QUERY);
+ ::comphelper::disposeComponent(xCon);
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ m_aConnections.clear();
+ m_bInShutDownConnections = sal_True;
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::preCommit( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ Reference< XStorage> xStorage(aEvent.Source,UNO_QUERY);
+ ::rtl::OUString sKey = StorageContainer::getRegisteredKey(xStorage);
+ if ( sKey.getLength() )
+ {
+ TWeakPairVector::iterator i = ::std::find_if(m_aConnections.begin(),m_aConnections.end(),::std::compose1(
+ ::std::bind2nd(::std::equal_to< ::rtl::OUString >(),sKey)
+ ,::std::compose1(::std::select1st<TWeakConnectionPair>(),::std::select2nd< TWeakPair >())));
+ OSL_ENSURE( i != m_aConnections.end(), "ODriverDelegator::preCommit: they're committing a storage which I do not know!" );
+ if ( i != m_aConnections.end() )
+ {
+ try
+ {
+ Reference<XConnection> xConnection(i->first,UNO_QUERY);
+ if ( xConnection.is() )
+ {
+ Reference< XStatement> xStmt = xConnection->createStatement();
+ OSL_ENSURE( xStmt.is(), "ODriverDelegator::preCommit: no statement!" );
+ if ( xStmt.is() )
+ xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 0" ) ) );
+
+ sal_Bool bPreviousAutoCommit = xConnection->getAutoCommit();
+ xConnection->setAutoCommit( sal_False );
+ xConnection->commit();
+ xConnection->setAutoCommit( bPreviousAutoCommit );
+
+ if ( xStmt.is() )
+ xStmt->execute( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SET WRITE_DELAY 60" ) ) );
+ }
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE( false, "ODriverDelegator::preCommit: caught an exception!" );
+ }
+ }
+ }
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::commited( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::preRevert( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
+ {
+ }
+ //------------------------------------------------------------------
+ void SAL_CALL ODriverDelegator::reverted( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ }
+ //------------------------------------------------------------------
+ namespace
+ {
+ //..............................................................
+ const sal_Char* lcl_getCollationForLocale( const ::rtl::OUString& _rLocaleString, bool _bAcceptCountryMismatch = false )
+ {
+ static const sal_Char* pTranslations[] =
+ {
+ "af-ZA", "Afrikaans",
+ "am-ET", "Amharic",
+ "ar", "Arabic",
+ "as-IN", "Assamese",
+ "az-AZ", "Azerbaijani_Latin",
+ "az-cyrillic", "Azerbaijani_Cyrillic",
+ "be-BY", "Belarusian",
+ "bg-BG", "Bulgarian",
+ "bn-IN", "Bengali",
+ "bo-CN", "Tibetan",
+ "bs-BA", "Bosnian",
+ "ca-ES", "Catalan",
+ "cs-CZ", "Czech",
+ "cy-GB", "Welsh",
+ "da-DK", "Danish",
+ "de-DE", "German",
+ "el-GR", "Greek",
+ "en-US", "Latin1_General",
+ "es-ES", "Spanish",
+ "et-EE", "Estonian",
+ "eu", "Basque",
+ "fi-FI", "Finnish",
+ "fr-FR", "French",
+ "gn-PY", "Guarani",
+ "gu-IN", "Gujarati",
+ "ha-NG", "Hausa",
+ "he-IL", "Hebrew",
+ "hi-IN", "Hindi",
+ "hr-HR", "Croatian",
+ "hu-HU", "Hungarian",
+ "hy-AM", "Armenian",
+ "id-ID", "Indonesian",
+ "ig-NG", "Igbo",
+ "is-IS", "Icelandic",
+ "it-IT", "Italian",
+ "iu-CA", "Inuktitut",
+ "ja-JP", "Japanese",
+ "ka-GE", "Georgian",
+ "kk-KZ", "Kazakh",
+ "km-KH", "Khmer",
+ "kn-IN", "Kannada",
+ "ko-KR", "Korean",
+ "kok-IN", "Konkani",
+ "ks", "Kashmiri",
+ "ky-KG", "Kirghiz",
+ "lo-LA", "Lao",
+ "lt-LT", "Lithuanian",
+ "lv-LV", "Latvian",
+ "mi-NZ", "Maori",
+ "mk-MK", "Macedonian",
+ "ml-IN", "Malayalam",
+ "mn-MN", "Mongolian",
+ "mni-IN", "Manipuri",
+ "mr-IN", "Marathi",
+ "ms-MY", "Malay",
+ "mt-MT", "Maltese",
+ "my-MM", "Burmese",
+ "nb-NO", "Danish_Norwegian",
+ "ne-NP", "Nepali",
+ "nl-NL", "Dutch",
+ "nn-NO", "Norwegian",
+ "or-IN", "Oriya",
+ "pa-IN", "Punjabi",
+ "pl-PL", "Polish",
+ "ps-AF", "Pashto",
+ "pt-PT", "Portuguese",
+ "ro-RO", "Romanian",
+ "ru-RU", "Russian",
+ "sa-IN", "Sanskrit",
+ "sd-IN", "Sindhi",
+ "sk-SK", "Slovak",
+ "sl-SI", "Slovenian",
+ "so-SO", "Somali",
+ "sq-AL", "Albanian",
+ "sr-YU", "Serbian_Cyrillic",
+ "sv-SE", "Swedish",
+ "sw-KE", "Swahili",
+ "ta-IN", "Tamil",
+ "te-IN", "Telugu",
+ "tg-TJ", "Tajik",
+ "th-TH", "Thai",
+ "tk-TM", "Turkmen",
+ "tn-BW", "Tswana",
+ "tr-TR", "Turkish",
+ "tt-RU", "Tatar",
+ "uk-UA", "Ukrainian",
+ "ur-PK", "Urdu",
+ "uz-UZ", "Uzbek_Latin",
+ "ven-ZA", "Venda",
+ "vi-VN", "Vietnamese",
+ "yo-NG", "Yoruba",
+ "zh-CN", "Chinese",
+ "zu-ZA", "Zulu",
+ NULL, NULL
+ };
+
+ ::rtl::OUString sLocaleString( _rLocaleString );
+ sal_Char nCompareTermination = 0;
+
+ if ( _bAcceptCountryMismatch )
+ {
+ // strip the country part from the compare string
+ sal_Int32 nCountrySep = sLocaleString.indexOf( '-' );
+ if ( nCountrySep > -1 )
+ sLocaleString = sLocaleString.copy( 0, nCountrySep );
+
+ // the entries in the translation table are compared until the
+ // - character only, not until the terminating 0
+ nCompareTermination = '-';
+ }
+
+ const sal_Char** pLookup = pTranslations;
+ for ( ; *pLookup; pLookup +=2 )
+ {
+ sal_Int32 nCompareUntil = 0;
+ while ( (*pLookup)[ nCompareUntil ] != nCompareTermination && (*pLookup)[ nCompareUntil ] != 0 )
+ ++nCompareUntil;
+
+ if ( sLocaleString.equalsAsciiL( *pLookup, nCompareUntil ) )
+ return *( pLookup + 1 );
+ }
+
+ if ( !_bAcceptCountryMismatch )
+ // second round, this time without matching the country
+ return lcl_getCollationForLocale( _rLocaleString, true );
+
+ OSL_ENSURE( false, "lcl_getCollationForLocale: unknown locale string, falling back to Latin1_General!" );
+ return "Latin1_General";
+ }
+
+ //..............................................................
+ ::rtl::OUString lcl_getSystemLocale( const Reference< XMultiServiceFactory >& _rxORB )
+ {
+ ::rtl::OUString sLocaleString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "en-US" ) );
+ try
+ {
+ //.........................................................
+ Reference< XMultiServiceFactory > xConfigProvider(
+ _rxORB->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationProvider" ) ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xConfigProvider.is(), "lcl_getSystemLocale: could not create the config provider!" );
+
+ if ( !xConfigProvider.is() )
+ return sLocaleString;
+
+ //.........................................................
+ // arguments for creating the config access
+ Sequence< Any > aArguments(2);
+ // the path to the node to open
+ ::rtl::OUString sNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Setup/L10N" );
+ aArguments[0] <<= PropertyValue( ::rtl::OUString::createFromAscii( "nodepath"), 0,
+ makeAny( sNodePath ), PropertyState_DIRECT_VALUE
+ );
+ // the depth: -1 means unlimited
+ aArguments[1] <<= PropertyValue(
+ ::rtl::OUString::createFromAscii( "depth"), 0,
+ makeAny( (sal_Int32)-1 ), PropertyState_DIRECT_VALUE
+ );
+
+ //.........................................................
+ // create the access
+ Reference< XPropertySet > xNode(
+ xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString::createFromAscii( "com.sun.star.configuration.ConfigurationAccess" ),
+ aArguments ),
+ UNO_QUERY );
+ OSL_ENSURE( xNode.is(), "lcl_getSystemLocale: invalid access returned (should throw an exception instead)!" );
+
+ //.........................................................
+ // ask for the system locale setting
+ if ( xNode.is() )
+ xNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ooSetupSystemLocale" ) ) ) >>= sLocaleString;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "lcl_getSystemLocale: caught an exception!" );
+ }
+ if ( !sLocaleString.getLength() )
+ {
+ rtl_Locale* pProcessLocale = NULL;
+ osl_getProcessLocale( &pProcessLocale );
+
+ ::rtl::OUStringBuffer aProcLocale;
+ aProcLocale.append( pProcessLocale->Language->buffer, pProcessLocale->Language->length );
+ if ( pProcessLocale->Country->length )
+ {
+ aProcLocale.appendAscii( "-" );
+ aProcLocale.append( pProcessLocale->Country->buffer, pProcessLocale->Country->length );
+ }
+ sLocaleString = aProcLocale.makeStringAndClear();
+ }
+ return sLocaleString;
+ }
+ }
+ //------------------------------------------------------------------
+ void ODriverDelegator::onConnectedNewDatabase( const Reference< XConnection >& _rxConnection )
+ {
+ try
+ {
+ Reference< XStatement > xStatement = _rxConnection->createStatement();
+ OSL_ENSURE( xStatement.is(), "ODriverDelegator::onConnectedNewDatabase: could not create a statement!" );
+ if ( xStatement.is() )
+ {
+ ::rtl::OUStringBuffer aStatement;
+ aStatement.appendAscii( "SET DATABASE COLLATION \"" );
+ aStatement.appendAscii( lcl_getCollationForLocale( lcl_getSystemLocale( m_xFactory ) ) );
+ aStatement.appendAscii( "\"" );
+
+ xStatement->execute( aStatement.makeStringAndClear() );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "ODriverDelegator::onConnectedNewDatabase: caught an exception!" );
+ }
+ }
+
+ //------------------------------------------------------------------
+ //------------------------------------------------------------------
+//........................................................................
+} // namespace connectivity
+//........................................................................
+
diff --git a/connectivity/source/drivers/hsqldb/HStorage.hxx b/connectivity/source/drivers/hsqldb/HStorage.hxx
new file mode 100644
index 000000000000..5dd8b4288b69
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorage.hxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_HSQLDB_STORAGE_HXX
+#define CONNECTIVITY_HSQLDB_STORAGE_HXX
+
+#include <cppuhelper/compbase6.hxx>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/io/XOutputStream.hpp>
+#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/lang/XInitialization.hpp>
+#include "connectivity/CommonTools.hxx"
+#include <comphelper/broadcasthelper.hxx>
+
+
+#define DECLARE_SERVICE_INFO_STATIC() \
+ DECLARE_SERVICE_INFO(); \
+ static ::rtl::OUString SAL_CALL getImplementationName_Static( ) throw (::com::sun::star::uno::RuntimeException); \
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames_Static( ) throw(::com::sun::star::uno::RuntimeException); \
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > \
+ SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&) \
+
+
+namespace connectivity
+{
+ namespace hsqldb
+ {
+ typedef ::cppu::WeakComponentImplHelper6< ::com::sun::star::io::XStream
+ , ::com::sun::star::io::XInputStream
+ , ::com::sun::star::io::XOutputStream
+ , ::com::sun::star::io::XSeekable
+ , ::com::sun::star::lang::XInitialization
+ , ::com::sun::star::lang::XServiceInfo> OStorage_Base;
+ class OStorage : public ::comphelper::OBaseMutex
+ ,public OStorage_Base
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceFactory;
+ ::com::sun::star::uno::Reference< ::com::sun::star::document::XDocumentSubStorageSupplier> m_xDS;
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage> m_xStorge;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XStream > m_xStream;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > m_xIn;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > m_xOut;
+ ::com::sun::star::uno::Reference< ::com::sun::star::io::XSeekable > m_xSeek;
+
+ OStorage(); // never implemented
+ OStorage(const OStorage&); // never implemented
+ int operator= (const OStorage&); // never implemented
+
+ OStorage(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+ protected:
+ /** this function is called upon disposing the component
+ */
+ virtual void SAL_CALL disposing();
+ public:
+ // ::com::sun::star::lang::XServiceInfo
+ DECLARE_SERVICE_INFO_STATIC();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw(::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+
+ // XStream
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getInputStream( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XOutputStream > SAL_CALL getOutputStream( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XInputStream
+ virtual ::sal_Int32 SAL_CALL readBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL readSomeBytes( ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData, ::sal_Int32 nMaxBytesToRead ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL skipBytes( ::sal_Int32 nBytesToSkip ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL available( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeInput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XOutputStream
+ virtual void SAL_CALL writeBytes( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aData ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL flush( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL closeOutput( ) throw (::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+
+ // XSeekable
+ virtual void SAL_CALL seek( ::sal_Int64 location ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL getPosition( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int64 SAL_CALL getLength( ) throw (::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+// .......................................................................
+} // connectivity
+// .......................................................................
+#endif // CONNECTIVITY_HSQLDB_STORAGE_HXX
+
diff --git a/connectivity/source/drivers/hsqldb/HStorageAccess.cxx b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
new file mode 100644
index 000000000000..1452df992a74
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageAccess.cxx
@@ -0,0 +1,555 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HStorageAccess.hxx"
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/io/XStream.hpp>
+#include "hsqldb/HStorageMap.hxx"
+#include "hsqldb/StorageNativeInputStream.h"
+#include "accesslog.hxx"
+#include "diagnose_ex.h"
+
+#include <string.h>
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key, jint mode)
+{
+#ifdef HSQLDB_DBG
+ {
+ OperationLogFile( env, name, "data" ).logOperation( "openStream" );
+ LogFile( env, name, "data" ).create();
+ }
+#endif
+
+ StorageContainer::registerStream(env,name,key,mode);
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
+{
+#ifdef HSQLDB_DBG
+ {
+ ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
+ ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
+ }
+#endif
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
+ if ( xFlush.is() )
+ try
+ {
+ xFlush->flush();
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE( false, "NativeStorageAccess::close: caught an exception while flushing!" );
+ }
+#ifdef HSQLDB_DBG
+ {
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "close" );
+ aOpLog.close();
+
+ LogFile aDataLog( env, name, "data" );
+ aDataLog.close();
+ }
+#endif
+
+ StorageContainer::revokeStream(env,name,key);
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: getFilePointer
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "getFilePointer" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+
+ jlong nReturn = pHelper.get() ? pHelper->getSeek()->getPosition() : jlong(0);
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nReturn );
+#endif
+ return nReturn;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: length
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)J
+ */
+SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "length" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+
+ jlong nReturn = pHelper.get() ? pHelper->getSeek()->getLength() :jlong(0);
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nReturn );
+#endif
+ return nReturn;
+}
+
+// -----------------------------------------------------------------------------
+
+jint read_from_storage_stream( JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, DataLogFile* logger )
+{
+ OSL_UNUSED( logger );
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>();
+ OSL_ENSURE(xIn.is(),"Input stream is NULL!");
+ if ( xIn.is() )
+ {
+ Sequence< ::sal_Int8 > aData(1);
+ sal_Int32 nBytesRead = -1;
+ try
+ {
+ nBytesRead = xIn->readBytes(aData,1);
+ }
+ catch(Exception& e)
+ {
+ StorageContainer::throwJavaException(e,env);
+ return -1;
+
+ }
+ if (nBytesRead <= 0)
+ {
+ return (-1);
+ }
+ else
+ {
+ sal_Int32 tmpInt = aData[0];
+ if (tmpInt < 0 )
+ tmpInt = 256 +tmpInt;
+
+#ifdef HSQLDB_DBG
+ if ( logger )
+ logger->write( tmpInt );
+#endif
+ return(tmpInt);
+ }
+ }
+ return -1;
+}
+
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv* env, jobject obj_this, jstring name, jstring key)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "read" );
+
+ DataLogFile aDataLog( env, name, "data" );
+ return read_from_storage_stream( env, obj_this, name, key, &aDataLog );
+#else
+ return read_from_storage_stream( env, obj_this, name, key );
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+jint read_from_storage_stream_into_buffer( JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key, jbyteArray buffer, jint off, jint len, DataLogFile* logger )
+{
+ OSL_UNUSED( logger );
+#ifdef HSQLDB_DBG
+ {
+ ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
+ ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
+ }
+#endif
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>();
+ OSL_ENSURE(xIn.is(),"Input stream is NULL!");
+ if ( xIn.is() )
+ {
+ jsize nLen = env->GetArrayLength(buffer);
+ if ( nLen < len )
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "len is greater or equal to the buffer size");
+ return -1;
+ }
+ sal_Int32 nBytesRead = -1;
+
+ Sequence< ::sal_Int8 > aData(nLen);
+ try
+ {
+ nBytesRead = xIn->readBytes(aData, len);
+ }
+ catch(Exception& e)
+ {
+ StorageContainer::throwJavaException(e,env);
+ return -1;
+ }
+
+ if (nBytesRead <= 0)
+ return -1;
+ env->SetByteArrayRegion(buffer,off,nBytesRead,&aData[0]);
+
+#ifdef HSQLDB_DBG
+ if ( logger )
+ logger->write( aData.getConstArray(), nBytesRead );
+#endif
+ return nBytesRead;
+ }
+ ThrowException( env,
+ "java/io/IOException",
+ "Stream is not valid");
+ return -1;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+ (JNIEnv * env, jobject obj_this,jstring name, jstring key, jbyteArray buffer, jint off, jint len)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "read( byte[], int, int )" );
+
+ DataLogFile aDataLog( env, name, "data" );
+ return read_from_storage_stream_into_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
+#else
+ return read_from_storage_stream_into_buffer( env, obj_this, name, key, buffer, off, len );
+#endif
+}
+
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: readInt
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "readInt" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>();
+ OSL_ENSURE(xIn.is(),"Input stream is NULL!");
+ if ( xIn.is() )
+ {
+ Sequence< ::sal_Int8 > aData(4);
+ sal_Int32 nBytesRead = -1;
+ try
+ {
+ nBytesRead = xIn->readBytes(aData, 4);
+ }
+ catch(Exception& e)
+ {
+ StorageContainer::throwJavaException(e,env);
+ return -1;
+ }
+
+ if ( nBytesRead != 4 ) {
+ ThrowException( env,
+ "java/io/IOException",
+ "Bytes read != 4");
+ return -1;
+ }
+
+ Sequence< sal_Int32 > ch(4);
+ for(sal_Int32 i = 0;i < 4; ++i)
+ {
+ ch[i] = aData[i];
+ if (ch[i] < 0 )
+ ch[i] = 256 + ch[i];
+ }
+
+ if ((ch[0] | ch[1] | ch[2] | ch[3]) < 0)
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "One byte is < 0");
+ return -1;
+ }
+ jint nRet = ((ch[0] << 24) + (ch[1] << 16) + (ch[2] << 8) + (ch[3] << 0));
+#ifdef HSQLDB_DBG
+ DataLogFile aDataLog( env, name, "data" );
+ aDataLog.write( nRet );
+
+ aOpLog.logReturn( nRet );
+#endif
+ return nRet;
+ }
+ ThrowException( env,
+ "java/io/IOException",
+ "No InputStream");
+ return -1;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: seek
+ * Signature: (Ljava/lang/String;Ljava/lang/String;J)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek
+ (JNIEnv * env, jobject /*obj_this*/,jstring name, jstring key, jlong position)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "seek", position );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XSeekable> xSeek = pHelper.get() ? pHelper->getSeek() : Reference< XSeekable>();
+
+ OSL_ENSURE(xSeek.is(),"No Seekable stream!");
+ if ( xSeek.is() )
+ {
+ #ifdef HSQLDB_DBG
+ DataLogFile aDataLog( env, name, "data" );
+ #endif
+
+ ::sal_Int64 nLen = xSeek->getLength();
+ if ( nLen < position)
+ {
+ static ::sal_Int64 BUFFER_SIZE = 9192;
+ #ifdef HSQLDB_DBG
+ aDataLog.seek( nLen );
+ #endif
+ xSeek->seek(nLen);
+ Reference< XOutputStream> xOut = pHelper->getOutputStream();
+ OSL_ENSURE(xOut.is(),"No output stream!");
+
+ ::sal_Int64 diff = position - nLen;
+ sal_Int32 n;
+ while( diff != 0 )
+ {
+ if ( BUFFER_SIZE < diff )
+ {
+ n = static_cast<sal_Int32>(BUFFER_SIZE);
+ diff = diff - BUFFER_SIZE;
+ }
+ else
+ {
+ n = static_cast<sal_Int32>(diff);
+ diff = 0;
+ }
+ Sequence< ::sal_Int8 > aData(n);
+ memset(aData.getArray(),0,n);
+ xOut->writeBytes(aData);
+ #ifdef HSQLDB_DBG
+ aDataLog.write( aData.getConstArray(), n );
+ #endif
+ }
+ }
+ xSeek->seek(position);
+ OSL_ENSURE(xSeek->getPosition() == position,"Wrong position after seeking the stream");
+
+ #ifdef HSQLDB_DBG
+ aDataLog.seek( position );
+ OSL_ENSURE( xSeek->getPosition() == aDataLog.tell(), "Wrong position after seeking the stream" );
+ #endif
+ }
+}
+// -----------------------------------------------------------------------------
+
+void write_to_storage_stream_from_buffer( JNIEnv* env, jobject /*obj_this*/, jstring name, jstring key, jbyteArray buffer, jint off, jint len, DataLogFile* logger )
+{
+ OSL_UNUSED( logger );
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XOutputStream> xOut = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
+ OSL_ENSURE(xOut.is(),"Stream is NULL");
+
+ try
+ {
+ if ( xOut.is() )
+ {
+ jbyte *buf = env->GetByteArrayElements(buffer,NULL);
+#ifdef HSQLDB_DBG
+ OSL_ENSURE(len <= env->GetArrayLength(buffer),"Length is greater than the buffer!");
+#endif
+
+ if (JNI_FALSE != env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_ENSURE(0,"ExceptionClear");
+ }
+ OSL_ENSURE(buf,"buf is NULL");
+ if ( buf )
+ {
+ Sequence< ::sal_Int8 > aData(buf + off,len);
+ xOut->writeBytes(aData);
+ env->ReleaseByteArrayElements(buffer, buf, JNI_ABORT);
+#ifdef HSQLDB_DBG
+ if ( logger )
+ logger->write( aData.getConstArray(), len );
+#endif
+ }
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "No OutputStream");
+ }
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception caught! : write [BII)V");
+ StorageContainer::throwJavaException(e,env);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: write
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write
+ (JNIEnv * env, jobject obj_this,jstring name, jstring key, jbyteArray buffer, jint off, jint len)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "write( byte[], int, int )" );
+
+ DataLogFile aDataLog( env, name, "data" );
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
+#else
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+void write_to_storage_stream( JNIEnv* env, jobject /*obj_this*/, jstring name, jstring key, jint v, DataLogFile* logger )
+{
+ OSL_UNUSED( logger );
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XOutputStream> xOut = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
+ OSL_ENSURE(xOut.is(),"Stream is NULL");
+ try
+ {
+ if ( xOut.is() )
+ {
+ Sequence< ::sal_Int8 > oneByte(4);
+ oneByte[0] = (sal_Int8) ((v >> 24) & 0xFF);
+ oneByte[1] = (sal_Int8) ((v >> 16) & 0xFF);
+ oneByte[2] = (sal_Int8) ((v >> 8) & 0xFF);
+ oneByte[3] = (sal_Int8) ((v >> 0) & 0xFF);
+
+ xOut->writeBytes(oneByte);
+#ifdef HSQLDB_DBG
+ if ( logger )
+ logger->write( oneByte.getConstArray(), 4 );
+#endif
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "No OutputStream");
+ }
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : writeBytes(aData);");
+ StorageContainer::throwJavaException(e,env);
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess
+ * Method: writeInt
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt
+ (JNIEnv * env, jobject obj_this,jstring name, jstring key, jint v)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "data" );
+ aOpLog.logOperation( "writeInt" );
+
+ DataLogFile aDataLog( env, name, "data" );
+ write_to_storage_stream( env, obj_this, name, key, v, &aDataLog );
+#else
+ write_to_storage_stream( env, obj_this, name, key, v );
+#endif
+}
diff --git a/connectivity/source/drivers/hsqldb/HStorageMap.cxx b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
new file mode 100644
index 000000000000..afb4d0da2640
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HStorageMap.cxx
@@ -0,0 +1,360 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HStorageMap.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/embed/XTransactionBroadcaster.hpp>
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "diagnose_ex.h"
+#include <osl/thread.h>
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+ namespace hsqldb
+ {
+ //........................................................................
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::lang;
+ using namespace ::com::sun::star::embed;
+ using namespace ::com::sun::star::io;
+
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+
+
+ StreamHelper::StreamHelper(const Reference< XStream>& _xStream)
+ : m_xStream(_xStream)
+ {
+ }
+ // -----------------------------------------------------------------------------
+ StreamHelper::~StreamHelper()
+ {
+ try
+ {
+ m_xStream.clear();
+ m_xSeek.clear();
+ if ( m_xInputStream.is() )
+ {
+ m_xInputStream->closeInput();
+ m_xInputStream.clear();
+ }
+ if ( m_xOutputStream.is() )
+ {
+ m_xOutputStream->closeOutput();
+ try
+ {
+ ::comphelper::disposeComponent(m_xOutputStream);
+ }
+ catch(DisposedException&)
+ {
+ }
+ catch(const Exception& e)
+ {
+ OSL_UNUSED( e );
+ OSL_ENSURE(0,"Could not dispose OutputStream");
+ }
+ m_xOutputStream.clear();
+ }
+ }
+ catch(Exception& )
+ {
+ OSL_ENSURE(0,"Exception catched!");
+ }
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XInputStream> StreamHelper::getInputStream()
+ {
+ if ( !m_xInputStream.is() )
+ m_xInputStream = m_xStream->getInputStream();
+ return m_xInputStream;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XOutputStream> StreamHelper::getOutputStream()
+ {
+ if ( !m_xOutputStream.is() )
+ m_xOutputStream = m_xStream->getOutputStream();
+ return m_xOutputStream;
+ }
+ // -----------------------------------------------------------------------------
+ Reference< XSeekable> StreamHelper::getSeek()
+ {
+ if ( !m_xSeek.is() )
+ m_xSeek.set(m_xStream,UNO_QUERY);
+ return m_xSeek;
+ }
+ // -----------------------------------------------------------------------------
+ TStorages& lcl_getStorageMap()
+ {
+ static TStorages s_aMap;
+ return s_aMap;
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString lcl_getNextCount()
+ {
+ static sal_Int32 s_nCount = 0;
+ return ::rtl::OUString::valueOf(s_nCount++);
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString StorageContainer::removeURLPrefix(const ::rtl::OUString& _sURL,const ::rtl::OUString& _sFileURL)
+ {
+ return _sURL.copy(_sFileURL.getLength()+1);
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString StorageContainer::removeOldURLPrefix(const ::rtl::OUString& _sURL)
+ {
+ ::rtl::OUString sRet = _sURL;
+#if defined(WIN) || defined(WNT)
+ sal_Int32 nIndex = sRet.lastIndexOf('\\');
+#else
+ sal_Int32 nIndex = sRet.lastIndexOf('/');
+#endif
+ if ( nIndex != -1 )
+ {
+ sRet = _sURL.copy(nIndex+1);
+ }
+ return sRet;
+
+ }
+ /*****************************************************************************/
+ /* convert jstring to rtl_uString */
+
+ ::rtl::OUString StorageContainer::jstring2ustring(JNIEnv * env, jstring jstr)
+ {
+ if (JNI_FALSE != env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_ENSURE(0,"ExceptionClear");
+ }
+ ::rtl::OUString aStr;
+ if ( jstr )
+ {
+ jboolean bCopy(sal_True);
+ const jchar* pChar = env->GetStringChars(jstr,&bCopy);
+ jsize len = env->GetStringLength(jstr);
+ aStr = ::rtl::OUString(pChar,len);
+
+ if(bCopy)
+ env->ReleaseStringChars(jstr,pChar);
+ }
+
+ if (JNI_FALSE != env->ExceptionCheck())
+ {
+ env->ExceptionClear();
+ OSL_ENSURE(0,"ExceptionClear");
+ }
+ return aStr;
+ }
+
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString StorageContainer::registerStorage(const Reference< XStorage>& _xStorage,const ::rtl::OUString& _sURL)
+ {
+ OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+ TStorages& rMap = lcl_getStorageMap();
+ // check if the storage is already in our map
+ TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(),
+ ::std::compose1(
+ ::std::bind2nd(::std::equal_to<Reference<XStorage> >(),_xStorage)
+ ,::std::compose1(::std::select1st<TStorageURLPair>(),::std::compose1(::std::select1st<TStorages::mapped_type>(),::std::select2nd<TStorages::value_type>())))
+ );
+ if ( aFind == rMap.end() )
+ {
+ aFind = rMap.insert(TStorages::value_type(lcl_getNextCount(),TStorages::mapped_type(TStorageURLPair(_xStorage,_sURL),TStreamMap()))).first;
+ }
+
+ return aFind->first;
+ }
+ // -----------------------------------------------------------------------------
+ TStorages::mapped_type StorageContainer::getRegisteredStorage(const ::rtl::OUString& _sKey)
+ {
+ TStorages::mapped_type aRet;
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(_sKey);
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ aRet = aFind->second;
+
+ return aRet;
+ }
+ // -----------------------------------------------------------------------------
+ ::rtl::OUString StorageContainer::getRegisteredKey(const Reference< XStorage>& _xStorage)
+ {
+ ::rtl::OUString sKey;
+ OSL_ENSURE(_xStorage.is(),"Storage is NULL!");
+ TStorages& rMap = lcl_getStorageMap();
+ // check if the storage is already in our map
+ TStorages::iterator aFind = ::std::find_if(rMap.begin(),rMap.end(),
+ ::std::compose1(
+ ::std::bind2nd(::std::equal_to<Reference<XStorage> >(),_xStorage)
+ ,::std::compose1(::std::select1st<TStorageURLPair>(),::std::compose1(::std::select1st<TStorages::mapped_type>(),::std::select2nd<TStorages::value_type>())))
+ );
+ if ( aFind != rMap.end() )
+ sKey = aFind->first;
+ return sKey;
+ }
+ // -----------------------------------------------------------------------------
+ void StorageContainer::revokeStorage(const ::rtl::OUString& _sKey,const Reference<XTransactionListener>& _xListener)
+ {
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(_sKey);
+ if ( aFind != rMap.end() )
+ {
+ try
+ {
+ if ( _xListener.is() )
+ {
+ Reference<XTransactionBroadcaster> xBroad(aFind->second.first.first,UNO_QUERY);
+ if ( xBroad.is() )
+ xBroad->removeTransactionListener(_xListener);
+ Reference<XTransactedObject> xTrans(aFind->second.first.first,UNO_QUERY);
+ if ( xTrans.is() )
+ xTrans->commit();
+ }
+ }
+ catch(Exception&)
+ {
+ }
+ rMap.erase(aFind);
+ }
+ }
+ // -----------------------------------------------------------------------------
+ TStreamMap::mapped_type StorageContainer::registerStream(JNIEnv * env,jstring name, jstring key,sal_Int32 _nMode)
+ {
+ TStreamMap::mapped_type pHelper;
+ TStorages& rMap = lcl_getStorageMap();
+ ::rtl::OUString sKey = jstring2ustring(env,key);
+ TStorages::iterator aFind = rMap.find(sKey);
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ {
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(sKey);
+ OSL_ENSURE(aStoragePair.first.first.is(),"No Storage available!");
+ if ( aStoragePair.first.first.is() )
+ {
+ ::rtl::OUString sOrgName = StorageContainer::jstring2ustring(env,name);
+ ::rtl::OUString sName = removeURLPrefix(sOrgName,aStoragePair.first.second);
+ TStreamMap::iterator aStreamFind = aFind->second.second.find(sName);
+ OSL_ENSURE( aStreamFind == aFind->second.second.end(),"A Stream was already registered for this object!");
+ if ( aStreamFind != aFind->second.second.end() )
+ {
+ pHelper = aStreamFind->second;
+ }
+ else
+ {
+ try
+ {
+ try
+ {
+ pHelper.reset(new StreamHelper(aStoragePair.first.first->openStreamElement(sName,_nMode)));
+ }
+ catch(Exception& )
+ {
+ ::rtl::OUString sStrippedName = removeOldURLPrefix(sOrgName);
+
+ if ( ((_nMode & ElementModes::WRITE) != ElementModes::WRITE ) )
+ {
+ sal_Bool bIsStream = sal_True;
+ try
+ {
+ bIsStream = aStoragePair.first.first->isStreamElement(sStrippedName);
+ }
+ catch(Exception& )
+ {
+ bIsStream = sal_False;
+ }
+ if ( !bIsStream )
+ return pHelper; // readonly file without data stream
+ }
+ pHelper.reset( new StreamHelper(aStoragePair.first.first->openStreamElement( sStrippedName, _nMode ) ) );
+ }
+ aFind->second.second.insert(TStreamMap::value_type(sName,pHelper));
+ }
+ catch(Exception& e)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ ::rtl::OString sMessage( "[HSQLDB-SDBC] caught an exception while opening a stream\n" );
+ sMessage += "Name: ";
+ sMessage += ::rtl::OString( sName.getStr(), sName.getLength(), osl_getThreadTextEncoding() );
+ sMessage += "\nMode: 0x";
+ if ( _nMode < 16 )
+ sMessage += "0";
+ sMessage += ::rtl::OString::valueOf( _nMode, 16 ).toAsciiUpperCase();
+ OSL_ENSURE( false, sMessage.getStr() );
+#endif
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ }
+ }
+ return pHelper;
+ }
+ // -----------------------------------------------------------------------------
+ void StorageContainer::revokeStream( JNIEnv * env,jstring name, jstring key)
+ {
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ aFind->second.second.erase(removeURLPrefix(jstring2ustring(env,name),aFind->second.first.second));
+ }
+ // -----------------------------------------------------------------------------
+ TStreamMap::mapped_type StorageContainer::getRegisteredStream( JNIEnv * env,jstring name, jstring key)
+ {
+ TStreamMap::mapped_type pRet;
+ TStorages& rMap = lcl_getStorageMap();
+ TStorages::iterator aFind = rMap.find(jstring2ustring(env,key));
+ OSL_ENSURE(aFind != rMap.end(),"Storage could not be found in list!");
+ if ( aFind != rMap.end() )
+ {
+ TStreamMap::iterator aStreamFind = aFind->second.second.find(removeURLPrefix(jstring2ustring(env,name),aFind->second.first.second));
+ if ( aStreamFind != aFind->second.second.end() )
+ pRet = aStreamFind->second;
+ }
+
+ return pRet;
+ }
+ // -----------------------------------------------------------------------------
+ void StorageContainer::throwJavaException(const Exception& _aException,JNIEnv * env)
+ {
+ if (JNI_FALSE != env->ExceptionCheck())
+ env->ExceptionClear();
+ ::rtl::OString cstr( ::rtl::OUStringToOString(_aException.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
+ OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
+ env->ThrowNew(env->FindClass("java/io/IOException"), cstr.getStr());
+ }
+ //........................................................................
+ } // namespace hsqldb
+ //........................................................................
+//........................................................................
+}
+// namespace connectivity
+//........................................................................
diff --git a/connectivity/source/drivers/hsqldb/HTable.cxx b/connectivity/source/drivers/hsqldb/HTable.cxx
new file mode 100644
index 000000000000..fdf16c8b975a
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTable.cxx
@@ -0,0 +1,427 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HTable.hxx"
+#include "hsqldb/HTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/TKeys.hxx"
+#include "connectivity/TIndexes.hxx"
+#include "connectivity/TColumnsHelper.hxx"
+#include "hsqldb/HCatalog.hxx"
+#include "hsqldb/HColumns.hxx"
+#include "TConnection.hxx"
+
+#include <tools/diagnose_ex.h>
+
+
+using namespace ::comphelper;
+using namespace connectivity::hsqldb;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OHSQLTable::OHSQLTable( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection)
+ :OTableHelper(_pTables,_xConnection,sal_True)
+{
+ // we create a new table here, so we should have all the rights or ;-)
+ m_nPrivileges = Privilege::DROP |
+ Privilege::REFERENCE |
+ Privilege::ALTER |
+ Privilege::CREATE |
+ Privilege::READ |
+ Privilege::DELETE |
+ Privilege::UPDATE |
+ Privilege::INSERT |
+ Privilege::SELECT;
+ construct();
+}
+// -------------------------------------------------------------------------
+OHSQLTable::OHSQLTable( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName,
+ sal_Int32 _nPrivileges
+ ) : OTableHelper( _pTables,
+ _xConnection,
+ sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ , m_nPrivileges(_nPrivileges)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OHSQLTable::construct()
+{
+ OTableHelper::construct();
+ if ( !isNew() )
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRIVILEGES), PROPERTY_ID_PRIVILEGES,PropertyAttribute::READONLY,&m_nPrivileges, ::getCppuType(&m_nPrivileges));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OHSQLTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OHSQLTable::getInfoHelper()
+{
+ return *static_cast<OHSQLTable_PROP*>(const_cast<OHSQLTable*>(this))->getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OHSQLTable::createColumns(const TStringVector& _rNames)
+{
+ OHSQLColumns* pColumns = new OHSQLColumns(*this,sal_True,m_aMutex,_rNames);
+ pColumns->setParent(this);
+ return pColumns;
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OHSQLTable::createKeys(const TStringVector& _rNames)
+{
+ return new OKeysHelper(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OHSQLTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexesHelper(this,m_aMutex,_rNames);
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OHSQLTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OHSQLTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OHSQLTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ if ( m_pColumns && !m_pColumns->hasByName(colName) )
+ throw NoSuchElementException(colName,*this);
+
+
+ if ( !isNew() )
+ {
+ // first we have to check what should be altered
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByName(colName) >>= xProp;
+ // first check the types
+ sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
+ ::rtl::OUString sOldTypeName, sNewTypeName;
+
+ ::dbtools::OPropertyMap& rProp = OMetaConnection::getPropMap();
+
+ // type/typename
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nOldType;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nNewType;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sOldTypeName;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME))>>= sNewTypeName;
+
+ // and precsions and scale
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION)) >>= nOldPrec;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION))>>= nNewPrec;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nOldScale;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nNewScale;
+
+ // second: check the "is nullable" value
+ sal_Int32 nOldNullable = 0,nNewNullable = 0;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nOldNullable;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNewNullable;
+
+ // check also the auto_increment
+ sal_Bool bOldAutoIncrement = sal_False,bAutoIncrement = sal_False;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bOldAutoIncrement;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
+
+ // now we should look if the name of the column changed
+ ::rtl::OUString sNewColumnName;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
+ if ( !sNewColumnName.equals(colName) )
+ {
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN "));
+ sSql += ::dbtools::quoteName(sQuote,colName);
+
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" RENAME TO "));
+ sSql += ::dbtools::quoteName(sQuote,sNewColumnName);
+
+ executeStatement(sSql);
+ }
+
+ if ( nOldType != nNewType
+ || sOldTypeName != sNewTypeName
+ || nOldPrec != nNewPrec
+ || nOldScale != nNewScale
+ || nNewNullable != nOldNullable
+ || bOldAutoIncrement != bAutoIncrement )
+ {
+ // special handling because they change the type names to distinguish
+ // if a column should be an auto_incmrement one
+ if ( bOldAutoIncrement != bAutoIncrement )
+ {
+ /// TODO: insert special handling for auto increment "IDENTITY" and primary key
+ }
+ alterColumnType(nNewType,sNewColumnName,descriptor);
+ }
+
+ // third: check the default values
+ ::rtl::OUString sNewDefault,sOldDefault;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sOldDefault;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sNewDefault;
+
+ if(sOldDefault.getLength())
+ {
+ dropDefaultValue(colName);
+ if(sNewDefault.getLength() && sOldDefault != sNewDefault)
+ alterDefaultValue(sNewDefault,sNewColumnName);
+ }
+ else if(!sOldDefault.getLength() && sNewDefault.getLength())
+ alterDefaultValue(sNewDefault,sNewColumnName);
+
+ m_pColumns->refresh();
+ }
+ else
+ {
+ if(m_pColumns)
+ {
+ m_pColumns->dropByName(colName);
+ m_pColumns->appendByDescriptor(descriptor);
+ }
+ }
+
+}
+// -----------------------------------------------------------------------------
+void OHSQLTable::alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName, const Reference<XPropertySet>& _xDescriptor)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN "));
+#if OSL_DEBUG_LEVEL > 0
+ try
+ {
+ ::rtl::OUString sDescriptorName;
+ OSL_ENSURE( _xDescriptor.is()
+ && ( _xDescriptor->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sDescriptorName )
+ && ( sDescriptorName == _rColName ),
+ "OHSQLTable::alterColumnType: unexpected column name!" );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+#else
+ (void)_rColName;
+#endif
+
+ OHSQLColumn* pColumn = new OHSQLColumn(sal_True);
+ Reference<XPropertySet> xProp = pColumn;
+ ::comphelper::copyProperties(_xDescriptor,xProp);
+ xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType));
+
+ sSql += ::dbtools::createStandardColumnPart(xProp,getConnection());
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+void OHSQLTable::alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN "));
+
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,_rColName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SET DEFAULT '")) + _sNewDefault;
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("'"));
+
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+void OHSQLTable::dropDefaultValue(const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER COLUMN "));
+
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,_rColName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP DEFAULT"));
+
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OHSQLTable::getAlterTableColumnPart()
+{
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sComposedName( ::dbtools::composeTableName( getMetaData(), m_CatalogName, m_SchemaName, m_Name, sal_True, ::dbtools::eInTableDefinitions ) );
+ sSql += sComposedName;
+
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+void OHSQLTable::executeStatement(const ::rtl::OUString& _rStatement )
+{
+ ::rtl::OUString sSQL = _rStatement;
+ if(sSQL.lastIndexOf(',') == (sSQL.getLength()-1))
+ sSQL = sSQL.replaceAt(sSQL.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ Reference< XStatement > xStmt = getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ try { xStmt->execute(sSQL); }
+ catch( const Exception& )
+ {
+ ::comphelper::disposeComponent(xStmt);
+ throw;
+ }
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OHSQLTable::getTypes( ) throw(RuntimeException)
+{
+ if ( ! m_Type.compareToAscii("VIEW") )
+ {
+ Sequence< Type > aTypes = OTableHelper::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pIter = aTypes.getConstArray();
+ const Type* pEnd = pIter + aTypes.getLength();
+ for(;pIter != pEnd;++pIter)
+ {
+ if( *pIter != ::getCppuType((const Reference<XRename>*)0) )
+ {
+ aOwnTypes.push_back(*pIter);
+ }
+ }
+ Type *pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+ }
+ return OTableHelper::getTypes();
+}
+// -------------------------------------------------------------------------
+// XRename
+void SAL_CALL OHSQLTable::rename( const ::rtl::OUString& newName ) throw(SQLException, ElementExistException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ if(!isNew())
+ {
+ ::rtl::OUString sSql = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ALTER "));
+ if ( m_Type == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")) )
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" VIEW "));
+ else
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" TABLE "));
+
+ ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(getMetaData(),newName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( getMetaData(), m_CatalogName, m_SchemaName, m_Name, sal_True, ::dbtools::eInDataManipulation ) );
+ sSql += sComposedName
+ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" RENAME TO "));
+ sSql += ::dbtools::composeTableName( getMetaData(), sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation );
+
+ executeStatement(sSql);
+
+ ::connectivity::OTable_TYPEDEF::rename(newName);
+ }
+ else
+ ::dbtools::qualifiedNameComponents(getMetaData(),newName,m_CatalogName,m_SchemaName,m_Name,::dbtools::eInTableDefinitions);
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OHSQLTable::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if( !m_Type.compareToAscii("VIEW") && rType == ::getCppuType((const Reference<XRename>*)0) )
+ return Any();
+
+ return OTableHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/hsqldb/HTables.cxx b/connectivity/source/drivers/hsqldb/HTables.cxx
new file mode 100644
index 000000000000..3013d2838fb0
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTables.cxx
@@ -0,0 +1,200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HTables.hxx"
+#include "hsqldb/HViews.hxx"
+#include "hsqldb/HTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "hsqldb/HCatalog.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_rName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ static const ::rtl::OUString s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ static const ::rtl::OUString s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+ static const ::rtl::OUString s_sAll(RTL_CONSTASCII_USTRINGPARAM("%"));
+
+ Sequence< ::rtl::OUString > sTableTypes(3);
+ sTableTypes[0] = s_sTableTypeView;
+ sTableTypes[1] = s_sTableTypeTable;
+ sTableTypes[2] = s_sAll; // just to be sure to include anything else ....
+
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if ( xResult->next() ) // there can be only one table with this name
+ {
+ sal_Int32 nPrivileges = ::dbtools::getTablePrivileges( m_xMetaData, sCatalog, sSchema, sTable );
+ if ( m_xMetaData->isReadOnly() )
+ nPrivileges &= ~( Privilege::INSERT | Privilege::UPDATE | Privilege::DELETE | Privilege::CREATE | Privilege::ALTER | Privilege::DROP );
+
+ // obtain privileges
+ OHSQLTable* pRet = new OHSQLTable( this
+ ,static_cast<OHCatalog&>(m_rParent).getConnection()
+ ,sTable
+ ,xRow->getString(4)
+ ,xRow->getString(5)
+ ,sSchema
+ ,sCatalog
+ ,nPrivileges);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OHCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OHSQLTable(this,static_cast<OHCatalog&>(m_rParent).getConnection());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createTable(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ Reference< XConnection > xConnection = static_cast<OHCatalog&>(m_rParent).getConnection();
+
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_sElementName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ sal_Bool bIsView;
+ if((bIsView = (xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == ::rtl::OUString::createFromAscii("VIEW")))) // here we have a view
+ aSql += ::rtl::OUString::createFromAscii("VIEW ");
+ else
+ aSql += ::rtl::OUString::createFromAscii("TABLE ");
+
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation ) );
+ aSql += sComposedName;
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ // if no exception was thrown we must delete it from the views
+ if ( bIsView )
+ {
+ HViews* pViews = static_cast<HViews*>(static_cast<OHCatalog&>(m_rParent).getPrivateViews());
+ if ( pViews && pViews->hasByName(_sElementName) )
+ pViews->dropByNameImpl(_sElementName);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+ Reference< XConnection > xConnection = static_cast<OHCatalog&>(m_rParent).getConnection();
+ ::rtl::OUString aSql = ::dbtools::createSqlCreateTableStatement(descriptor,xConnection);
+
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
+{
+ insertElement(_rsNewTable,NULL);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+ return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::eInDataManipulation, false, false, false );
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.cxx b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
new file mode 100644
index 000000000000..c386334acd70
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.cxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "HTerminateListener.hxx"
+#include "hsqldb/HDriver.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+ using namespace hsqldb;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::frame;
+ using namespace ::com::sun::star::lang;
+ using namespace ::rtl;
+
+// XEventListener
+void SAL_CALL OConnectionController::disposing( const EventObject& /*Source*/ )
+throw( RuntimeException )
+{
+}
+
+// XTerminateListener
+void SAL_CALL OConnectionController::queryTermination( const EventObject& /*aEvent*/ )
+throw( TerminationVetoException, RuntimeException )
+{
+}
+
+void SAL_CALL OConnectionController::notifyTermination( const EventObject& /*aEvent*/ )
+throw( RuntimeException )
+{
+ m_pDriver->shutdownConnections();
+}
+
+//........................................................................
+} // namespace connectivity
+//........................................................................
diff --git a/connectivity/source/drivers/hsqldb/HTerminateListener.hxx b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
new file mode 100644
index 000000000000..9bec7c02d57f
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTerminateListener.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_HSQLDB_TERMINATELISTENER_HXX
+#define CONNECTIVITY_HSQLDB_TERMINATELISTENER_HXX
+
+#include <cppuhelper/compbase1.hxx>
+#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#endif
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+
+ namespace hsqldb
+ {
+ class ODriverDelegator;
+ class OConnectionController : public ::cppu::WeakImplHelper1<
+ ::com::sun::star::frame::XTerminateListener >
+ {
+ ODriverDelegator* m_pDriver;
+ protected:
+ virtual ~OConnectionController() {m_pDriver = NULL;}
+ public:
+ OConnectionController(ODriverDelegator* _pDriver) : m_pDriver(_pDriver){}
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source )
+ throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent )
+ throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent )
+ throw( ::com::sun::star::uno::RuntimeException );
+ };
+ }
+//........................................................................
+} // namespace connectivity
+//........................................................................
+#endif // CONNECTIVITY_HSQLDB_TERMINATELISTENER_HXX
diff --git a/connectivity/source/drivers/hsqldb/HTools.cxx b/connectivity/source/drivers/hsqldb/HTools.cxx
new file mode 100644
index 000000000000..c5e31e5ef1a4
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HTools.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "hsqldb/HTools.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace connectivity { namespace hsqldb
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= HTools
+ //====================================================================
+ //--------------------------------------------------------------------
+ void HTools::appendTableFilterCrit( ::rtl::OUStringBuffer& _inout_rBuffer, const ::rtl::OUString& _rCatalog,
+ const ::rtl::OUString _rSchema, const ::rtl::OUString _rName, bool _bShortForm )
+ {
+ _inout_rBuffer.appendAscii( " WHERE " );
+ if ( _rCatalog.getLength() )
+ {
+ _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_CAT" : "TABLE_CATALOG" );
+ _inout_rBuffer.appendAscii( " = '" );
+ _inout_rBuffer.append ( _rCatalog );
+ _inout_rBuffer.appendAscii( "' AND " );
+ }
+ if ( _rSchema.getLength() )
+ {
+ _inout_rBuffer.appendAscii( _bShortForm ? "TABLE_SCHEM" : "TABLE_SCHEMA" );
+ _inout_rBuffer.appendAscii( " = '" );
+ _inout_rBuffer.append ( _rSchema );
+ _inout_rBuffer.appendAscii( "' AND " );
+ }
+ _inout_rBuffer.appendAscii( "TABLE_NAME = '" );
+ _inout_rBuffer.append ( _rName );
+ _inout_rBuffer.appendAscii( "'" );
+ }
+
+//........................................................................
+} } // namespace connectivity::hsqldb
+//........................................................................
diff --git a/connectivity/source/drivers/hsqldb/HUser.cxx b/connectivity/source/drivers/hsqldb/HUser.cxx
new file mode 100644
index 000000000000..90f914e77307
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUser.cxx
@@ -0,0 +1,351 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HUser.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "TConnection.hxx"
+#include "resource/hsqldb_res.hrc"
+
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OHSQLUser::OHSQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : connectivity::sdbcx::OUser(sal_True)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OHSQLUser::OHSQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OUser(_Name,sal_True)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OHSQLUser::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : OHSQLUser(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+void OUserExtend::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OHSQLUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRights;
+}
+// -----------------------------------------------------------------------------
+void OHSQLUser::findPrivilegesAndGrantPrivileges(const ::rtl::OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ Reference<XResultSet> xRes;
+ switch(objType)
+ {
+ case PrivilegeObject::TABLE:
+ case PrivilegeObject::VIEW:
+ {
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
+ }
+ break;
+
+ case PrivilegeObject::COLUMN:
+ {
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
+ }
+ break;
+ }
+
+ if ( xRes.is() )
+ {
+ static const ::rtl::OUString sSELECT = ::rtl::OUString::createFromAscii("SELECT");
+ static const ::rtl::OUString sINSERT = ::rtl::OUString::createFromAscii("INSERT");
+ static const ::rtl::OUString sUPDATE = ::rtl::OUString::createFromAscii("UPDATE");
+ static const ::rtl::OUString sDELETE = ::rtl::OUString::createFromAscii("DELETE");
+ static const ::rtl::OUString sREAD = ::rtl::OUString::createFromAscii("READ");
+ static const ::rtl::OUString sCREATE = ::rtl::OUString::createFromAscii("CREATE");
+ static const ::rtl::OUString sALTER = ::rtl::OUString::createFromAscii("ALTER");
+ static const ::rtl::OUString sREFERENCE = ::rtl::OUString::createFromAscii("REFERENCE");
+ static const ::rtl::OUString sDROP = ::rtl::OUString::createFromAscii("DROP");
+ static const ::rtl::OUString sYes = ::rtl::OUString::createFromAscii("YES");
+
+ nRightsWithGrant = nRights = 0;
+
+ Reference<XRow> xCurrentRow(xRes,UNO_QUERY);
+ while( xCurrentRow.is() && xRes->next() )
+ {
+ ::rtl::OUString sGrantee = xCurrentRow->getString(5);
+ ::rtl::OUString sPrivilege = xCurrentRow->getString(6);
+ ::rtl::OUString sGrantable = xCurrentRow->getString(7);
+
+ if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
+ continue;
+
+ if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
+ {
+ nRights |= Privilege::SELECT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::SELECT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
+ {
+ nRights |= Privilege::INSERT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::INSERT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
+ {
+ nRights |= Privilege::UPDATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::UPDATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
+ {
+ nRights |= Privilege::DELETE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DELETE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
+ {
+ nRights |= Privilege::READ;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::READ;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
+ {
+ nRights |= Privilege::CREATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::CREATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
+ {
+ nRights |= Privilege::ALTER;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::ALTER;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
+ {
+ nRights |= Privilege::REFERENCE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::REFERENCE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
+ {
+ nRights |= Privilege::DROP;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DROP;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OHSQLUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OHSQLUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("GRANT ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" TO ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OHSQLUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" FROM ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+// XUser
+void SAL_CALL OHSQLUser::changePassword( const ::rtl::OUString& /*oldPassword*/, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sAlterPwd;
+ sAlterPwd = ::rtl::OUString::createFromAscii("SET PASSWORD FOR ");
+ sAlterPwd += m_Name;
+ sAlterPwd += ::rtl::OUString::createFromAscii("@\"%\" = PASSWORD('") ;
+ sAlterPwd += newPassword;
+ sAlterPwd += ::rtl::OUString::createFromAscii("')") ;
+
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OHSQLUser::getPrivilegeString(sal_Int32 nRights) const
+{
+ ::rtl::OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += ::rtl::OUString::createFromAscii("INSERT");
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("DELETE");
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("ALTER");
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("SELECT");
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
+ }
+
+ return sPrivs;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/hsqldb/HUsers.cxx b/connectivity/source/drivers/hsqldb/HUsers.cxx
new file mode 100644
index 000000000000..151528457ac0
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HUsers.cxx
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "hsqldb/HUsers.hxx"
+#include "hsqldb/HUser.hxx"
+#include "hsqldb/HTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+OUsers::OUsers( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ connectivity::sdbcx::IRefreshableUsers* _pParent)
+ : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_xConnection(_xConnection)
+ ,m_pParent(_pParent)
+{
+}
+// -----------------------------------------------------------------------------
+
+sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
+{
+ return new OHSQLUser(m_xConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OUsers::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshUsers();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ OUserExtend* pNew = new OUserExtend(m_xConnection);
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("GRANT USAGE ON * TO ");
+ ::rtl::OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString sUserName( _rForName );
+ aSql += ::dbtools::quoteName(aQuote,sUserName)
+ + ::rtl::OUString::createFromAscii(" @\"%\" ");
+ ::rtl::OUString sPassword;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPassword;
+ if ( sPassword.getLength() )
+ {
+ aSql += ::rtl::OUString::createFromAscii(" IDENTIFIED BY '");
+ aSql += sPassword;
+ aSql += ::rtl::OUString::createFromAscii("'");
+ }
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OUsers::dropObject(sal_Int32 /*nPos*/,const ::rtl::OUString _sElementName)
+{
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("REVOKE ALL ON * FROM ");
+ ::rtl::OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/HView.cxx b/connectivity/source/drivers/hsqldb/HView.cxx
new file mode 100644
index 000000000000..229e9c9218d9
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HView.cxx
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "hsqldb/HView.hxx"
+#include "hsqldb/HTools.hxx"
+
+#include "propertyids.hxx"
+
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/lang/WrappedTargetException.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+/** === end UNO includes === **/
+
+#include <cppuhelper/exc_hlp.hxx>
+#include <tools/diagnose_ex.h>
+#include <unotools/sharedunocomponent.hxx>
+
+//........................................................................
+namespace connectivity { namespace hsqldb
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::UNO_QUERY;
+ using ::com::sun::star::uno::UNO_QUERY_THROW;
+ using ::com::sun::star::uno::Exception;
+ using ::com::sun::star::uno::RuntimeException;
+ using ::com::sun::star::uno::Any;
+ using ::com::sun::star::uno::makeAny;
+ using ::com::sun::star::sdbc::XDatabaseMetaData;
+ using ::com::sun::star::sdbc::SQLException;
+ using ::com::sun::star::sdbc::XConnection;
+ using ::com::sun::star::lang::WrappedTargetException;
+ using ::com::sun::star::sdbc::XResultSet;
+ using ::com::sun::star::sdbc::XStatement;
+ using ::com::sun::star::lang::DisposedException;
+ using ::com::sun::star::sdbc::XRow;
+ /** === end UNO using === **/
+
+ //====================================================================
+ //= HView
+ //====================================================================
+ //--------------------------------------------------------------------
+ HView::HView( const Reference< XConnection >& _rxConnection, sal_Bool _bCaseSensitive,
+ const ::rtl::OUString& _rSchemaName, const ::rtl::OUString& _rName )
+ :HView_Base( _bCaseSensitive, _rName, _rxConnection->getMetaData(), 0, ::rtl::OUString(), _rSchemaName, ::rtl::OUString() )
+ ,m_xConnection( _rxConnection )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ HView::~HView()
+ {
+ }
+
+ //--------------------------------------------------------------------
+ IMPLEMENT_FORWARD_XINTERFACE2( HView, HView_Base, HView_IBASE )
+ IMPLEMENT_FORWARD_XTYPEPROVIDER2( HView, HView_Base, HView_IBASE )
+
+ //--------------------------------------------------------------------
+ void SAL_CALL HView::alterCommand( const ::rtl::OUString& _rNewCommand ) throw (SQLException, RuntimeException)
+ {
+ // not really atomic ... as long as we do not have something like
+ // ALTER VIEW <name> TO <command>
+ // in HSQL, we need to do it this way ...
+ //
+ // I can imagine scenarios where this fails, e.g. when dropping the view
+ // succeedes, re-creating it fails, some other thread alters a table which
+ // the view was based on, and then we try to restore the view with the
+ // original command, which then fails, too.
+ //
+ // However, there's not much chance to prevent this kind of errors without
+ // backend support.
+
+ ::rtl::OUString sQualifiedName( ::dbtools::composeTableName(
+ m_xMetaData, m_CatalogName, m_SchemaName, m_Name, true, ::dbtools::eInDataManipulation ) );
+
+ ::utl::SharedUNOComponent< XStatement > xStatement; xStatement.set( m_xConnection->createStatement(), UNO_QUERY_THROW );
+
+ // create a statement which can be used to re-create the original view, in case
+ // dropping it succeeds, but creating it with a new statement fails
+ ::rtl::OUStringBuffer aRestoreCommand;
+ aRestoreCommand.appendAscii( "CREATE VIEW " );
+ aRestoreCommand.append ( sQualifiedName );
+ aRestoreCommand.appendAscii( " AS " );
+ aRestoreCommand.append ( impl_getCommand_throw( true ) );
+ ::rtl::OUString sRestoreCommand( aRestoreCommand.makeStringAndClear() );
+
+ bool bDropSucceeded( false );
+ try
+ {
+ // drop the existing view
+ ::rtl::OUStringBuffer aCommand;
+ aCommand.appendAscii( "DROP VIEW " );
+ aCommand.append ( sQualifiedName );
+ xStatement->execute( aCommand.makeStringAndClear() );
+ bDropSucceeded = true;
+
+ // create a new one with the same name
+ aCommand.appendAscii( "CREATE VIEW " );
+ aCommand.append ( sQualifiedName );
+ aCommand.appendAscii( " AS " );
+ aCommand.append ( _rNewCommand );
+ xStatement->execute( aCommand.makeStringAndClear() );
+ }
+ catch( const SQLException& )
+ {
+ if ( bDropSucceeded )
+ // drop succeeded, but creation failed -> re-create the view with the original
+ // statemnet
+ xStatement->execute( sRestoreCommand );
+ throw;
+ }
+ catch( const RuntimeException& )
+ {
+ if ( bDropSucceeded )
+ xStatement->execute( sRestoreCommand );
+ throw;
+ }
+ catch( const Exception& )
+ {
+ if ( bDropSucceeded )
+ xStatement->execute( sRestoreCommand );
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void SAL_CALL HView::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
+ {
+ if ( _nHandle == PROPERTY_ID_COMMAND )
+ {
+ // retrieve the very current command, don't rely on the base classes cached value
+ // (which we initialized empty, anyway)
+ _rValue <<= impl_getCommand_throw( false );
+ return;
+ }
+
+ HView_Base::getFastPropertyValue( _rValue, _nHandle );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString HView::impl_getCommand_throw( bool _bAllowSQLException ) const
+ {
+ ::rtl::OUString sCommand;
+
+ try
+ {
+ ::rtl::OUStringBuffer aCommand;
+ aCommand.appendAscii( "SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.SYSTEM_VIEWS " );
+ HTools::appendTableFilterCrit( aCommand, m_CatalogName, m_SchemaName, m_Name, false );
+ ::utl::SharedUNOComponent< XStatement > xStatement; xStatement.set( m_xConnection->createStatement(), UNO_QUERY_THROW );
+ Reference< XResultSet > xResult( xStatement->executeQuery( aCommand.makeStringAndClear() ), UNO_QUERY_THROW );
+ if ( !xResult->next() )
+ {
+ // hmm. There is no view view the name as we know it. Can only mean some other instance
+ // dropped this view meanwhile ...
+ throw DisposedException();
+ }
+
+ Reference< XRow > xRow( xResult, UNO_QUERY_THROW );
+ sCommand = xRow->getString( 1 );
+ }
+ catch( const RuntimeException& ) { throw; }
+ catch( const SQLException& e )
+ {
+ if ( _bAllowSQLException )
+ throw;
+ throw WrappedTargetException( e.Message, static_cast< XAlterView* >( const_cast< HView* >( this ) ), ::cppu::getCaughtException() );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ return sCommand;
+ }
+
+//........................................................................
+} } // namespace connectivity::hsqldb
+//........................................................................
diff --git a/connectivity/source/drivers/hsqldb/HViews.cxx b/connectivity/source/drivers/hsqldb/HViews.cxx
new file mode 100644
index 000000000000..d604947e016e
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/HViews.cxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "hsqldb/HTables.hxx"
+#include "hsqldb/HViews.hxx"
+#include "hsqldb/HView.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/CheckOption.hpp>
+#include "hsqldb/HCatalog.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace connectivity::hsqldb;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+// -------------------------------------------------------------------------
+HViews::HViews( const Reference< XConnection >& _rxConnection, ::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector )
+ :sdbcx::OCollection( _rParent, sal_True, _rMutex, _rVector )
+ ,m_xConnection( _rxConnection )
+ ,m_xMetaData( _rxConnection->getMetaData() )
+ ,m_bInDrop( sal_False )
+{
+}
+
+// -------------------------------------------------------------------------
+sdbcx::ObjectType HViews::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ return new HView( m_xConnection, isCaseSensitive(), sSchema, sTable );
+}
+
+// -------------------------------------------------------------------------
+void HViews::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OHCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void HViews::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > HViews::createDescriptor()
+{
+ Reference<XConnection> xConnection = static_cast<OHCatalog&>(m_rParent).getConnection();
+ connectivity::sdbcx::OView* pNew = new connectivity::sdbcx::OView(sal_True,xConnection->getMetaData());
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType HViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createView(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void HViews::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
+{
+ if ( m_bInDrop )
+ return;
+
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP VIEW");
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::eInTableDefinitions, false, false, true );
+
+ Reference<XConnection> xConnection = static_cast<OHCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void HViews::dropByNameImpl(const ::rtl::OUString& elementName)
+{
+ m_bInDrop = sal_True;
+ OCollection_TYPE::dropByName(elementName);
+ m_bInDrop = sal_False;
+}
+// -----------------------------------------------------------------------------
+void HViews::createView( const Reference< XPropertySet >& descriptor )
+{
+ Reference<XConnection> xConnection = static_cast<OHCatalog&>(m_rParent).getConnection();
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE VIEW ");
+ ::rtl::OUString aQuote = xConnection->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString sSchema,sCommand;
+
+ aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInTableDefinitions, false, false, true );
+
+ aSql += ::rtl::OUString::createFromAscii(" AS ");
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
+ aSql += sCommand;
+
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+
+ // insert the new view also in the tables collection
+ OTables* pTables = static_cast<OTables*>(static_cast<OHCatalog&>(m_rParent).getPrivateTables());
+ if ( pTables )
+ {
+ ::rtl::OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInDataManipulation, false, false, false );
+ pTables->appendNew(sName);
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/Hservices.cxx b/connectivity/source/drivers/hsqldb/Hservices.cxx
new file mode 100644
index 000000000000..a3e783a3e9a7
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/Hservices.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "hsqldb/HDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::hsqldb;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriverDelegator::getImplementationName_Static(),
+ ODriverDelegator::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriverDelegator::getImplementationName_Static(),
+ ODriverDelegator::getSupportedServiceNames_Static(),
+ ODriverDelegator_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
new file mode 100644
index 000000000000..a95ee058d4b2
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/StorageFileAccess.cxx
@@ -0,0 +1,180 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include "hsqldb/StorageFileAccess.h"
+#include "hsqldb/HStorageMap.hxx"
+
+#include <rtl/logfile.hxx>
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+/*****************************************************************************/
+/* exception macros */
+
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: isStreamElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)Z
+ */
+SAL_DLLPUBLIC_EXPORT jboolean JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ if ( aStoragePair.first.first.is() )
+ {
+ try
+ {
+ ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
+ try
+ {
+ ::rtl::OUString sOldName = StorageContainer::removeOldURLPrefix(sName);
+ if ( aStoragePair.first.first->isStreamElement(sOldName) )
+ {
+ try
+ {
+ aStoragePair.first.first->renameElement(sOldName,StorageContainer::removeURLPrefix(sName,aStoragePair.first.second));
+ }
+ catch(Exception&)
+ {
+ }
+ }
+ }
+ catch(NoSuchElementException&)
+ {
+ }
+ return aStoragePair.first.first->isStreamElement(StorageContainer::removeURLPrefix(sName,aStoragePair.first.second));
+ }
+ catch(NoSuchElementException&)
+ {
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement");
+ if (JNI_FALSE != env->ExceptionCheck())
+ env->ExceptionClear();
+ ::rtl::OString cstr( ::rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_JAVA_UTF8 ) );
+ OSL_TRACE( __FILE__": forwarding Exception: %s", cstr.getStr() );
+ }
+ }
+ return JNI_FALSE;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: removeElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ {
+ ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
+ ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
+ }
+#endif
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ if ( aStoragePair.first.first.is() )
+ {
+ try
+ {
+ aStoragePair.first.first->removeElement(StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,name),aStoragePair.first.second));
+ }
+ catch(NoSuchElementException&)
+ {
+ if (JNI_FALSE != env->ExceptionCheck())
+ env->ExceptionClear();
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess
+ * Method: renameElement
+ * Signature: (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring oldname, jstring newname)
+{
+#ifdef HSQLDB_DBG
+ {
+ ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
+ ::rtl::OUString sNewName = StorageContainer::jstring2ustring(env,newname);
+ ::rtl::OUString sOldName = StorageContainer::jstring2ustring(env,oldname);
+ }
+#endif
+ TStorages::mapped_type aStoragePair = StorageContainer::getRegisteredStorage(StorageContainer::jstring2ustring(env,key));
+ if ( aStoragePair.first.first.is() )
+ {
+ try
+ {
+ aStoragePair.first.first->renameElement(
+ StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,oldname),aStoragePair.first.second),
+ StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second)
+ );
+#ifdef HSQLDB_DBG
+ {
+ ::rtl::OUString sNewName = StorageContainer::removeURLPrefix(StorageContainer::jstring2ustring(env,newname),aStoragePair.first.second);
+ OSL_ENSURE(aStoragePair.first.first->isStreamElement(sNewName),"Stream could not be renamed");
+ }
+#endif
+ }
+ catch(NoSuchElementException&)
+ {
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
new file mode 100644
index 000000000000..99ac75290d94
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/StorageNativeInputStream.cxx
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/types.hxx>
+#include "hsqldb/HStorageAccess.hxx"
+#include "hsqldb/HStorageMap.hxx"
+#include "hsqldb/StorageNativeInputStream.h"
+
+#include "jvmaccess/virtualmachine.hxx"
+#include <com/sun/star/lang/XSingleComponentFactory.hpp>
+#include "accesslog.hxx"
+
+#include <limits>
+
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+/*****************************************************************************/
+/* exception macros */
+
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jint mode)
+{
+#ifdef HSQLDB_DBG
+ {
+ OperationLogFile( env, name, "input" ).logOperation( "openStream" );
+ LogFile( env, name, "input" ).create();
+ }
+#endif
+ StorageContainer::registerStream(env,name,key,mode);
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2
+ (JNIEnv * env, jobject obj_this,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "read()" );
+
+ DataLogFile aDataLog( env, name, "input" );
+ return read_from_storage_stream( env, obj_this, name, key, &aDataLog );
+#else
+ return read_from_storage_stream( env, obj_this, name, key );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+ (JNIEnv * env, jobject obj_this,jstring key, jstring name, jbyteArray buffer, jint off, jint len)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "read( byte[], int, int )" );
+
+ DataLogFile aDataLog( env, name, "input" );
+ return read_from_storage_stream_into_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
+#else
+ return read_from_storage_stream_into_buffer(env,obj_this,name,key,buffer,off,len);
+#endif
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "close" );
+ aOpLog.close();
+
+ LogFile aDataLog( env, name, "input" );
+ aDataLog.close();
+#endif
+ StorageContainer::revokeStream(env,name,key);
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: skip
+ * Signature: (Ljava/lang/String;Ljava/lang/String;J)J
+ */
+SAL_DLLPUBLIC_EXPORT jlong JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jlong n)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "input" ).logOperation( "skip()" );
+#endif
+
+ if ( n < 0 )
+ ThrowException( env,
+ "java/io/IOException",
+ "n < 0");
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+ if ( pHelper.get() )
+ {
+ Reference<XInputStream> xIn = pHelper->getInputStream();
+ if ( xIn.is() )
+ {
+ try
+ {
+ sal_Int64 tmpLongVal = n;
+ sal_Int32 tmpIntVal;
+
+ try
+ {
+ do {
+ if (tmpLongVal >= ::std::numeric_limits<sal_Int64>::max() )
+ tmpIntVal = ::std::numeric_limits<sal_Int32>::max();
+ else // Casting is safe here.
+ tmpIntVal = static_cast<sal_Int32>(tmpLongVal);
+
+ tmpLongVal -= tmpIntVal;
+
+ xIn->skipBytes(tmpIntVal);
+
+ } while (tmpLongVal > 0);
+ }
+ catch(Exception& )
+ {
+ }
+
+ return n - tmpLongVal;
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : skip();");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "Stream is not valid");
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: available
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "available" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ OSL_ENSURE(pHelper.get(),"No stream helper!");
+ Reference<XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference<XInputStream>();
+ if ( xIn.is() )
+ {
+ try
+ {
+ jint nAvailable = xIn->available();
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nAvailable );
+#endif
+ return nAvailable;
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception caught! : available();");
+ StorageContainer::throwJavaException(e,env);
+ }
+ }
+ else
+ {
+ ThrowException( env,
+ "java/io/IOException",
+ "Stream is not valid");
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream
+ * Method: read
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[B)I
+ */
+SAL_DLLPUBLIC_EXPORT jint JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
+ (JNIEnv * env, jobject /*obj_this*/,jstring key, jstring name, jbyteArray buffer)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "input" );
+ aOpLog.logOperation( "read( byte[] )" );
+
+ DataLogFile aDataLog( env, name, "input" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XInputStream> xIn = pHelper.get() ? pHelper->getInputStream() : Reference< XInputStream>();
+ OSL_ENSURE(xIn.is(),"Input stream is NULL!");
+ jint nBytesRead = 0;
+ if ( xIn.is() )
+ {
+ jsize nLen = env->GetArrayLength(buffer);
+ Sequence< ::sal_Int8 > aData(nLen);
+
+ try
+ {
+ nBytesRead = xIn->readBytes(aData,nLen);
+ }
+ catch(Exception& e)
+ {
+ OSL_ENSURE(0,"Exception catched! : skip();");
+ StorageContainer::throwJavaException(e,env);
+ }
+
+ // Casting bytesRead to an int is okay, since the user can
+ // only pass in an integer length to read, so the bytesRead
+ // must <= len.
+ //
+ if (nBytesRead <= 0) {
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( (jint)-1 );
+#endif
+ return -1;
+ }
+ OSL_ENSURE(nLen >= nBytesRead,"Buffer is too small!");
+ OSL_ENSURE(aData.getLength() >= nBytesRead,"Buffer is too small!");
+ env->SetByteArrayRegion(buffer,0,nBytesRead,&aData[0]);
+#ifdef HSQLDB_DBG
+ aDataLog.write( &aData[0], nBytesRead );
+#endif
+ }
+#ifdef HSQLDB_DBG
+ aOpLog.logReturn( nBytesRead );
+#endif
+ return nBytesRead;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx
new file mode 100644
index 000000000000..ec7428d14fef
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/StorageNativeOutputStream.cxx
@@ -0,0 +1,219 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#if defined(HAVE_CONFIG_H) && HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "uno/mapping.hxx"
+#include "uno/environment.hxx"
+#include "cppuhelper/bootstrap.hxx"
+#include "cppuhelper/compbase1.hxx"
+#include "cppuhelper/component_context.hxx"
+#include "accesslog.hxx"
+#include <com/sun/star/embed/XTransactedObject.hpp>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/io/XStream.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <com/sun/star/document/XDocumentSubStorageSupplier.hpp>
+#include <com/sun/star/embed/XStorage.hpp>
+#include <com/sun/star/embed/ElementModes.hpp>
+#include <comphelper/stl_types.hxx>
+#include <comphelper/types.hxx>
+#include "hsqldb/HStorageAccess.hxx"
+#include "hsqldb/HStorageMap.hxx"
+
+#include "jvmaccess/virtualmachine.hxx"
+#include "com/sun/star/lang/XSingleComponentFactory.hpp"
+#include "diagnose_ex.h"
+
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::document;
+using namespace ::com::sun::star::embed;
+using namespace ::com::sun::star::io;
+using namespace ::com::sun::star::lang;
+using namespace ::connectivity::hsqldb;
+
+#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
+/*****************************************************************************/
+/* exception macros */
+
+#define ThrowException(env, type, msg) { \
+ env->ThrowNew(env->FindClass(type), msg); }
+
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: openStream
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
+ (JNIEnv * env, jobject /*obj_this*/, jstring name, jstring key, jint mode)
+{
+#ifdef HSQLDB_DBG
+ {
+ OperationLogFile( env, name, "output" ).logOperation( "openStream" );
+ LogFile( env, name, "output" ).create();
+ }
+#endif
+ StorageContainer::registerStream(env,name,key,mode);
+}
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: write
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[BII)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
+ (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer, jint off, jint len)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "output" ).logOperation( "write( byte[], int, int )" );
+
+ DataLogFile aDataLog( env, name, "output" );
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len, &aDataLog );
+#else
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, off, len );
+#endif
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: write
+ * Signature: (Ljava/lang/String;Ljava/lang/String;[B)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
+ (JNIEnv * env, jobject obj_this, jstring key, jstring name, jbyteArray buffer)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "output" ).logOperation( "write( byte[] )" );
+
+ DataLogFile aDataLog( env, name, "output" );
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ), &aDataLog );
+#else
+ write_to_storage_stream_from_buffer( env, obj_this, name, key, buffer, 0, env->GetArrayLength( buffer ) );
+#endif
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: close
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
+ (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile aOpLog( env, name, "output" );
+ aOpLog.logOperation( "close" );
+
+ LogFile aDataLog( env, name, "output" );
+#endif
+
+ ::boost::shared_ptr<StreamHelper> pHelper = StorageContainer::getRegisteredStream(env,name,key);
+ Reference< XOutputStream> xFlush = pHelper.get() ? pHelper->getOutputStream() : Reference< XOutputStream>();
+ if ( xFlush.is() )
+ try
+ {
+ xFlush->flush();
+ }
+ catch(Exception&)
+ {}
+
+#ifdef HSQLDB_DBG
+ aDataLog.close();
+ aOpLog.close();
+#endif
+ StorageContainer::revokeStream(env,name,key);
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: write
+ * Signature: (Ljava/lang/String;Ljava/lang/String;I)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
+ (JNIEnv * env, jobject obj_this, jstring key, jstring name,jint b)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "output" ).logOperation( "write( int )" );
+
+ DataLogFile aDataLog( env, name, "output" );
+ write_to_storage_stream( env, obj_this, name, key, b, &aDataLog );
+#else
+ write_to_storage_stream( env, obj_this, name, key, b );
+#endif
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: flush
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
+ (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
+{
+ OSL_UNUSED( env );
+ OSL_UNUSED( key );
+ OSL_UNUSED( name );
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "output" ).logOperation( "flush" );
+
+ ::rtl::OUString sKey = StorageContainer::jstring2ustring(env,key);
+ ::rtl::OUString sName = StorageContainer::jstring2ustring(env,name);
+#endif
+}
+// -----------------------------------------------------------------------------
+/*
+ * Class: com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream
+ * Method: sync
+ * Signature: (Ljava/lang/String;Ljava/lang/String;)V
+ */
+extern "C" SAL_DLLPUBLIC_EXPORT void JNICALL Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
+ (JNIEnv * env, jobject /*obj_this*/, jstring key, jstring name)
+{
+#ifdef HSQLDB_DBG
+ OperationLogFile( env, name, "output" ).logOperation( "sync" );
+#endif
+ ::boost::shared_ptr< StreamHelper > pStream = StorageContainer::getRegisteredStream( env, name, key );
+ Reference< XOutputStream > xFlush = pStream.get() ? pStream->getOutputStream() : Reference< XOutputStream>();
+ OSL_ENSURE( xFlush.is(), "StorageNativeOutputStream::sync: could not retrieve an output stream!" );
+ if ( xFlush.is() )
+ {
+ try
+ {
+ xFlush->flush();
+ }
+ catch(Exception&)
+ {
+ OSL_ENSURE( false, "StorageNativeOutputStream::sync: could not flush output stream!" );
+ }
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/hsqldb/accesslog.cxx b/connectivity/source/drivers/hsqldb/accesslog.cxx
new file mode 100644
index 000000000000..8ac77d5be4c2
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/accesslog.cxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifdef HSQLDB_DBG
+#include "accesslog.hxx"
+#include "hsqldb/HStorageMap.hxx"
+
+#include <osl/thread.h>
+
+namespace connectivity { namespace hsqldb
+{
+ DECLARE_STL_USTRINGACCESS_MAP(FILE *,TDebugStreamMap);
+ TDebugStreamMap& getStreams()
+ {
+ static TDebugStreamMap streams;
+ return streams;
+ }
+
+ //---------------------------------------------------------------------
+ LogFile::LogFile( JNIEnv* env, jstring streamName, const sal_Char* _pAsciiSuffix )
+ {
+ m_sFileName = StorageContainer::jstring2ustring(env,streamName);
+ m_sFileName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+ m_sFileName += ::rtl::OUString::createFromAscii( _pAsciiSuffix );
+ }
+
+ //---------------------------------------------------------------------
+ FILE*& LogFile::getLogFile()
+ {
+ FILE*& pLogFile = getStreams()[m_sFileName];
+ if ( !pLogFile )
+ {
+ ::rtl::OString sByteLogName = ::rtl::OUStringToOString(m_sFileName,osl_getThreadTextEncoding());
+ pLogFile = fopen( sByteLogName.getStr(), "a+" );
+ }
+ return pLogFile;
+ }
+
+ //---------------------------------------------------------------------
+ void LogFile::writeString( const sal_Char* _pString, bool _bEndLine )
+ {
+ FILE* pLogFile = getLogFile();
+ fwrite( _pString, sizeof( *_pString ), strlen( _pString ), pLogFile );
+ if ( _bEndLine )
+ fwrite( "\n", sizeof( *_pString ), strlen( "\n" ), pLogFile );
+ fflush( pLogFile );
+ }
+
+ //---------------------------------------------------------------------
+ void LogFile::close()
+ {
+ fclose( getLogFile() );
+ getLogFile() = NULL;
+ }
+} }
+#endif
diff --git a/connectivity/source/drivers/hsqldb/accesslog.hxx b/connectivity/source/drivers/hsqldb/accesslog.hxx
new file mode 100644
index 000000000000..524394a8b885
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/accesslog.hxx
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLDB_ACCESSLOG_HXX
+#define CONNECTIVITY_HSQLDB_ACCESSLOG_HXX
+
+#ifdef HSQLDB_DBG
+
+#include <stdio.h>
+#include <jni.h>
+#include <rtl/ustring.hxx>
+#include <rtl/string.hxx>
+
+namespace connectivity { namespace hsqldb
+{
+ class LogFile
+ {
+ private:
+ ::rtl::OUString m_sFileName;
+
+ public:
+ LogFile( JNIEnv* env, jstring streamName, const sal_Char* _pAsciiSuffix );
+
+ public:
+ void writeString( const sal_Char* _pString, bool _bEndLine = true );
+ void create() { getLogFile(); }
+ virtual void close();
+
+ protected:
+ FILE*& getLogFile();
+ };
+
+ class OperationLogFile : public LogFile
+ {
+ public:
+ OperationLogFile( JNIEnv* env, jstring streamName, const sal_Char* _pAsciiSuffix )
+ :LogFile( env, streamName, ( ::rtl::OString( _pAsciiSuffix ) += ".op" ).getStr() )
+ {
+ }
+
+ void logOperation( const sal_Char* _pOp )
+ {
+ writeString( _pOp, true );
+ }
+
+ void logOperation( const sal_Char* _pOp, jlong _nLongArg )
+ {
+ ::rtl::OString sLine( _pOp );
+ sLine += "( ";
+ sLine += ::rtl::OString::valueOf( _nLongArg );
+ sLine += " )";
+ writeString( sLine.getStr(), true );
+ }
+
+ void logReturn( jlong _nRetVal )
+ {
+ ::rtl::OString sLine( " -> " );
+ sLine += ::rtl::OString::valueOf( _nRetVal );
+ writeString( sLine.getStr(), true );
+ }
+
+ void logReturn( jint _nRetVal )
+ {
+ ::rtl::OString sLine( " -> " );
+ sLine += ::rtl::OString::valueOf( _nRetVal );
+ writeString( sLine.getStr(), true );
+ }
+
+ virtual void close()
+ {
+ writeString( "-------------------------------", true );
+ writeString( "", true );
+ LogFile::close();
+ }
+ };
+
+ class DataLogFile : public LogFile
+ {
+ public:
+ DataLogFile( JNIEnv* env, jstring streamName, const sal_Char* _pAsciiSuffix )
+ :LogFile( env, streamName, _pAsciiSuffix )
+ {
+ }
+
+ void write( jint value )
+ {
+ fputc( value, getLogFile() );
+ fflush( getLogFile() );
+ }
+
+ void write( const sal_Int8* buffer, sal_Int32 bytesRead )
+ {
+ fwrite( buffer, sizeof(sal_Int8), bytesRead, getLogFile() );
+ fflush( getLogFile() );
+ }
+
+ sal_Int64 seek( sal_Int64 pos )
+ {
+ FILE* pFile = getLogFile();
+ fseek( pFile, 0, SEEK_END );
+ if ( ftell( pFile ) < pos )
+ {
+ sal_Int8 filler( 0 );
+ while ( ftell( pFile ) < pos )
+ fwrite( &filler, sizeof( sal_Int8 ), 1, pFile );
+ fflush( pFile );
+ }
+ fseek( pFile, pos, SEEK_SET );
+ return ftell( pFile );
+ }
+
+ sal_Int64 tell()
+ {
+ return ftell( getLogFile() );
+ }
+ };
+
+} }
+#endif
+
+#endif // CONNECTIVITY_HSQLDB_ACCESSLOG_HXX
diff --git a/connectivity/source/drivers/hsqldb/exports.dxp b/connectivity/source/drivers/hsqldb/exports.dxp
new file mode 100644
index 000000000000..7ff56f4f9977
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/exports.dxp
@@ -0,0 +1,30 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write
+Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement
+Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement
diff --git a/connectivity/source/drivers/hsqldb/hsqldb.map b/connectivity/source/drivers/hsqldb/hsqldb.map
new file mode 100644
index 000000000000..b4fc53b320ef
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/hsqldb.map
@@ -0,0 +1,35 @@
+UDK_3_0_0 {
+ global:
+ component_getImplementationEnvironment;
+ component_writeInfo;
+ component_getFactory;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_openStream;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3BII;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2_3B;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_close;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_write__Ljava_lang_String_2Ljava_lang_String_2I;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_flush;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeOutputStream_sync;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_openStream;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_close;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_getFilePointer;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_length;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_read__Ljava_lang_String_2Ljava_lang_String_2_3BII;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_readInt;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_seek;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_write;
+ Java_com_sun_star_sdbcx_comp_hsqldb_NativeStorageAccess_writeInt;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_openStream;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3BII;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_close;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_skip;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_available;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageNativeInputStream_read__Ljava_lang_String_2Ljava_lang_String_2_3B;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_isStreamElement;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_removeElement;
+ Java_com_sun_star_sdbcx_comp_hsqldb_StorageFileAccess_renameElement;
+ local:
+ *;
+};
diff --git a/connectivity/source/drivers/hsqldb/hsqldb.xcu b/connectivity/source/drivers/hsqldb/hsqldb.xcu
new file mode 100755
index 000000000000..f97b5e357179
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/hsqldb.xcu
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:embedded:hsqldb" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.sdbcx.comp.hsqldb.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">HSQL database engine</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseJava" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AutoIncrementIsPrimaryKey" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/hsqldb/hsqldb.xml b/connectivity/source/drivers/hsqldb/hsqldb.xml
new file mode 100644
index 000000000000..720e9e30dbd4
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/hsqldb.xml
@@ -0,0 +1,28 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>hsqldb</module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.sdbcx.comp.hsqldb.Driver</name>
+ <description>
+ This is the implementation of the HSQLDB driver.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/drivers/hsqldb/hsqlui.hrc b/connectivity/source/drivers/hsqldb/hsqlui.hrc
new file mode 100644
index 000000000000..fe20ec5eaf21
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/hsqlui.hrc
@@ -0,0 +1,36 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLUI_HRC
+#define CONNECTIVITY_HSQLUI_HRC
+
+#define LINKED_TEXT_TABLE_IMAGE_RESOURCE "linked_text_table.png"
+#define LINKED_TEXT_TABLE_IMAGE_RESOURCE_HC "linked_text_table_hc.png"
+
+#endif // CONNECTIVITY_HSQLUI_HRC
+
+
diff --git a/connectivity/source/drivers/hsqldb/hsqlui.src b/connectivity/source/drivers/hsqldb/hsqlui.src
new file mode 100644
index 000000000000..a2886c1a18cf
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/hsqlui.src
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_HSQLUI_HRC
+#include "hsqlui.hrc"
+#endif
+
+/* Note:
+ The resource file built here (hsqldb.res, finally) is *not* included
+ in the final OOo installation. Instead, it is only built to ensure that
+ the two images below are included in the application-wide image repository
+ (images.zip). This way, they can be accessed at runtime, but without the
+ indirection via a resource file - the GraphicProvider service supports
+ a "private:imagerepository/*" protocol meanwhile, which allows this.
+
+ If there were another possibility to ensure that the images are
+ put into the repository, instead of creating a resource file for them,
+ then we would use this other way ...
+*/
+
+Image 1000
+{
+ ImageBitmap = Bitmap { File = LINKED_TEXT_TABLE_IMAGE_RESOURCE; };
+};
+
+Image 1001
+{
+ ImageBitmap = Bitmap { File = LINKED_TEXT_TABLE_IMAGE_RESOURCE_HC; };
+};
diff --git a/connectivity/source/drivers/hsqldb/makefile.mk b/connectivity/source/drivers/hsqldb/makefile.mk
new file mode 100644
index 000000000000..e1a953055c04
--- /dev/null
+++ b/connectivity/source/drivers/hsqldb/makefile.mk
@@ -0,0 +1,117 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=hsqldb
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+USE_DEFFILE=TRUE
+
+# --- Settings ----------------------------------
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(SOLAR_JAVA)"==""
+nojava:
+ @echo "Not building jurt because Java is disabled"
+.ENDIF
+
+.IF "$(SYSTEM_HSQLDB)" == "YES"
+CDEFS+=-DSYSTEM_HSQLDB -DHSQLDB_JAR=\""file://$(HSQLDB_JAR)"\"
+.ENDIF
+# --- Resources ---------------------------------
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ hsqlui.src
+
+RES1FILELIST=\
+ $(SRS)$/$(TARGET).srs
+
+RESLIB1NAME=$(TARGET)
+RESLIB1IMAGES=$(SOLARSRC)$/$(RSCDEFIMG)$/database
+RESLIB1SRSFILES=$(RES1FILELIST)
+
+# Note that the resource file built here is currently *not* included
+# in installation sets. See hsqlui.src for an explanation
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/HStorageMap.obj \
+ $(SLO)$/HStorageAccess.obj \
+ $(SLO)$/HDriver.obj \
+ $(SLO)$/HConnection.obj \
+ $(SLO)$/HTerminateListener.obj \
+ $(SLO)$/StorageNativeOutputStream.obj \
+ $(SLO)$/StorageNativeInputStream.obj \
+ $(SLO)$/StorageFileAccess.obj \
+ $(SLO)$/HTables.obj \
+ $(SLO)$/HTable.obj \
+ $(SLO)$/HView.obj \
+ $(SLO)$/HViews.obj \
+ $(SLO)$/HCatalog.obj \
+ $(SLO)$/HColumns.obj \
+ $(SLO)$/HUser.obj \
+ $(SLO)$/HUsers.obj \
+ $(SLO)$/Hservices.obj \
+ $(SLO)$/HTools.obj \
+ $(SLO)$/accesslog.obj
+
+SHL1VERSIONMAP=$(HSQLDB_TARGET).map
+
+# --- Library -----------------------------------
+# NO $(DLLPOSTFIX) otherwise we have to find on which plattform we are for the java files
+SHL1TARGET= $(HSQLDB_TARGET)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(JVMFWKLIB) \
+ $(COMPHELPERLIB) \
+ $(TOOLSLIB) \
+ $(UNOTOOLSLIB)
+
+
+SHL1DEPN=
+SHL1IMPLIB= i$(HSQLDB_TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/jdbc/Array.cxx b/connectivity/source/drivers/jdbc/Array.cxx
new file mode 100644
index 000000000000..6178f9ba385b
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Array.cxx
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Array.hxx"
+#include "java/tools.hxx"
+#include "java/sql/ResultSet.hxx"
+
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.Array
+//**************************************************************
+
+jclass java_sql_Array::theClass = 0;
+
+java_sql_Array::~java_sql_Array()
+{}
+
+jclass java_sql_Array::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Array");
+
+ return theClass;
+}
+
+::rtl::OUString SAL_CALL java_sql_Array::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("getBaseTypeName",mID);
+}
+
+sal_Int32 SAL_CALL java_sql_Array::getBaseType( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callIntMethod("getBaseType",mID);
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArray( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jobjectArray out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
+ static const char * cSignature = "(Ljava/util/Map;)[Ljava/lang/Object;";
+ static const char * cMethodName = "getArray";
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Java-Call absetzen
+ out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
+ } //t.pEnv
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
+}
+
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL java_sql_Array::getArrayAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jobjectArray out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
+ static const char * cSignature = "(IILjava/util/Map;)[Ljava/lang/Object;";
+ static const char * cMethodName = "getArray";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = (jobjectArray)t.pEnv->CallObjectMethod( object, mID, index,count,obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
+ } //t.pEnv
+ return ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >();//copyArrayAndDelete< ::com::sun::star::uno::Any,jobject>(t.pEnv,out);
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSet( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ // Parameter konvertieren
+ jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getResultSet";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod( object, mID, obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
+ return NULL;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Array::getResultSetAtIndex( sal_Int32 index, sal_Int32 count, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ // Parameter konvertieren
+ jobject obj = convertTypeMapToJavaMap(t.pEnv,typeMap);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/util/Map;)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getResultSetAtIndex";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod( object, mID, index,count,obj);
+ ThrowSQLException(t.pEnv,*this);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(obj);
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ // return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out );
+ return NULL;
+}
+
+
+
diff --git a/connectivity/source/drivers/jdbc/Blob.cxx b/connectivity/source/drivers/jdbc/Blob.cxx
new file mode 100644
index 000000000000..cd448754585f
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Blob.cxx
@@ -0,0 +1,148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Blob.hxx"
+#include "java/tools.hxx"
+#include "java/io/InputStream.hxx"
+#ifndef _INC_MEMORY
+//#include <memory.h>
+#endif
+#include <connectivity/dbexception.hxx>
+
+#include <string.h>
+
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.Blob
+//**************************************************************
+
+jclass java_sql_Blob::theClass = 0;
+java_sql_Blob::java_sql_Blob( JNIEnv * pEnv, jobject myObj )
+ : java_lang_Object( pEnv, myObj )
+{
+ SDBThreadAttach::addRef();
+}
+java_sql_Blob::~java_sql_Blob()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_sql_Blob::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Blob");
+ return theClass;
+}
+
+sal_Int64 SAL_CALL java_sql_Blob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jlong out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "()J";
+ static const char * cMethodName = "length";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID );
+ ThrowSQLException(t.pEnv,*this);
+ } //t.pEnv
+ return (sal_Int64)out;
+}
+::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL java_sql_Blob::getBytes( sal_Int64 pos, sal_Int32 count ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ ::com::sun::star::uno::Sequence< sal_Int8 > aSeq;
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(JI)[B";
+ static const char * cMethodName = "getBytes";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jbyteArray out = (jbyteArray)t.pEnv->CallObjectMethod( object, mID,pos,count);
+ ThrowSQLException(t.pEnv,*this);
+ if(out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return aSeq;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Blob::getBinaryStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getBinaryStream","()Ljava/io/InputStream;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_io_InputStream( t.pEnv, out );
+}
+
+sal_Int64 SAL_CALL java_sql_Blob::position( const ::com::sun::star::uno::Sequence< sal_Int8 >& pattern, sal_Int64 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ jlong out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "([BI)J";
+ static const char * cMethodName = "position";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jbyteArray pByteArray = t.pEnv->NewByteArray(pattern.getLength());
+ t.pEnv->SetByteArrayRegion(pByteArray,0,pattern.getLength(),(jbyte*)pattern.getConstArray());
+ out = t.pEnv->CallLongMethod( object, mID, pByteArray,start );
+ t.pEnv->DeleteLocalRef(pByteArray);
+ ThrowSQLException(t.pEnv,*this);
+ } //t.pEnv
+ return (sal_Int64)out;
+}
+
+sal_Int64 SAL_CALL java_sql_Blob::positionOfBlob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XBlob::positionOfBlob", *this );
+ // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore
+ // the pattern parameter. Since the effort for proper implementation is rather high - we would need
+ // to translated patter into a byte[] -, we defer this functionality for the moment (hey, it was
+ // unusable, anyway)
+ // 2005-11-15 / #i57457# / frank.schoenheit@sun.com
+ return 0;
+}
+
diff --git a/connectivity/source/drivers/jdbc/Boolean.cxx b/connectivity/source/drivers/jdbc/Boolean.cxx
new file mode 100644
index 000000000000..2df75283a14b
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Boolean.cxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/Boolean.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.Boolean
+//**************************************************************
+
+jclass java_lang_Boolean::theClass = 0;
+
+java_lang_Boolean::~java_lang_Boolean()
+{}
+jclass java_lang_Boolean::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/Boolean");
+ return theClass;
+}
+
+jclass java_lang_Boolean::getMyClass() const
+{
+ return st_getMyClass();
+}
+
+java_lang_Boolean::java_lang_Boolean( sal_Bool _par0 ): java_lang_Object( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Z)V";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 );
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ // und aufraeumen
+}
+
+
diff --git a/connectivity/source/drivers/jdbc/CallableStatement.cxx b/connectivity/source/drivers/jdbc/CallableStatement.cxx
new file mode 100644
index 000000000000..a411e0277514
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/CallableStatement.cxx
@@ -0,0 +1,359 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/CallableStatement.hxx"
+#include "java/tools.hxx"
+#include "java/sql/Array.hxx"
+#include "java/sql/Clob.hxx"
+#include "java/sql/Blob.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/sql/Ref.hxx"
+#include "java/sql/Timestamp.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+
+#include <string.h>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+IMPLEMENT_SERVICE_INFO(java_sql_CallableStatement,"com.sun.star.sdbcx.ACallableStatement","com.sun.star.sdbc.CallableStatement");
+
+//**************************************************************
+//************ Class: java.sql.CallableStatement
+//**************************************************************
+java_sql_CallableStatement::java_sql_CallableStatement( JNIEnv * pEnv, java_sql_Connection& _rCon,const ::rtl::OUString& sql )
+ : java_sql_PreparedStatement( pEnv, _rCon, sql )
+{
+}
+// -----------------------------------------------------------------------------
+java_sql_CallableStatement::~java_sql_CallableStatement()
+{
+}
+// -----------------------------------------------------------------------------
+
+Any SAL_CALL java_sql_CallableStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = java_sql_PreparedStatement::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface(rType,static_cast< starsdbc::XRow*>(this),static_cast< starsdbc::XOutParameters*>(this));
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_CallableStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XRow > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< starsdbc::XOutParameters > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_PreparedStatement::getTypes());
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_CallableStatement::wasNull( ) throw(starsdbc::SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "wasNull", mID );
+}
+
+sal_Bool SAL_CALL java_sql_CallableStatement::getBoolean( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex );
+}
+sal_Int8 SAL_CALL java_sql_CallableStatement::getByte( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod;
+ return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex);
+}
+Sequence< sal_Int8 > SAL_CALL java_sql_CallableStatement::getBytes( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ Sequence< sal_Int8 > aSeq;
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex);
+ if (out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
+ return aSeq;
+}
+::com::sun::star::util::Date SAL_CALL java_sql_CallableStatement::getDate( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex);
+ return out ? static_cast <com::sun::star::util::Date>(java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date();
+}
+double SAL_CALL java_sql_CallableStatement::getDouble( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ double (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod;
+ return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex);
+}
+
+float SAL_CALL java_sql_CallableStatement::getFloat( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod;
+ return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex);
+}
+
+sal_Int32 SAL_CALL java_sql_CallableStatement::getInt( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getInt",mID,columnIndex);
+}
+
+sal_Int64 SAL_CALL java_sql_CallableStatement::getLong( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod;
+ return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex);
+}
+
+Any SAL_CALL java_sql_CallableStatement::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ /*jobject out = */callObjectMethodWithIntArg(t.pEnv,"getObject","(I)Ljava/lang/Object;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return Any(); //out==0 ? 0 : new java_lang_Object( t.pEnv, out );
+}
+
+sal_Int16 SAL_CALL java_sql_CallableStatement::getShort( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod;
+ return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex);
+}
+
+::rtl::OUString SAL_CALL java_sql_CallableStatement::getString( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getString",mID,columnIndex);
+}
+
+ ::com::sun::star::util::Time SAL_CALL java_sql_CallableStatement::getTime( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time();
+}
+
+ ::com::sun::star::util::DateTime SAL_CALL java_sql_CallableStatement::getTimestamp( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime();
+}
+
+void SAL_CALL java_sql_CallableStatement::registerOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(starsdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ createStatement(t.pEnv);
+
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(IILjava/lang/String;)V";
+ static const char * cMethodName = "registerOutParameter";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,typeName));
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,str.get());
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+}
+void SAL_CALL java_sql_CallableStatement::registerNumericOutParameter( sal_Int32 parameterIndex, sal_Int32 sqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ createStatement(t.pEnv);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(III)V";
+ static const char * cMethodName = "registerOutParameter";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,sqlType,scale);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+}
+
+jclass java_sql_CallableStatement::theClass = 0;
+
+jclass java_sql_CallableStatement::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/CallableStatement");
+ return theClass;
+}
+
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getBinaryStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ Reference< starsdbc::XBlob > xBlob = getBlob(columnIndex);
+ return xBlob.is() ? xBlob->getBinaryStream() : Reference< ::com::sun::star::io::XInputStream >();
+}
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_CallableStatement::getCharacterStream( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ Reference< starsdbc::XClob > xClob = getClob(columnIndex);
+ return xClob.is() ? xClob->getCharacterStream() : Reference< ::com::sun::star::io::XInputStream >();
+}
+
+Reference< starsdbc::XArray > SAL_CALL java_sql_CallableStatement::getArray( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Array( t.pEnv, out );
+}
+
+Reference< starsdbc::XClob > SAL_CALL java_sql_CallableStatement::getClob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Clob( t.pEnv, out );
+}
+Reference< starsdbc::XBlob > SAL_CALL java_sql_CallableStatement::getBlob( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Blob( t.pEnv, out );
+}
+
+Reference< starsdbc::XRef > SAL_CALL java_sql_CallableStatement::getRef( sal_Int32 columnIndex ) throw(starsdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Ref( t.pEnv, out );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_CallableStatement::acquire() throw()
+{
+ java_sql_PreparedStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_CallableStatement::release() throw()
+{
+ java_sql_PreparedStatement::release();
+}
+// -----------------------------------------------------------------------------
+void java_sql_CallableStatement::createStatement(JNIEnv* /*_pEnv*/)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ if( t.pEnv && !object ){
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/CallableStatement;";
+ static const char * cMethodName = "prepareCall";
+ // Java-Call absetzen
+ jobject out = NULL;
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,m_sSqlStatement));
+
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+ if( mID ){
+ out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, str.get() ,m_nResultSetType,m_nResultSetConcurrency);
+ } //mID
+ else
+ {
+ static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/CallableStatement;";
+ static jmethodID mID2 = t.pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!");
+ if( mID2 ){
+ out = t.pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, str.get() );
+ } //mID
+ }
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+
+ if ( out )
+ object = t.pEnv->NewGlobalRef( out );
+ } //t.pEnv
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/Class.cxx b/connectivity/source/drivers/jdbc/Class.cxx
new file mode 100644
index 000000000000..02bd9ace59f6
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Class.cxx
@@ -0,0 +1,73 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/Class.hxx"
+#include "java/tools.hxx"
+#include <rtl/ustring.hxx>
+
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.Class
+//**************************************************************
+
+jclass java_lang_Class::theClass = 0;
+
+java_lang_Class::~java_lang_Class()
+{}
+
+jclass java_lang_Class::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/Class");
+ return theClass;
+}
+
+java_lang_Class * java_lang_Class::forName( const ::rtl::OUString& _par0 )
+{
+ jobject out(NULL);
+ SDBThreadAttach t;
+
+ {
+ ::rtl::OString sClassName = ::rtl::OUStringToOString(_par0, RTL_TEXTENCODING_JAVA_UTF8);
+ sClassName = sClassName.replace('.','/');
+ out = t.pEnv->FindClass(sClassName);
+ ThrowSQLException(t.pEnv,0);
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? NULL : new java_lang_Class( t.pEnv, out );
+}
+
+jobject java_lang_Class::newInstanceObject()
+{
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ return callObjectMethod(t.pEnv,"newInstance","()Ljava/lang/Object;", mID);
+}
+
diff --git a/connectivity/source/drivers/jdbc/Clob.cxx b/connectivity/source/drivers/jdbc/Clob.cxx
new file mode 100644
index 000000000000..f97bbbe49be6
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Clob.cxx
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Clob.hxx"
+#include "java/tools.hxx"
+#include "java/io/Reader.hxx"
+#include <connectivity/dbexception.hxx>
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.Clob
+//**************************************************************
+
+jclass java_sql_Clob::theClass = 0;
+
+java_sql_Clob::java_sql_Clob( JNIEnv * pEnv, jobject myObj )
+ : java_lang_Object( pEnv, myObj )
+{
+ SDBThreadAttach::addRef();
+}
+java_sql_Clob::~java_sql_Clob()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_sql_Clob::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Clob");
+ return theClass;
+}
+
+sal_Int64 SAL_CALL java_sql_Clob::length( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::length" );
+ jlong out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "()J";
+ static const char * cMethodName = "length";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID );
+ ThrowSQLException(t.pEnv,*this);
+ } //t.pEnv
+ return (sal_Int64)out;
+}
+
+::rtl::OUString SAL_CALL java_sql_Clob::getSubString( sal_Int64 pos, sal_Int32 subStringLength ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getSubString" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ ::rtl::OUString aStr;
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(JI)Ljava/lang/String;";
+ static const char * cMethodName = "getSubString";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jstring out = (jstring)t.pEnv->CallObjectMethod( object, mID,pos,subStringLength);
+ ThrowSQLException(t.pEnv,*this);
+ aStr = JavaString2String(t.pEnv,out);
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return aStr;
+}
+
+::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_Clob::getCharacterStream( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::getCharacterStream" );
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getCharacterStream","()Ljava/io/Reader;", mID);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_io_Reader( t.pEnv, out );
+}
+
+sal_Int64 SAL_CALL java_sql_Clob::position( const ::rtl::OUString& searchstr, sal_Int32 start ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::position" );
+ jlong out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jvalue args[1];
+ // Parameter konvertieren
+ args[0].l = convertwchar_tToJavaString(t.pEnv,searchstr);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;I)J";
+ static const char * cMethodName = "position";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallLongMethod( object, mID, args[0].l,start );
+ ThrowSQLException(t.pEnv,*this);
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ } //t.pEnv
+ return (sal_Int64)out;
+}
+
+sal_Int64 SAL_CALL java_sql_Clob::positionOfClob( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*pattern*/, sal_Int64 /*start*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_Clob::positionOfClob" );
+ ::dbtools::throwFeatureNotImplementedException( "XClob::positionOfClob", *this );
+ // this was put here in CWS warnings01. The previous implementation was defective, as it did ignore
+ // the pattern parameter. Since the effort for proper implementation is rather high - we would need
+ // to translated patter into a byte[] -, we defer this functionality for the moment (hey, it was
+ // unusable, anyway)
+ // 2005-11-15 / #i57457# / frank.schoenheit@sun.com
+ return 0;
+}
+
+
diff --git a/connectivity/source/drivers/jdbc/ConnectionLog.cxx b/connectivity/source/drivers/jdbc/ConnectionLog.cxx
new file mode 100644
index 000000000000..c15c5dc30055
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/ConnectionLog.cxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "java/sql/ConnectionLog.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/util/Date.hpp>
+#include <com/sun/star/util/Time.hpp>
+#include <com/sun/star/util/DateTime.hpp>
+/** === end UNO includes === **/
+
+#include <stdio.h>
+
+//........................................................................
+namespace connectivity { namespace java { namespace sql {
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ /** === end UNO using === **/
+
+ //--------------------------------------------------------------------
+ namespace
+ {
+ sal_Int32 lcl_getFreeID( ConnectionLog::ObjectType _eType )
+ {
+ static oslInterlockedCount s_nCounts[ ConnectionLog::ObjectTypeCount ] = { 0, 0 };
+ return osl_incrementInterlockedCount( s_nCounts + _eType );
+ }
+ }
+
+ //====================================================================
+ //= ConnectionLog
+ //====================================================================
+ //--------------------------------------------------------------------
+ ConnectionLog::ConnectionLog( const ::comphelper::ResourceBasedEventLogger& _rDriverLog )
+ :ConnectionLog_Base( _rDriverLog )
+ ,m_nObjectID( lcl_getFreeID( CONNECTION ) )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog )
+ :ConnectionLog_Base( _rSourceLog )
+ ,m_nObjectID( _rSourceLog.m_nObjectID )
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ConnectionLog::ConnectionLog( const ConnectionLog& _rSourceLog, ConnectionLog::ObjectType _eType )
+ :ConnectionLog_Base( _rSourceLog )
+ ,m_nObjectID( lcl_getFreeID( _eType ) )
+ {
+ }
+
+//........................................................................
+} } } // namespace connectivity::java::sql
+//........................................................................
+
+//........................................................................
+namespace comphelper { namespace log { namespace convert
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XComponentContext;
+ using ::com::sun::star::util::Date;
+ using ::com::sun::star::util::Time;
+ using ::com::sun::star::util::DateTime;
+ /** === end UNO using === **/
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString convertLogArgToString( const Date& _rDate )
+ {
+ char buffer[ 30 ];
+ const size_t buffer_size = sizeof( buffer );
+ snprintf( buffer, buffer_size, "%04i-%02i-%02i",
+ (int)_rDate.Year, (int)_rDate.Month, (int)_rDate.Day );
+ return ::rtl::OUString::createFromAscii( buffer );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString convertLogArgToString( const Time& _rTime )
+ {
+ char buffer[ 30 ];
+ const size_t buffer_size = sizeof( buffer );
+ snprintf( buffer, buffer_size, "%02i:%02i:%02i.%02i",
+ (int)_rTime.Hours, (int)_rTime.Minutes, (int)_rTime.Seconds, (int)_rTime.HundredthSeconds );
+ return ::rtl::OUString::createFromAscii( buffer );
+ }
+
+ //--------------------------------------------------------------------
+ ::rtl::OUString convertLogArgToString( const DateTime& _rDateTime )
+ {
+ char buffer[ 30 ];
+ const size_t buffer_size = sizeof( buffer );
+ snprintf( buffer, buffer_size, "%04i-%02i-%02i %02i:%02i:%02i.%02i",
+ (int)_rDateTime.Year, (int)_rDateTime.Month, (int)_rDateTime.Day,
+ (int)_rDateTime.Hours, (int)_rDateTime.Minutes, (int)_rDateTime.Seconds, (int)_rDateTime.HundredthSeconds );
+ return ::rtl::OUString::createFromAscii( buffer );
+ }
+
+//........................................................................
+} } } // comphelper::log::convert
+//........................................................................
diff --git a/connectivity/source/drivers/jdbc/ContextClassLoader.cxx b/connectivity/source/drivers/jdbc/ContextClassLoader.cxx
new file mode 100644
index 000000000000..e730f94e47c0
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/ContextClassLoader.cxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "java/ContextClassLoader.hxx"
+#include "java/lang/Object.hxx"
+
+/** === begin UNO includes === **/
+/** === end UNO includes === **/
+
+//........................................................................
+namespace connectivity { namespace jdbc
+{
+//........................................................................
+
+ /** === begin UNO using === **/
+ using ::com::sun::star::uno::Reference;
+ using ::com::sun::star::uno::XInterface;
+ /** === end UNO using === **/
+
+ using ::connectivity::java_lang_Object;
+
+ //====================================================================
+ //= ContextClassLoaderScope
+ //====================================================================
+ //--------------------------------------------------------------------
+ ContextClassLoaderScope::ContextClassLoaderScope( JNIEnv& environment, const GlobalRef< jobject >& newClassLoader,
+ const ::comphelper::ResourceBasedEventLogger& _rLoggerForErrors, const Reference< XInterface >& _rxErrorContext )
+ :m_environment( environment )
+ ,m_currentThread( environment )
+ ,m_oldContextClassLoader( environment )
+ {
+ if ( !newClassLoader.is() )
+ return;
+
+ do // artificial loop for easier flow control
+ {
+
+ LocalRef< jclass > threadClass( m_environment );
+ threadClass.set( m_environment.FindClass( "java/lang/Thread" ) );
+ if ( !threadClass.is() )
+ break;
+
+ jmethodID currentThreadMethod( m_environment.GetStaticMethodID(
+ threadClass.get(), "currentThread", "()Ljava/lang/Thread;" ) );
+ if ( currentThreadMethod == NULL )
+ break;
+
+ m_currentThread.set( m_environment.CallStaticObjectMethod( threadClass.get(), currentThreadMethod ) );
+ if ( !m_currentThread.is() )
+ break;
+
+ jmethodID getContextClassLoaderMethod( m_environment.GetMethodID(
+ threadClass.get(), "getContextClassLoader", "()Ljava/lang/ClassLoader;" ) );
+ if ( getContextClassLoaderMethod == NULL )
+ break;
+ m_oldContextClassLoader.set( m_environment.CallObjectMethod( m_currentThread.get(), getContextClassLoaderMethod ) );
+ LocalRef< jthrowable > throwable( m_environment, m_environment.ExceptionOccurred() );
+ if ( throwable.is() )
+ break;
+
+ m_setContextClassLoaderMethod = m_environment.GetMethodID(
+ threadClass.get(), "setContextClassLoader", "(Ljava/lang/ClassLoader;)V" );
+ if ( m_setContextClassLoaderMethod == NULL )
+ break;
+
+ }
+ while ( false );
+
+ if ( !isActive() )
+ {
+ java_lang_Object::ThrowLoggedSQLException( _rLoggerForErrors, &environment, _rxErrorContext );
+ return;
+ }
+
+ // set the new class loader
+ m_environment.CallObjectMethod( m_currentThread.get(), m_setContextClassLoaderMethod, newClassLoader.get() );
+ LocalRef< jthrowable > throwable( m_environment, m_environment.ExceptionOccurred() );
+ if ( throwable.is() )
+ {
+ m_currentThread.reset();
+ m_setContextClassLoaderMethod = NULL;
+ java_lang_Object::ThrowLoggedSQLException( _rLoggerForErrors, &environment, _rxErrorContext );
+ }
+ }
+
+ //--------------------------------------------------------------------
+ void ContextClassLoaderScope::pop( bool clearExceptions )
+ {
+ if ( isActive() )
+ {
+ LocalRef< jobject > currentThread( m_currentThread.env(), m_currentThread.release() );
+ jmethodID setContextClassLoaderMethod( m_setContextClassLoaderMethod );
+ m_setContextClassLoaderMethod = NULL;
+
+ m_environment.CallObjectMethod( currentThread.get(), setContextClassLoaderMethod, m_oldContextClassLoader.get() );
+ if ( clearExceptions )
+ {
+ m_environment.ExceptionClear();
+ }
+ }
+ }
+//........................................................................
+} } // namespace connectivity::jdbc
+//........................................................................
diff --git a/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
new file mode 100644
index 000000000000..848206ecf551
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/DatabaseMetaData.cxx
@@ -0,0 +1,1462 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/DatabaseMetaData.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/sql/ResultSet.hxx"
+#include "java/tools.hxx"
+#include "java/lang/String.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <comphelper/types.hxx>
+#include "TPrivilegesResultSet.hxx"
+#include "diagnose_ex.h"
+#include "resource/jdbc_log.hrc"
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+//**************************************************************
+//************ Class: java.sql.DatabaseMetaData
+//**************************************************************
+
+jclass java_sql_DatabaseMetaData::theClass = 0;
+
+java_sql_DatabaseMetaData::~java_sql_DatabaseMetaData()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_sql_DatabaseMetaData::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/DatabaseMetaData");
+ return theClass;
+}
+// -----------------------------------------------------------------------------
+java_sql_DatabaseMetaData::java_sql_DatabaseMetaData( JNIEnv * pEnv, jobject myObj, java_sql_Connection& _rConnection )
+ :ODatabaseMetaDataBase( &_rConnection,_rConnection.getConnectionInfo() )
+ ,java_lang_Object( pEnv, myObj )
+ ,m_pConnection( &_rConnection )
+ ,m_aLogger( _rConnection.getLogger() )
+{
+ SDBThreadAttach::addRef();
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > java_sql_DatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethod( "getTypeInfo", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethod( "getCatalogs", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString java_sql_DatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getCatalogSeparator", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethod( "getSchemas", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getColumnPrivileges", mID, catalog, schema, table, &columnNamePattern );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getColumns", mID, catalog, schemaPattern, tableNamePattern, &columnNamePattern );
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& _types ) throw(SQLException, RuntimeException)
+{
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[Ljava/lang/String;)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getTables";
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ OSL_VERIFY_RES( !isExceptionOccured(t.pEnv,sal_True),"Exception occured!");
+ jvalue args[4];
+
+ args[3].l = 0;
+ sal_Int32 typeFilterCount = _types.getLength();
+ if ( typeFilterCount )
+ {
+ jobjectArray pObjArray = static_cast< jobjectArray >( t.pEnv->NewObjectArray( (jsize)typeFilterCount, java_lang_String::st_getMyClass(), 0 ) );
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ const ::rtl::OUString* typeFilter = _types.getConstArray();
+ bool bIncludeAllTypes = false;
+ for ( sal_Int32 i=0; i<typeFilterCount; ++i, ++typeFilter )
+ {
+ if ( typeFilter->equalsAsciiL( "%", 1 ) )
+ {
+ bIncludeAllTypes = true;
+ break;
+ }
+ jstring aT = convertwchar_tToJavaString( t.pEnv, *typeFilter );
+ t.pEnv->SetObjectArrayElement( pObjArray, (jsize)i, aT );
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+
+ if ( bIncludeAllTypes )
+ {
+ // the SDBC API allows to pass "%" as table type filter, but in JDBC, "all table types"
+ // is represented by the table type being <null/>
+ t.pEnv->DeleteLocalRef( pObjArray );
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ else
+ {
+ args[3].l = pObjArray;
+ }
+ }
+ // if we are to display "all catalogs", then respect m_aCatalogRestriction
+ Any aCatalogFilter( catalog );
+ if ( !aCatalogFilter.hasValue() )
+ aCatalogFilter = m_pConnection->getCatalogRestriction();
+ // similar for schema
+ Any aSchemaFilter;
+ if ( schemaPattern.equalsAsciiL( "%", 1 ) )
+ aSchemaFilter = m_pConnection->getSchemaRestriction();
+ else
+ aSchemaFilter <<= schemaPattern;
+
+ args[0].l = aCatalogFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aCatalogFilter ) ) : NULL;
+ args[1].l = aSchemaFilter.hasValue() ? convertwchar_tToJavaString( t.pEnv, ::comphelper::getString( aSchemaFilter ) ) : NULL;
+ args[2].l = convertwchar_tToJavaString(t.pEnv,tableNamePattern);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
+ jthrowable jThrow = t.pEnv->ExceptionOccurred();
+ if ( jThrow )
+ t.pEnv->ExceptionClear();// we have to clear the exception here because we want to handle it below
+ if ( aCatalogFilter.hasValue() )
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ if(args[1].l)
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ if(tableNamePattern.getLength())
+ {
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+ //for(INT16 i=0;i<len;i++)
+ if ( args[3].l )
+ {
+ t.pEnv->DeleteLocalRef( (jobjectArray)args[3].l );
+ OSL_VERIFY_RES( !isExceptionOccured( t.pEnv, sal_True ), "Exception occured!" );
+ }
+
+ if ( jThrow )
+ {
+ if ( t.pEnv->IsInstanceOf( jThrow,java_sql_SQLException_BASE::st_getMyClass() ) )
+ {
+ java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE( t.pEnv, jThrow );
+ SQLException e( pException->getMessage(),
+ *this,
+ pException->getSQLState(),
+ pException->getErrorCode(),
+ Any()
+ );
+ delete pException;
+ throw e;
+ }
+ }
+ }
+
+ if ( !out )
+ return NULL;
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedureColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getProcedureColumns", mID, catalog, schemaPattern, procedureNamePattern, &columnNamePattern );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getProcedures( const Any&
+ catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getProcedures", mID, catalog, schemaPattern, procedureNamePattern );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getVersionColumns(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getVersionColumns", mID, catalog, schema, table );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxBinaryLiteralLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxRowSize", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxCatalogNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxCharLiteralLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnsInIndex", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxCursorNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxConnections", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnsInTable", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxStatementLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxTableNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_sql_DatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxTablesInSelect", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getExportedKeys", mID, catalog, schema, table );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getImportedKeys", mID, catalog, schema, table );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethodWithStrings( "getPrimaryKeys", mID, catalog, schema, table );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getIndexInfo(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
+{
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZ)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getIndexInfo";
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[5];
+ // Parameter konvertieren
+ args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
+ args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,table);
+ args[3].z = unique;
+ args[4].z = approximate;
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,args[3].z,args[4].z );
+
+ // und aufraeumen
+ if(catalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(table.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ if ( !out )
+ return NULL;
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getBestRowIdentifier(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
+ sal_Bool nullable ) throw(SQLException, RuntimeException)
+{
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IZ)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getBestRowIdentifier";
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[3];
+ // Parameter konvertieren
+ args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
+ args[1].l = schema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,table);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[1].l,args[2].l,scope,nullable);
+
+ // und aufraeumen
+ if(catalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(table.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+
+ if ( !out )
+ return NULL;
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTablePrivileges(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
+ return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
+
+ static jmethodID mID(NULL);
+ Reference< XResultSet > xReturn( impl_callResultSetMethodWithStrings( "getTablePrivileges", mID, catalog, schemaPattern, tableNamePattern ) );
+
+ if ( xReturn.is() )
+ {
+ // we have to check the result columns for the tables privleges
+ // #106324#
+ Reference< XResultSetMetaDataSupplier > xMetaSup(xReturn,UNO_QUERY);
+ if ( xMetaSup.is() )
+ {
+ Reference< XResultSetMetaData> xMeta = xMetaSup->getMetaData();
+ if ( xMeta.is() && xMeta->getColumnCount() != 7 )
+ {
+ // here we know that the count of column doesn't match
+ ::std::map<sal_Int32,sal_Int32> aColumnMatching;
+ static const ::rtl::OUString sPrivs[] = {
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_CAT")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_SCHEM")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TABLE_NAME")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GRANTOR")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GRANTEE")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PRIVILEGE")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IS_GRANTABLE"))
+ };
+
+ ::rtl::OUString sColumnName;
+ sal_Int32 nCount = xMeta->getColumnCount();
+ for (sal_Int32 i = 1 ; i <= nCount ; ++i)
+ {
+ sColumnName = xMeta->getColumnName(i);
+ for (sal_uInt32 j = 0 ; j < sizeof(sPrivs)/sizeof(sPrivs[0]); ++j)
+ {
+ if ( sPrivs[j] == sColumnName )
+ {
+ aColumnMatching.insert( ::std::map<sal_Int32,sal_Int32>::value_type(i,j+1) );
+ break;
+ }
+ }
+
+ }
+ // fill our own resultset
+ ODatabaseMetaDataResultSet* pNewPrivRes = new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+ Reference< XResultSet > xTemp = xReturn;
+ xReturn = pNewPrivRes;
+ ODatabaseMetaDataResultSet::ORows aRows;
+ Reference< XRow > xRow(xTemp,UNO_QUERY);
+ ::rtl::OUString sValue;
+
+ ODatabaseMetaDataResultSet::ORow aRow(8);
+ while ( xRow.is() && xTemp->next() )
+ {
+ ::std::map<sal_Int32,sal_Int32>::iterator aIter = aColumnMatching.begin();
+ ::std::map<sal_Int32,sal_Int32>::iterator aEnd = aColumnMatching.end();
+ for (;aIter != aEnd ; ++aIter)
+ {
+ sValue = xRow->getString(aIter->first);
+ if ( xRow->wasNull() )
+ aRow[aIter->second] = ODatabaseMetaDataResultSet::getEmptyValue();
+ else
+ aRow[aIter->second] = new ORowSetValueDecorator(sValue);
+ }
+
+ aRows.push_back(aRow);
+ }
+ pNewPrivRes->setRows(aRows);
+ }
+ }
+ }
+ return xReturn;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getCrossReference(
+ const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
+{
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getCrossReference";
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, cMethodName );
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jvalue args[6];
+ // Parameter konvertieren
+ args[0].l = primaryCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(primaryCatalog)) : 0;
+ args[1].l = primarySchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,primarySchema);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,primaryTable);
+ args[3].l = foreignCatalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(foreignCatalog)) : 0;
+ args[4].l = foreignSchema.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,foreignSchema);
+ args[5].l = convertwchar_tToJavaString(t.pEnv,foreignTable);
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l,args[2].l,args[2].l,args[3].l,args[4].l,args[5].l );
+
+ // und aufraeumen
+ if(primaryCatalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(args[1].l)
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(primaryTable.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ if(foreignCatalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[3].l);
+ if(args[4].l)
+ t.pEnv->DeleteLocalRef((jstring)args[4].l);
+ if(foreignTable.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[5].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+
+ if ( !out )
+ return NULL;
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, cMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
+{
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
+ jboolean out( java_lang_Object::callBooleanMethod(_pMethodName,_inout_MethodID) );
+ m_aLogger.log< const sal_Char*, sal_Int16>( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
+ return out;
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString java_sql_DatabaseMetaData::impl_callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
+{
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
+
+ const ::rtl::OUString sReturn( callStringMethod(_pMethodName,_inout_MethodID) );
+ if ( m_aLogger.isLoggable( LogLevel::FINEST ) )
+ {
+ ::rtl::OUString sLoggedResult( sReturn );
+ if ( !sLoggedResult.getLength() )
+ sLoggedResult = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "<empty string>" ) );
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, sLoggedResult );
+ }
+
+ return sReturn;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 java_sql_DatabaseMetaData::impl_callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
+{
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
+ sal_Int32 out( (sal_Int32)callIntMethod(_pMethodName,_inout_MethodID) );
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, (sal_Int32)out );
+ return out;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument )
+{
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG1, _pMethodName, _nArgument );
+
+ jboolean out( callBooleanMethodWithIntArg(_pMethodName,_inout_MethodID,_nArgument) );
+
+ m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, _pMethodName, out );
+ return out;
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethod( const char* _pMethodName, jmethodID& _inout_MethodID )
+{
+ SDBThreadAttach t;
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD, _pMethodName );
+ jobject out(callResultSetMethod(t.env(),_pMethodName,_inout_MethodID));
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+
+// -------------------------------------------------------------------------
+Reference< XResultSet > java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings( const char* _pMethodName, jmethodID& _inout_MethodID,
+ const Any& _rCatalog, const ::rtl::OUString& _rSchemaPattern, const ::rtl::OUString& _rLeastPattern,
+ const ::rtl::OUString* _pOptionalAdditionalString )
+{
+ bool bCatalog = _rCatalog.hasValue();
+ ::rtl::OUString sCatalog;
+ _rCatalog >>= sCatalog;
+
+ bool bSchema = _rSchemaPattern.toChar() != '%';
+
+ // log the call
+ if ( m_aLogger.isLoggable( LogLevel::FINEST ) )
+ {
+ ::rtl::OUString sCatalogLog = bCatalog ? sCatalog : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "null" ) );
+ ::rtl::OUString sSchemaLog = bSchema ? _rSchemaPattern : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "null" ) );
+ if ( _pOptionalAdditionalString )
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG4, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern, *_pOptionalAdditionalString );
+ else
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG3, _pMethodName, sCatalogLog, sSchemaLog, _rLeastPattern );
+ }
+
+ jobject out(0);
+
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_sql_DatabaseMetaData::impl_callResultSetMethodWithStrings: no Java enviroment anymore!" );
+
+ {
+ const char* pSignature = _pOptionalAdditionalString
+ ? "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;"
+ : "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/sql/ResultSet;";
+ // obtain method ID
+ obtainMethodId(t.pEnv, _pMethodName,pSignature, _inout_MethodID);
+
+ // call method
+
+ {
+ jvalue args[4];
+ // convert parameters
+ args[0].l = bCatalog ? convertwchar_tToJavaString( t.pEnv, sCatalog ) : NULL;
+ args[1].l = bSchema ? convertwchar_tToJavaString( t.pEnv, _rSchemaPattern ) : NULL;
+ args[2].l = convertwchar_tToJavaString( t.pEnv, _rLeastPattern );
+ args[3].l = _pOptionalAdditionalString ? convertwchar_tToJavaString( t.pEnv, *_pOptionalAdditionalString ) : NULL;
+
+ // actually do the call
+ if ( _pOptionalAdditionalString )
+ out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l, args[3].l );
+ else
+ out = t.pEnv->CallObjectMethod( object, _inout_MethodID, args[0].l, args[1].l, args[2].l );
+
+ // clean up
+ if ( args[0].l )
+ t.pEnv->DeleteLocalRef( (jstring)args[0].l );
+ if ( args[1].l )
+ t.pEnv->DeleteLocalRef( (jstring)args[1].l );
+ if ( args[2].l )
+ t.pEnv->DeleteLocalRef( (jstring)args[2].l );
+ if ( args[3].l )
+ t.pEnv->DeleteLocalRef( (jstring)args[3].l );
+
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+
+ if ( !out )
+ return NULL;
+
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_SUCCESS, _pMethodName );
+ return new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "doesMaxRowSizeIncludeBlobs", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesLowerCaseQuotedIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesLowerCaseIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesMixedCaseQuotedIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesMixedCaseIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesUpperCaseQuotedIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "storesUpperCaseIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsAlterTableWithAddColumn", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsAlterTableWithDropColumn", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxIndexLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsNonNullableColumns", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getCatalogTerm", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString java_sql_DatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getIdentifierQuoteString", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getExtraNameCharacters", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsDifferentTableCorrelationNames", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "isCatalogAtStart", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "dataDefinitionIgnoredInTransactions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "dataDefinitionCausesTransactionCommit", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsDataManipulationTransactionsOnly", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsDataDefinitionAndDataManipulationTransactions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsPositionedDelete", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsPositionedUpdate", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOpenStatementsAcrossRollback", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOpenStatementsAcrossCommit", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOpenCursorsAcrossCommit", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOpenCursorsAcrossRollback", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "supportsTransactionIsolationLevel", mID, level );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSchemasInDataManipulation", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsANSI92FullSQL", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsANSI92EntryLevelSQL", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsIntegrityEnhancementFacility", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSchemasInIndexDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSchemasInTableDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCatalogsInTableDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCatalogsInIndexDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCatalogsInDataManipulation", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOuterJoins", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callResultSetMethod( "getTableTypes", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_sql_DatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxStatements", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxProcedureNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxSchemaNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsTransactions", mID );
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "allProceduresAreCallable", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsStoredProcedures", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSelectForUpdate", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "allTablesAreSelectable", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "isReadOnly", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "usesLocalFiles", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "usesLocalFilePerTable", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsTypeConversion", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "nullPlusNonNullIsNull", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsColumnAliasing", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsTableCorrelationNames", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException)
+{
+ static const char* pMethodName = "supportsConvert";
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, fromType, toType );
+
+ jboolean out( sal_False );
+ SDBThreadAttach t;
+
+ {
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID);
+ out = t.pEnv->CallBooleanMethod( object, mID, fromType, toType );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+
+ m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
+ return out;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsExpressionsInOrderBy", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsGroupBy", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsGroupByBeyondSelect", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsGroupByUnrelated", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsMultipleTransactions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsMultipleResultSets", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsLikeEscapeClause", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsOrderByUnrelated", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsUnion", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsUnionAll", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsMixedCaseIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_DatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsMixedCaseQuotedIdentifiers", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "nullsAreSortedAtEnd", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "nullsAreSortedAtStart", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "nullsAreSortedHigh", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "nullsAreSortedLow", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSchemasInProcedureCalls", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSchemasInPrivilegeDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCatalogsInProcedureCalls", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCatalogsInPrivilegeDefinitions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCorrelatedSubqueries", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSubqueriesInComparisons", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSubqueriesInExists", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSubqueriesInIns", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsSubqueriesInQuantifieds", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsANSI92IntermediateSQL", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString sURL = m_pConnection->getURL();
+ if ( !sURL.getLength() )
+ {
+ static jmethodID mID(NULL);
+ sURL = impl_callStringMethod( "getURL", mID );
+ }
+ return sURL;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getUserName", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getDriverName", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDriverVersion( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getDriverVersion", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getDatabaseProductVersion", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getDatabaseProductName", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getProcedureTerm", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getSchemaTerm", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getDriverMajorVersion", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getDefaultTransactionIsolation", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getDriverMinorVersion", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getSQLKeywords", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getSearchStringEscape", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getStringFunctions", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getTimeDateFunctions", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getSystemFunctions", mID );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_DatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callStringMethod( "getNumericFunctions", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsExtendedSQLGrammar", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsCoreSQLGrammar", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsMinimumSQLGrammar", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsFullOuterJoins", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsLimitedOuterJoins", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnsInGroupBy", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnsInOrderBy", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxColumnsInSelect", mID );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_DatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callIntMethod( "getMaxUserNameLength", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "supportsResultSetType", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException)
+{
+ static const char* pMethodName = "supportsResultSetConcurrency";
+ m_aLogger.log( LogLevel::FINEST, STR_LOG_META_DATA_METHOD_ARG2, pMethodName, setType, concurrency );
+
+ jboolean out( sal_False );
+ SDBThreadAttach t;
+
+ {
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, pMethodName,"(II)Z", mID);
+ out = t.pEnv->CallBooleanMethod( object, mID, setType, concurrency);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+
+ m_aLogger.log< const sal_Char*, sal_Int16 >( LogLevel::FINEST, STR_LOG_META_DATA_RESULT, pMethodName, out );
+ return out;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "ownUpdatesAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "ownDeletesAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "ownInsertsAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "othersUpdatesAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "othersDeletesAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "othersInsertsAreVisible", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::updatesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "updatesAreDetected", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::deletesAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "deletesAreDetected", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::insertsAreDetected( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethodWithIntArg( "insertsAreDetected", mID, setType );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_DatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_callBooleanMethod( "supportsBatchUpdates", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_DatabaseMetaData::getUDTs(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern,
+ const Sequence< sal_Int32 >& types ) throw(SQLException, RuntimeException)
+{
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+
+
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;[I)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "getUDTs";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ {
+ jvalue args[4];
+ // temporaere Variable initialisieren
+ args[0].l = catalog.hasValue() ? convertwchar_tToJavaString(t.pEnv,comphelper::getString(catalog)) : 0;
+ args[1].l = schemaPattern.toChar() == '%' ? NULL : convertwchar_tToJavaString(t.pEnv,schemaPattern);
+ args[2].l = convertwchar_tToJavaString(t.pEnv,typeNamePattern);
+ jintArray pArray = t.pEnv->NewIntArray(types.getLength());
+ t.pEnv->SetIntArrayRegion(pArray,0,types.getLength(),(jint*)types.getConstArray());
+ args[3].l = pArray;
+
+ out = t.pEnv->CallObjectMethod( object, mID, args[0].l, args[1].l,args[2].l,args[3].l);
+
+ if(catalog.hasValue())
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ if(schemaPattern.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ if(typeNamePattern.getLength())
+ t.pEnv->DeleteLocalRef((jstring)args[2].l);
+ if(args[3].l)
+ t.pEnv->DeleteLocalRef((jintArray)args[3].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+
+ return out ? new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection ) : 0;
+}
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/Date.cxx b/connectivity/source/drivers/jdbc/Date.cxx
new file mode 100644
index 000000000000..41fd2696177a
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Date.cxx
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/util/Date.hxx"
+#include "java/tools.hxx"
+#include "connectivity/dbconversion.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.util.Date
+//**************************************************************
+
+jclass java_util_Date::theClass = 0;
+
+java_util_Date::~java_util_Date()
+{}
+
+jclass java_util_Date::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/util/Date");
+ return theClass;
+}
+
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx
new file mode 100644
index 000000000000..4a0895fee08d
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/DriverPropertyInfo.cxx
@@ -0,0 +1,141 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/DriverPropertyInfo.hxx"
+#include "java/lang/Boolean.hxx"
+#include "java/tools.hxx"
+#include "java/lang/String.hxx"
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+//**************************************************************
+//************ Class: java.sql.Driver
+//**************************************************************
+
+jclass java_sql_DriverPropertyInfo::theClass = 0;
+// --------------------------------------------------------------------------------
+java_sql_DriverPropertyInfo::~java_sql_DriverPropertyInfo()
+{}
+// --------------------------------------------------------------------------------
+jclass java_sql_DriverPropertyInfo::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/DriverPropertyInfo");
+ return theClass;
+}
+
+// --------------------------------------------------------------------------------
+java_sql_DriverPropertyInfo::operator starsdbc::DriverPropertyInfo()
+{
+ starsdbc::DriverPropertyInfo aInfo;
+ aInfo.Name = name();
+ aInfo.Description = description();
+ aInfo.IsRequired = required();
+ aInfo.Value = value();
+ aInfo.Choices = choices();
+
+ return aInfo;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString java_sql_DriverPropertyInfo::name()
+{
+ ::rtl::OUString aStr;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"name","Ljava/lang/String;");
+ if(id)
+ aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
+ } //t.pEnv
+ return aStr;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString java_sql_DriverPropertyInfo::description()
+{
+ ::rtl::OUString aStr;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"description","Ljava/lang/String;");
+ if(id)
+ aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
+ } //t.pEnv
+ return aStr;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString java_sql_DriverPropertyInfo::value()
+{
+ ::rtl::OUString aStr;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"value","Ljava/lang/String;");
+ if(id)
+ aStr = JavaString2String(t.pEnv,(jstring)t.pEnv->GetObjectField( object, id));
+ } //t.pEnv
+ return aStr;
+}
+// --------------------------------------------------------------------------------
+sal_Bool java_sql_DriverPropertyInfo::required()
+{
+ jboolean out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"required","Z");
+ if(id)
+ out = t.pEnv->GetBooleanField( object, id);
+ } //t.pEnv
+ return out;
+}
+// --------------------------------------------------------------------------------
+Sequence< ::rtl::OUString> java_sql_DriverPropertyInfo::choices()
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jfieldID id = t.pEnv->GetFieldID(getMyClass(),"choices","[Ljava/lang/String;");
+ if(id)
+ {
+ const java_lang_String * pEmpty = NULL;
+ const ::rtl::OUString * pEmpty2 = NULL;
+ return copyArrayAndDelete(t.pEnv,(jobjectArray)t.pEnv->GetObjectField( object, id), pEmpty2, pEmpty);
+ }
+ } //t.pEnv
+ return Sequence< ::rtl::OUString>();
+}
+// --------------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/jdbc/Exception.cxx b/connectivity/source/drivers/jdbc/Exception.cxx
new file mode 100644
index 000000000000..da6ceb0b19e0
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Exception.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/Exception.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.Exception
+//**************************************************************
+
+jclass java_lang_Exception::theClass = 0;
+
+java_lang_Exception::~java_lang_Exception()
+{}
+
+jclass java_lang_Exception::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/Exception");
+ return theClass;
+}
+
diff --git a/connectivity/source/drivers/jdbc/InputStream.cxx b/connectivity/source/drivers/jdbc/InputStream.cxx
new file mode 100644
index 000000000000..ed1f1b00abe4
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/InputStream.cxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/io/InputStream.hxx"
+#include "java/tools.hxx"
+
+#include <string.h>
+
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.io.InputStream
+//**************************************************************
+
+jclass java_io_InputStream::theClass = 0;
+java_io_InputStream::java_io_InputStream( JNIEnv * pEnv, jobject myObj )
+ : java_lang_Object( pEnv, myObj )
+{
+ SDBThreadAttach::addRef();
+}
+java_io_InputStream::~java_io_InputStream()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_io_InputStream::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/io/InputStream");
+ return theClass;
+}
+
+
+sal_Int32 SAL_CALL java_io_InputStream::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ return readBytes(aData,nMaxBytesToRead);
+}
+
+void SAL_CALL java_io_InputStream::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callIntMethodWithIntArg("skip",mID,nBytesToSkip);
+}
+
+sal_Int32 SAL_CALL java_io_InputStream::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callIntMethod("available",mID);
+}
+void SAL_CALL java_io_InputStream::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+}
+// -----------------------------------------------------
+sal_Int32 SAL_CALL java_io_InputStream::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ if (nBytesToRead < 0)
+ throw ::com::sun::star::io::BufferSizeExceededException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), *this );
+
+ jint out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jbyteArray pByteArray = t.pEnv->NewByteArray(nBytesToRead);
+ static const char * cSignature = "([BII)I";
+ static const char * cMethodName = "read";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallIntMethod( object, mID, pByteArray, 0, nBytesToRead );
+ if ( !out )
+ ThrowSQLException(t.pEnv,*this);
+ if(out > 0)
+ {
+ jboolean p = sal_False;
+ aData.realloc ( out );
+ rtl_copyMemory(aData.getArray(),t.pEnv->GetByteArrayElements(pByteArray,&p),out);
+ }
+ t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
+ } //t.pEnv
+ return out;
+}
+
diff --git a/connectivity/source/drivers/jdbc/JBigDecimal.cxx b/connectivity/source/drivers/jdbc/JBigDecimal.cxx
new file mode 100644
index 000000000000..155ab5f694f9
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/JBigDecimal.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/math/BigDecimal.hxx"
+#include "java/tools.hxx"
+#include "resource/jdbc_log.hrc"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.Boolean
+//**************************************************************
+
+jclass java_math_BigDecimal::theClass = 0;
+
+java_math_BigDecimal::~java_math_BigDecimal()
+{}
+
+jclass java_math_BigDecimal::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/math/BigDecimal");
+ return theClass;
+}
+
+java_math_BigDecimal::java_math_BigDecimal( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)V";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+
+ jstring str = convertwchar_tToJavaString(t.pEnv,_par0.replace(',','.'));
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, str );
+ t.pEnv->DeleteLocalRef(str);
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ ThrowSQLException( t.pEnv, NULL );
+ // und aufraeumen
+}
+
+java_math_BigDecimal::java_math_BigDecimal( const double& _par0 ): java_lang_Object( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(D)V";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+ tempObj = t.pEnv->NewObject( getMyClass(), mID, _par0 );
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ ThrowSQLException( t.pEnv, NULL );
+ // und aufraeumen
+}
+
diff --git a/connectivity/source/drivers/jdbc/JConnection.cxx b/connectivity/source/drivers/jdbc/JConnection.cxx
new file mode 100644
index 000000000000..f61dc9287649
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/JConnection.cxx
@@ -0,0 +1,873 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "java/sql/Connection.hxx"
+#include "java/lang/Class.hxx"
+#include "java/tools.hxx"
+#include "java/ContextClassLoader.hxx"
+#include "java/sql/DatabaseMetaData.hxx"
+#include "java/sql/JStatement.hxx"
+#include "java/sql/Driver.hxx"
+#include "java/sql/PreparedStatement.hxx"
+#include "java/sql/CallableStatement.hxx"
+#include "java/sql/SQLWarning.hxx"
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
+#include "connectivity/sqlparse.hxx"
+#include "connectivity/dbexception.hxx"
+#include "java/util/Property.hxx"
+#include "java/LocalRef.hxx"
+#include "resource/jdbc_log.hrc"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "jvmaccess/classpath.hxx"
+#include <comphelper/namedvaluecollection.hxx>
+#include <rtl/ustrbuf.hxx>
+#include <jni.h>
+#include "resource/common_res.hrc"
+#include <unotools/confignode.hxx>
+
+#include <list>
+#include <memory>
+
+using namespace connectivity;
+using namespace connectivity::jdbc;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+namespace {
+
+struct ClassMapEntry {
+ ClassMapEntry(
+ rtl::OUString const & theClassPath, rtl::OUString const & theClassName):
+ classPath(theClassPath), className(theClassName), classLoader(NULL),
+ classObject(NULL) {}
+
+ rtl::OUString classPath;
+ rtl::OUString className;
+ jweak classLoader;
+ jweak classObject;
+};
+
+typedef std::list< ClassMapEntry > ClassMap;
+
+struct ClassMapData {
+ osl::Mutex mutex;
+
+ ClassMap map;
+};
+
+struct ClassMapDataInit {
+ ClassMapData * operator()() {
+ static ClassMapData instance;
+ return &instance;
+ }
+};
+
+template < typename T >
+bool getLocalFromWeakRef( jweak& _weak, LocalRef< T >& _inout_local )
+{
+ _inout_local.set( static_cast< T >( _inout_local.env().NewLocalRef( _weak ) ) );
+
+ if ( !_inout_local.is() )
+ {
+ if ( _inout_local.env().ExceptionCheck())
+ {
+ return false;
+ }
+ else if ( _weak != NULL )
+ {
+ _inout_local.env().DeleteWeakGlobalRef( _weak );
+ _weak = NULL;
+ }
+ }
+ return true;
+}
+
+// Load a class. A map from pairs of (classPath, name) to pairs of weak Java
+// references to (ClassLoader, Class) is maintained, so that a class is only
+// loaded once.
+//
+// It may happen that the weak reference to the ClassLoader becomes null while
+// the reference to the Class remains non-null (in case the Class was actually
+// loaded by some parent of the ClassLoader), in which case the ClassLoader is
+// resurrected (which cannot cause any classes to be loaded multiple times, as
+// the ClassLoader is no longer reachable, so no classes it has ever loaded are
+// still reachable).
+//
+// Similarly, it may happen that the weak reference to the Class becomes null
+// while the reference to the ClassLoader remains non-null, in which case the
+// Class is simply re-loaded.
+//
+// This code is close to the implementation of jvmaccess::ClassPath::loadClass
+// in jvmaccess/classpath.hxx, but not close enough to avoid the duplication.
+//
+// If false is returned, a (still pending) JNI exception occurred.
+bool loadClass(
+ Reference< XComponentContext > const & context, JNIEnv& environment,
+ rtl::OUString const & classPath, rtl::OUString const & name,
+ LocalRef< jobject > * classLoaderPtr, LocalRef< jclass > * classPtr)
+{
+ OSL_ASSERT(classLoaderPtr != NULL);
+ // For any jweak entries still present in the map upon destruction,
+ // DeleteWeakGlobalRef is not called (which is a leak):
+ ClassMapData * d =
+ rtl_Instance< ClassMapData, ClassMapDataInit, osl::MutexGuard,
+ osl::GetGlobalMutex >::create(
+ ClassMapDataInit(), osl::GetGlobalMutex());
+ osl::MutexGuard g(d->mutex);
+ ClassMap::iterator i(d->map.begin());
+ LocalRef< jobject > cloader(environment);
+ LocalRef< jclass > cl(environment);
+ // Prune dangling weak references from the list while searching for a match,
+ // so that the list cannot grow unbounded:
+ for (; i != d->map.end();)
+ {
+ LocalRef< jobject > classLoader( environment );
+ if ( !getLocalFromWeakRef( i->classLoader, classLoader ) )
+ return false;
+
+ LocalRef< jclass > classObject( environment );
+ if ( !getLocalFromWeakRef( i->classObject, classObject ) )
+ return false;
+
+ if ( !classLoader.is() && !classObject.is() )
+ {
+ i = d->map.erase(i);
+ }
+ else if ( i->classPath == classPath && i->className == name )
+ {
+ cloader.set( classLoader.release() );
+ cl.set( classObject.release() );
+ break;
+ }
+ else
+ {
+ ++i;
+ }
+ }
+ if ( !cloader.is() || !cl.is() )
+ {
+ if ( i == d->map.end() )
+ {
+ // Push a new ClassMapEntry (which can potentially fail) before
+ // loading the class, so that it never happens that a class is
+ // loaded but not added to the map (which could have effects on the
+ // JVM that are not easily undone). If the pushed ClassMapEntry is
+ // not used after all (return false, etc.) it will be pruned on next
+ // call because its classLoader/classObject are null:
+ d->map.push_front( ClassMapEntry( classPath, name ) );
+ i = d->map.begin();
+ }
+
+ LocalRef< jclass > clClass( environment );
+ clClass.set( environment.FindClass( "java/net/URLClassLoader" ) );
+ if ( !clClass.is() )
+ return false;
+
+ jweak wcloader = NULL;
+ if (!cloader.is())
+ {
+ jmethodID ctorLoader( environment.GetMethodID( clClass.get(), "<init>", "([Ljava/net/URL;)V" ) );
+ if (ctorLoader == NULL)
+ return false;
+
+ LocalRef< jobjectArray > arr( environment );
+ arr.set( jvmaccess::ClassPath::translateToUrls( context, &environment, classPath ) );
+ if ( !arr.is() )
+ return false;
+
+ jvalue arg;
+ arg.l = arr.get();
+ cloader.set( environment.NewObjectA( clClass.get(), ctorLoader, &arg ) );
+ if ( !cloader.is() )
+ return false;
+
+ wcloader = environment.NewWeakGlobalRef( cloader.get() );
+ if ( wcloader == NULL )
+ return false;
+ }
+
+ jweak wcl = NULL;
+ if ( !cl.is() )
+ {
+ jmethodID methLoadClass( environment.GetMethodID( clClass.get(), "loadClass", "(Ljava/lang/String;)Ljava/lang/Class;" ) );
+ if ( methLoadClass == NULL )
+ return false;
+
+ LocalRef< jstring > str( environment );
+ str.set( convertwchar_tToJavaString( &environment, name ) );
+ if ( !str.is() )
+ return false;
+
+ jvalue arg;
+ arg.l = str.get();
+ cl.set( static_cast< jclass >( environment.CallObjectMethodA( cloader.get(), methLoadClass, &arg ) ) );
+ if ( !cl.is() )
+ return false;
+
+ wcl = environment.NewWeakGlobalRef( cl.get() );
+ if ( wcl == NULL )
+ return false;
+ }
+
+ if ( wcloader != NULL)
+ {
+ i->classLoader = wcloader;
+ }
+ if ( wcl != NULL )
+ {
+ i->classObject = wcl;
+ }
+ }
+
+ classLoaderPtr->set( cloader.release() );
+ classPtr->set( cl.release() );
+ return true;
+}
+
+}
+
+//------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(java_sql_Connection,"com.sun.star.sdbcx.JConnection","com.sun.star.sdbc.Connection");
+//------------------------------------------------------------------------------
+//**************************************************************
+//************ Class: java.sql.Connection
+//**************************************************************
+jclass java_sql_Connection::theClass = 0;
+
+java_sql_Connection::java_sql_Connection( const java_sql_Driver& _rDriver )
+ :java_lang_Object( _rDriver.getContext().getLegacyServiceFactory() )
+ ,OSubComponent<java_sql_Connection, java_sql_Connection_BASE>((::cppu::OWeakObject*)(&_rDriver), this)
+ ,m_pDriver( &_rDriver )
+ ,m_pDriverobject(NULL)
+ ,m_pDriverClassLoader()
+ ,m_Driver_theClass(NULL)
+ ,m_aLogger( _rDriver.getLogger() )
+ ,m_bParameterSubstitution(sal_False)
+ ,m_bIgnoreDriverPrivileges(sal_True)
+ ,m_bIgnoreCurrency(sal_False)
+{
+}
+// -----------------------------------------------------------------------------
+java_sql_Connection::~java_sql_Connection()
+{
+ ::rtl::Reference< jvmaccess::VirtualMachine > xTest = java_lang_Object::getVM();
+ if ( xTest.is() )
+ {
+ SDBThreadAttach t;
+ clearObject(*t.pEnv);
+
+ {
+ if ( m_pDriverobject )
+ t.pEnv->DeleteGlobalRef( m_pDriverobject );
+ m_pDriverobject = NULL;
+ if ( m_Driver_theClass )
+ t.pEnv->DeleteGlobalRef( m_Driver_theClass );
+ m_Driver_theClass = NULL;
+ }
+ t.releaseRef();
+ }
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::release() throw()
+{
+ relase_ChildImpl();
+}
+//------------------------------------------------------------------------------
+void java_sql_Connection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aLogger.log( LogLevel::INFO, STR_LOG_SHUTDOWN_CONNECTION );
+
+ dispose_ChildImpl();
+ java_sql_Connection_BASE::disposing();
+
+ if ( object )
+ {
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+ }
+}
+// -------------------------------------------------------------------------
+jclass java_sql_Connection::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Connection");
+ return theClass;
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_Connection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ static jmethodID mID(NULL);
+ return callStringMethod("getCatalog",mID);
+}
+// -------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL java_sql_Connection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/DatabaseMetaData;", mID);
+ if(out)
+ {
+ xMetaData = new java_sql_DatabaseMetaData( t.pEnv, out, *this );
+ m_xMetaData = xMetaData;
+ }
+ }
+
+ return xMetaData;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::close( ) throw(SQLException, RuntimeException)
+{
+ dispose();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::commit( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethod("commit",mID);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_Connection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isClosed", mID ) && java_sql_Connection_BASE::rBHelper.bDisposed;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_Connection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isReadOnly", mID );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("setCatalog",mID,catalog);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::rollback( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethod("rollback",mID);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_Connection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "getAutoCommit", mID );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setReadOnly",mID,readOnly);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setAutoCommit",mID,autoCommit);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL java_sql_Connection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ /*jobject out = */callObjectMethod(t.pEnv,"getTypeMap","()Ljava/util/Map;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return 0;// ? 0 : Map2XNameAccess( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_Connection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ static jmethodID mID(NULL);
+ return callIntMethod("getTransactionIsolation",mID);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setTransactionIsolation",mID,level);
+}
+// -------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL java_sql_Connection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_CREATE_STATEMENT );
+
+ SDBThreadAttach t;
+ java_sql_Statement* pStatement = new java_sql_Statement( t.pEnv, *this );
+ Reference< XStatement > xStmt = pStatement;
+ m_aStatements.push_back( WeakReferenceHelper( xStmt ) );
+
+ m_aLogger.log( LogLevel::FINE, STR_LOG_CREATED_STATEMENT_ID, pStatement->getStatementObjectID() );
+ return xStmt;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_sql_Connection::transFormPreparedStatement(const ::rtl::OUString& _sSQL)
+{
+ ::rtl::OUString sSqlStatement = _sSQL;
+ if ( m_bParameterSubstitution )
+ {
+ try
+ {
+ OSQLParser aParser( m_pDriver->getContext().getLegacyServiceFactory() );
+ ::rtl::OUString sErrorMessage;
+ ::rtl::OUString sNewSql;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sSQL);
+ if(pNode)
+ { // special handling for parameters
+ OSQLParseNode::substituteParameterNames(pNode);
+ pNode->parseNodeToStr( sNewSql, this );
+ delete pNode;
+ sSqlStatement = sNewSql;
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ return sSqlStatement;
+}
+// -------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_STATEMENT, sql );
+
+ SDBThreadAttach t;
+ ::rtl::OUString sSqlStatement = sql;
+ sSqlStatement = transFormPreparedStatement( sSqlStatement );
+
+ java_sql_PreparedStatement* pStatement = new java_sql_PreparedStatement( t.pEnv, *this, sSqlStatement );
+ Reference< XPreparedStatement > xReturn( pStatement );
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+
+ m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_STATEMENT_ID, pStatement->getStatementObjectID() );
+ return xReturn;
+}
+// -------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL java_sql_Connection::prepareCall( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARE_CALL, sql );
+
+ SDBThreadAttach t;
+ ::rtl::OUString sSqlStatement = sql;
+ sSqlStatement = transFormPreparedStatement( sSqlStatement );
+
+ java_sql_CallableStatement* pStatement = new java_sql_CallableStatement( t.pEnv, *this, sSqlStatement );
+ Reference< XPreparedStatement > xStmt( pStatement );
+ m_aStatements.push_back(WeakReferenceHelper(xStmt));
+
+ m_aLogger.log( LogLevel::FINE, STR_LOG_PREPARED_CALL_ID, pStatement->getStatementObjectID() );
+ return xStmt;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_Connection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString aStr;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Ljava/lang/String;";
+ static const char * cMethodName = "nativeSQL";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,sql));
+
+ jobject out = t.pEnv->CallObjectMethod( object, mID, str.get() );
+ aStr = JavaString2String(t.pEnv, (jstring)out );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ } //t.pEnv
+
+ m_aLogger.log( LogLevel::FINER, STR_LOG_NATIVE_SQL, sql, aStr );
+
+ return aStr;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Connection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL java_sql_Connection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Connection_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ if( out )
+ {
+ java_sql_SQLWarning_BASE warn_base(t.pEnv, out);
+ SQLException aAsException( static_cast< starsdbc::SQLException >( java_sql_SQLWarning( warn_base, *this ) ) );
+
+ // translate to warning
+ SQLWarning aWarning;
+ aWarning.Context = aAsException.Context;
+ aWarning.Message = aAsException.Message;
+ aWarning.SQLState = aAsException.SQLState;
+ aWarning.ErrorCode = aAsException.ErrorCode;
+ aWarning.NextException = aAsException.NextException;
+
+ return makeAny( aWarning );
+ }
+
+ return Any();
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ ::rtl::OUString lcl_getDriverLoadErrorMessage( const ::connectivity::SharedResources& _aResource,const ::rtl::OUString& _rDriverClass, const ::rtl::OUString& _rDriverClassPath )
+ {
+ ::rtl::OUString sError1( _aResource.getResourceStringWithSubstitution(
+ STR_NO_CLASSNAME,
+ "$classname$", _rDriverClass
+ ) );
+ if ( _rDriverClassPath.getLength() )
+ {
+ const ::rtl::OUString sError2( _aResource.getResourceStringWithSubstitution(
+ STR_NO_CLASSNAME_PATH,
+ "$classpath$", _rDriverClassPath
+ ) );
+ sError1 += sError2;
+ } // if ( _rDriverClassPath.getLength() )
+ return sError1;
+ }
+}
+
+// -----------------------------------------------------------------------------
+namespace
+{
+ bool lcl_setSystemProperties_nothrow( const java::sql::ConnectionLog& _rLogger,
+ JNIEnv& _rEnv, const Sequence< NamedValue >& _rSystemProperties )
+ {
+ if ( _rSystemProperties.getLength() == 0 )
+ // nothing to do
+ return true;
+
+ LocalRef< jclass > systemClass( _rEnv );
+ jmethodID nSetPropertyMethodID = 0;
+ // retrieve the java.lang.System class
+ systemClass.set( _rEnv.FindClass( "java/lang/System" ) );
+ if ( systemClass.is() )
+ {
+ nSetPropertyMethodID = _rEnv.GetStaticMethodID(
+ systemClass.get(), "setProperty", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;" );
+ }
+
+ if ( nSetPropertyMethodID == 0 )
+ return false;
+
+ for ( const NamedValue* pSystemProp = _rSystemProperties.getConstArray();
+ pSystemProp != _rSystemProperties.getConstArray() + _rSystemProperties.getLength();
+ ++pSystemProp
+ )
+ {
+ ::rtl::OUString sValue;
+ OSL_VERIFY( pSystemProp->Value >>= sValue );
+
+ _rLogger.log( LogLevel::FINER, STR_LOG_SETTING_SYSTEM_PROPERTY, pSystemProp->Name, sValue );
+
+ LocalRef< jstring > jName( _rEnv, convertwchar_tToJavaString( &_rEnv, pSystemProp->Name ) );
+ LocalRef< jstring > jValue( _rEnv, convertwchar_tToJavaString( &_rEnv, sValue ) );
+
+ _rEnv.CallStaticObjectMethod( systemClass.get(), nSetPropertyMethodID, jName.get(), jValue.get() );
+ LocalRef< jthrowable > throwable( _rEnv, _rEnv.ExceptionOccurred() );
+ if ( throwable.is() )
+ return false;
+ }
+
+ return true;
+ }
+}
+
+// -----------------------------------------------------------------------------
+void java_sql_Connection::loadDriverFromProperties( const ::rtl::OUString& _sDriverClass, const ::rtl::OUString& _sDriverClassPath,
+ const Sequence< NamedValue >& _rSystemProperties )
+{
+ // contains the statement which should be used when query for automatically generated values
+ ::rtl::OUString sGeneratedValueStatement;
+ // set to <TRUE/> when we should allow to query for generated values
+ sal_Bool bAutoRetrievingEnabled = sal_False;
+
+ // first try if the jdbc driver is alraedy registered at the driver manager
+ SDBThreadAttach t;
+ try
+ {
+ if ( !object )
+ {
+ if ( !lcl_setSystemProperties_nothrow( getLogger(), *t.pEnv, _rSystemProperties ) )
+ ThrowLoggedSQLException( getLogger(), t.pEnv, *this );
+
+ m_pDriverClassLoader.reset();
+
+ // here I try to find the class for jdbc driver
+ java_sql_SQLException_BASE::st_getMyClass();
+ java_lang_Throwable::st_getMyClass();
+
+ if ( !_sDriverClass.getLength() )
+ {
+ m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_DRIVER_CLASS );
+ ::dbtools::throwGenericSQLException(
+ lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ),
+ *this
+ );
+ }
+ else
+ {
+ m_aLogger.log( LogLevel::INFO, STR_LOG_LOADING_DRIVER, _sDriverClass );
+ // the driver manager holds the class of the driver for later use
+ ::std::auto_ptr< java_lang_Class > pDrvClass;
+ if ( !_sDriverClassPath.getLength() )
+ {
+ // if forName didn't find the class it will throw an exception
+ pDrvClass = ::std::auto_ptr< java_lang_Class >(java_lang_Class::forName(_sDriverClass));
+ }
+ else
+ {
+ LocalRef< jclass > driverClass(t.env());
+ LocalRef< jobject > driverClassLoader(t.env());
+
+ loadClass(
+ m_pDriver->getContext().getUNOContext(),
+ t.env(), _sDriverClassPath, _sDriverClass, &driverClassLoader, &driverClass );
+
+ m_pDriverClassLoader.set( driverClassLoader );
+ pDrvClass.reset( new java_lang_Class( t.pEnv, driverClass.release() ) );
+
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ if ( pDrvClass.get() )
+ {
+ LocalRef< jobject > driverObject( t.env() );
+ driverObject.set( pDrvClass->newInstanceObject() );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ m_pDriverobject = driverObject.release();
+
+ if( t.pEnv && m_pDriverobject )
+ m_pDriverobject = t.pEnv->NewGlobalRef( m_pDriverobject );
+
+ {
+ jclass tempClass = t.pEnv->GetObjectClass(m_pDriverobject);
+ if ( m_pDriverobject )
+ {
+ m_Driver_theClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
+ t.pEnv->DeleteLocalRef( tempClass );
+ }
+ }
+ }
+ m_aLogger.log( LogLevel::INFO, STR_LOG_CONN_SUCCESS );
+ }
+ }
+ }
+ catch( const SQLException& e )
+ {
+ throw SQLException(
+ lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ),
+ *this,
+ ::rtl::OUString(),
+ 1000,
+ makeAny(e)
+ );
+ }
+ catch( Exception& )
+ {
+ ::dbtools::throwGenericSQLException(
+ lcl_getDriverLoadErrorMessage( getResources(),_sDriverClass, _sDriverClassPath ),
+ *this
+ );
+ }
+
+ enableAutoRetrievingEnabled( bAutoRetrievingEnabled );
+ setAutoRetrievingStatement( sGeneratedValueStatement );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_sql_Connection::impl_getJavaDriverClassPath_nothrow(const ::rtl::OUString& _sDriverClass)
+{
+ static const ::rtl::OUString s_sNodeName(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.DataAccess/JDBC/DriverClassPaths"));
+ ::utl::OConfigurationTreeRoot aNamesRoot = ::utl::OConfigurationTreeRoot::createWithServiceFactory(
+ m_pDriver->getContext().getLegacyServiceFactory(), s_sNodeName, -1, ::utl::OConfigurationTreeRoot::CM_READONLY);
+ ::rtl::OUString sURL;
+ if ( aNamesRoot.isValid() && aNamesRoot.hasByName( _sDriverClass ) )
+ {
+ ::utl::OConfigurationNode aRegisterObj = aNamesRoot.openNode( _sDriverClass );
+ OSL_VERIFY( aRegisterObj.getNodeValue( "Path" ) >>= sURL );
+ }
+ return sURL;
+}
+// -----------------------------------------------------------------------------
+sal_Bool java_sql_Connection::construct(const ::rtl::OUString& url,
+ const Sequence< PropertyValue >& info)
+{
+ { // initialize the java vm
+ ::rtl::Reference< jvmaccess::VirtualMachine > xTest = java_lang_Object::getVM(getORB());
+ if ( !xTest.is() )
+ throwGenericSQLException(STR_NO_JAVA,*this);
+ }
+ SDBThreadAttach t;
+ t.addRef(); // will be released in dtor
+ if ( !t.pEnv )
+ throwGenericSQLException(STR_NO_JAVA,*this);
+
+ ::rtl::OUString sGeneratedValueStatement; // contains the statement which should be used when query for automatically generated values
+ sal_Bool bAutoRetrievingEnabled = sal_False; // set to <TRUE/> when we should allow to query for generated values
+ ::rtl::OUString sDriverClassPath,sDriverClass;
+ Sequence< NamedValue > aSystemProperties;
+
+ ::comphelper::NamedValueCollection aSettings( info );
+ sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass );
+ sDriverClassPath = aSettings.getOrDefault( "JavaDriverClassPath", sDriverClassPath);
+ if ( !sDriverClassPath.getLength() )
+ sDriverClassPath = impl_getJavaDriverClassPath_nothrow(sDriverClass);
+ bAutoRetrievingEnabled = aSettings.getOrDefault( "IsAutoRetrievingEnabled", bAutoRetrievingEnabled );
+ sGeneratedValueStatement = aSettings.getOrDefault( "AutoRetrievingStatement", sGeneratedValueStatement );
+ m_bParameterSubstitution = aSettings.getOrDefault( "ParameterNameSubstitution", m_bParameterSubstitution );
+ m_bIgnoreDriverPrivileges = aSettings.getOrDefault( "IgnoreDriverPrivileges", m_bIgnoreDriverPrivileges );
+ m_bIgnoreCurrency = aSettings.getOrDefault( "IgnoreCurrency", m_bIgnoreCurrency );
+ aSystemProperties = aSettings.getOrDefault( "SystemProperties", aSystemProperties );
+ m_aCatalogRestriction = aSettings.getOrDefault( "ImplicitCatalogRestriction", Any() );
+ m_aSchemaRestriction = aSettings.getOrDefault( "ImplicitSchemaRestriction", Any() );
+
+ loadDriverFromProperties( sDriverClass, sDriverClassPath, aSystemProperties );
+
+ enableAutoRetrievingEnabled(bAutoRetrievingEnabled);
+ setAutoRetrievingStatement(sGeneratedValueStatement);
+
+ if ( t.pEnv && m_Driver_theClass && m_pDriverobject )
+ {
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;Ljava/util/Properties;)Ljava/sql/Connection;";
+ static const char * cMethodName = "connect";
+ // Java-Call absetzen
+ static jmethodID mID = NULL;
+ if ( !mID )
+ mID = t.pEnv->GetMethodID( m_Driver_theClass, cMethodName, cSignature );
+ if ( mID )
+ {
+ jvalue args[2];
+ // Parameter konvertieren
+ args[0].l = convertwchar_tToJavaString(t.pEnv,url);
+ java_util_Properties* pProps = createStringPropertyArray(info);
+ args[1].l = pProps->getJavaObject();
+
+ LocalRef< jobject > ensureDelete( t.env(), args[0].l );
+
+ jobject out = NULL;
+ // In some cases (e.g.,
+ // connectivity/source/drivers/hsqldb/HDriver.cxx:1.24
+ // l. 249) the JavaDriverClassPath contains multiple jars,
+ // as creating the JavaDriverClass instance requires
+ // (reflective) access to those other jars. Now, if the
+ // JavaDriverClass is actually loaded by some parent class
+ // loader (e.g., because its jar is also on the global
+ // class path), it would still not have access to the
+ // additional jars on the JavaDriverClassPath. Hence, the
+ // JavaDriverClassPath class loader is pushed as context
+ // class loader around the JavaDriverClass instance
+ // creation:
+ // #i82222# / 2007-10-15
+ {
+ ContextClassLoaderScope ccl( t.env(), getDriverClassLoader(), getLogger(), *this );
+ out = t.pEnv->CallObjectMethod( m_pDriverobject, mID, args[0].l,args[1].l );
+ delete pProps, pProps = NULL;
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+
+ if ( !out )
+ m_aLogger.log( LogLevel::SEVERE, STR_LOG_NO_SYSTEM_CONNECTION );
+
+ if ( out )
+ object = t.pEnv->NewGlobalRef( out );
+
+ if ( object )
+ m_aLogger.log( LogLevel::INFO, STR_LOG_GOT_JDBC_CONNECTION, url );
+
+ m_aConnectionInfo = info;
+ } //mID
+ } //t.pEnv
+ return object != NULL;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/jdbc/JDriver.cxx b/connectivity/source/drivers/jdbc/JDriver.cxx
new file mode 100644
index 000000000000..09a9649f059d
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/JDriver.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Driver.hxx"
+#include "java/lang/Object.hxx"
+#include "java/lang/Class.hxx"
+#include "java/sql/DriverPropertyInfo.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/util/Property.hxx"
+#include "java/tools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <jvmfwk/framework.h>
+#include "diagnose_ex.h"
+#include "resource/jdbc_log.hrc"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include <comphelper/componentcontext.hxx>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+java_sql_Driver::java_sql_Driver(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ :m_aContext( _rxFactory )
+ ,m_aLogger( m_aContext.getUNOContext(), "sdbcl", "org.openoffice.sdbc.jdbcBridge" )
+{
+}
+// --------------------------------------------------------------------------------
+java_sql_Driver::~java_sql_Driver()
+{
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString java_sql_Driver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.JDBCDriver");
+ // this name is referenced in the configuration and in the jdbc.xml
+ // Please take care when changing it.
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > java_sql_Driver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ return aSNS;
+}
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL connectivity::java_sql_Driver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new java_sql_Driver(_rxFactory));
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_Driver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_Driver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// --------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL java_sql_Driver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL java_sql_Driver::connect( const ::rtl::OUString& url, const
+ Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_CONNECTING_URL, url );
+
+ Reference< XConnection > xOut;
+ if ( acceptsURL(url ) )
+ {
+ java_sql_Connection* pConnection = new java_sql_Connection( *this );
+ xOut = pConnection;
+ if ( !pConnection->construct(url,info) )
+ xOut.clear(); // an error occured and the java driver didn't throw an exception
+ else
+ m_aLogger.log( LogLevel::INFO, STR_LOG_DRIVER_SUCCESS );
+ }
+ return xOut;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_Driver::acceptsURL( const ::rtl::OUString& url ) throw(SQLException, RuntimeException)
+{
+ // don't ask the real driver for the url
+ // I feel responsible for all jdbc url's
+ sal_Bool bEnabled = sal_False;
+ OSL_VERIFY_EQUALS( jfw_getEnabled( &bEnabled ), JFW_E_NONE, "error in jfw_getEnabled" );
+ static const ::rtl::OUString s_sJdbcPrefix = ::rtl::OUString::createFromAscii("jdbc:");
+ return bEnabled && 0 == url.compareTo(s_sJdbcPrefix, 5);
+}
+// -------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL java_sql_Driver::getPropertyInfo( const ::rtl::OUString& url,
+ const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBooleanValues(2);
+ aBooleanValues[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) );
+ aBooleanValues[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The JDBC driver class name."))
+ ,sal_True
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClassPath"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The class path where to look for the JDBC driver."))
+ ,sal_True
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) )
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemProperties"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Additional properties to set at java.lang.System before loading the driver."))
+ ,sal_True
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "" ) )
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParameterNameSubstitution"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Change named parameters with '?'."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreDriverPrivileges"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the privileges from the database driver."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Retrieve generated values."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoRetrievingStatement"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Auto-increment statement."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GenerateASBeforeCorrelationName"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Generate AS before table correlation names."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreCurrency"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the currency field from the ResultsetMetaData."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EscapeDateTime"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Escape date time format."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TypeInfoSettings"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Defines how the type info of the database metadata should be manipulated."))
+ ,sal_False
+ ,::rtl::OUString( )
+ ,Sequence< ::rtl::OUString > ())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImplicitCatalogRestriction"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The catalog which should be used in getTables calls, when the caller passed NULL."))
+ ,sal_False
+ ,::rtl::OUString( )
+ ,Sequence< ::rtl::OUString > ())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ImplicitSchemaRestriction"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The schema which should be used in getTables calls, when the caller passed NULL."))
+ ,sal_False
+ ,::rtl::OUString( )
+ ,Sequence< ::rtl::OUString > ())
+ );
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_Driver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_Driver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/JStatement.cxx b/connectivity/source/drivers/jdbc/JStatement.cxx
new file mode 100644
index 000000000000..29d8c189a66e
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/JStatement.cxx
@@ -0,0 +1,829 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "java/sql/JStatement.hxx"
+#include "java/sql/ResultSet.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/sql/SQLWarning.hxx"
+#include "java/tools.hxx"
+#include "java/ContextClassLoader.hxx"
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+
+#include "resource/jdbc_log.hrc"
+
+#include <algorithm>
+#include <string.h>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+//------------------------------------------------------------------------------
+//**************************************************************
+//************ Class: java.sql.Statement
+//**************************************************************
+
+jclass java_sql_Statement_Base::theClass = 0;
+
+// -------------------------------------------------------------------------
+java_sql_Statement_Base::java_sql_Statement_Base( JNIEnv * pEnv, java_sql_Connection& _rCon )
+ :java_sql_Statement_BASE(m_aMutex)
+ ,java_lang_Object( pEnv, NULL )
+ ,OPropertySetHelper(java_sql_Statement_BASE::rBHelper)
+ ,m_pConnection( &_rCon )
+ ,m_aLogger( _rCon.getLogger(), java::sql::ConnectionLog::STATEMENT )
+ ,m_nResultSetConcurrency(ResultSetConcurrency::READ_ONLY)
+ ,m_nResultSetType(ResultSetType::FORWARD_ONLY)
+ ,m_bEscapeProcessing(sal_True)
+ ,rBHelper(java_sql_Statement_BASE::rBHelper)
+{
+ m_pConnection->acquire();
+}
+
+//------------------------------------------------------------------------------
+java_sql_Statement_Base::~java_sql_Statement_Base()
+{
+}
+
+//------------------------------------------------------------------------------
+void SAL_CALL OStatement_BASE2::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( object )
+ {
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+ }
+
+ ::comphelper::disposeComponent(m_xGeneratedStatement);
+ if (m_pConnection)
+ m_pConnection->release();
+ m_pConnection = NULL;
+
+ dispose_ChildImpl();
+ java_sql_Statement_Base::disposing();
+}
+// -------------------------------------------------------------------------
+jclass java_sql_Statement_Base::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Statement");
+ return theClass;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement_Base::disposing(void)
+{
+ m_aLogger.log( LogLevel::FINE, STR_LOG_CLOSING_STATEMENT );
+ java_sql_Statement_BASE::disposing();
+ clearObject();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_BASE2::release() throw()
+{
+ relase_ChildImpl();
+}
+
+// -------------------------------------------------------------------------
+Any SAL_CALL java_sql_Statement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) )
+ return Any();
+ Any aRet( java_sql_Statement_BASE::queryInterface(rType) );
+ return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL java_sql_Statement_Base::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ Sequence< Type > aOldTypes = java_sql_Statement_BASE::getTypes();
+ if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
+ {
+ ::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
+ ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ));
+ aOldTypes.realloc(aOldTypes.getLength() - 1);
+ }
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL java_sql_Statement_Base::getGeneratedValues( ) throw (SQLException, RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINE, STR_LOG_GENERATED_VALUES );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ // temporaere Variable initialisieren
+ try
+ {
+ static jmethodID mID(NULL);
+ out = callResultSetMethod(t.env(),"getGeneratedKeys",mID);
+ }
+ catch(const SQLException&)
+ {
+ // ignore
+ }
+
+ Reference< XResultSet > xRes;
+ if ( !out )
+ {
+ OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
+ if ( m_pConnection )
+ {
+ ::rtl::OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
+ if ( sStmt.getLength() )
+ {
+ m_aLogger.log( LogLevel::FINER, STR_LOG_GENERATED_VALUES_FALLBACK, sStmt );
+ ::comphelper::disposeComponent(m_xGeneratedStatement);
+ m_xGeneratedStatement = m_pConnection->createStatement();
+ xRes = m_xGeneratedStatement->executeQuery(sStmt);
+ }
+ }
+ }
+ else
+ xRes = new java_sql_ResultSet( t.pEnv, out, m_aLogger,*m_pConnection, this );
+ return xRes;
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_Statement_Base::cancel( ) throw(RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("cancel",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_Statement_Base::close( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ if (java_sql_Statement_BASE::rBHelper.bDisposed)
+ throw DisposedException();
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_Statement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("clearBatch",mID);
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_Statement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_STATEMENT, sql );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ jboolean out(sal_False);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ m_sSqlStatement = sql;
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Z";
+ static const char * cMethodName = "execute";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ {
+ jdbc::ContextClassLoaderScope ccl( t.env(),
+ m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_aLogger,
+ *this
+ );
+
+ out = t.pEnv->CallBooleanMethod( object, mID, str.get() );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ } //t.pEnv
+ return out;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL java_sql_Statement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_QUERY, sql );
+
+ jobject out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ createStatement(t.pEnv);
+ m_sSqlStatement = sql;
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/ResultSet;";
+ static const char * cMethodName = "executeQuery";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ {
+ jdbc::ContextClassLoaderScope ccl( t.env(),
+ m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ m_aLogger,
+ *this
+ );
+
+ out = t.pEnv->CallObjectMethod( object, mID, str.get() );
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL java_sql_Statement_Base::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL java_sql_Statement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
+ return aRet.hasValue() ? aRet : java_sql_Statement_Base::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_Statement::addBatch( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("addBatch",mID,sql);
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL java_sql_Statement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ Sequence< sal_Int32 > aSeq;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID);
+ if (out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
+ return aSeq;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Int32 SAL_CALL java_sql_Statement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTE_UPDATE, sql );
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ m_sSqlStatement = sql;
+ static jmethodID mID(NULL);
+ return callIntMethodWithStringArg("executeUpdate",mID,sql);
+}
+// -------------------------------------------------------------------------
+
+Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_Statement_Base::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callResultSetMethod(t.env(),"getResultSet",mID);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this );
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_Statement_Base::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ sal_Int32 out = callIntMethod("getUpdateCount",mID);
+ m_aLogger.log( LogLevel::FINER, STR_LOG_UPDATE_COUNT, (sal_Int32)out );
+ return out;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_Statement_Base::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "getMoreResults", mID );
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+Any SAL_CALL java_sql_Statement_Base::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ SDBThreadAttach t;
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ if( out )
+ {
+ java_sql_SQLWarning_BASE warn_base( t.pEnv, out );
+ return makeAny(
+ static_cast< starsdbc::SQLException >(
+ java_sql_SQLWarning(warn_base,*(::cppu::OWeakObject*)this)));
+ }
+
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement_Base::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t;
+
+ {
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
+ }
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getQueryTimeOut() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getQueryTimeOut",mID);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getMaxRows() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getMaxRows",mID);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getResultSetConcurrency() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getResultSetConcurrency",mID,m_nResultSetConcurrency);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getResultSetType() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getResultSetType",mID,m_nResultSetType);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nDefault)
+{
+ sal_Int32 out = _nDefault;
+ if ( object )
+ out = callIntMethod(_pMethodName,_inout_MethodID,true);
+
+ return out;
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::impl_getProperty(const char* _pMethodName, jmethodID& _inout_MethodID)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ return callIntMethod(_pMethodName,_inout_MethodID,true);
+}
+
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getFetchDirection() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getFetchDirection",mID);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getFetchSize() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getFetchSize",mID);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_Statement_Base::getMaxFieldSize() throw(SQLException, RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return impl_getProperty("getMaxFieldSize",mID);
+}
+//------------------------------------------------------------------------------
+::rtl::OUString java_sql_Statement_Base::getCursorName() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ try
+ {
+ return callStringMethod("getCursorName",mID);
+ }
+ catch(const SQLException&)
+ {
+ }
+ return ::rtl::OUString();
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setQueryTimeOut(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setQueryTimeOut",mID,_par0,true);
+}
+
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setEscapeProcessing(sal_Bool _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_SET_ESCAPE_PROCESSING, _par0 );
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ m_bEscapeProcessing = _par0;
+ createStatement( t.pEnv );
+ static jmethodID mID(NULL);
+ callVoidMethodWithBoolArg("setEscapeProcessing",mID,_par0,true);
+}
+
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setMaxRows(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setMaxRows",mID,_par0,true);
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setResultSetConcurrency(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_CONCURRENCY, (sal_Int32)_par0 );
+ m_nResultSetConcurrency = _par0;
+
+ clearObject();
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setResultSetType(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_RESULT_SET_TYPE, (sal_Int32)_par0 );
+ m_nResultSetType = _par0;
+
+ clearObject();
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setFetchDirection(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_DIRECTION, (sal_Int32)_par0 );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true);
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setFetchSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINER, STR_LOG_FETCH_SIZE, (sal_Int32)_par0 );
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchSize",mID,_par0,true);
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setMaxFieldSize(sal_Int32 _par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setMaxFieldSize",mID,_par0,true);
+}
+//------------------------------------------------------------------------------
+void java_sql_Statement_Base::setCursorName(const ::rtl::OUString &_par0) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethodWithStringArg("setCursorName",mID,_par0);
+ } //t.pEnv
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* java_sql_Statement_Base::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(10);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & java_sql_Statement_Base::getInfoHelper()
+
+{
+ return *const_cast<java_sql_Statement_Base*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_Statement_Base::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
+ case PROPERTY_ID_MAXFIELDSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
+ case PROPERTY_ID_MAXROWS:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows());
+ case PROPERTY_ID_CURSORNAME:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
+ case PROPERTY_ID_RESULTSETTYPE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
+ case PROPERTY_ID_FETCHDIRECTION:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ case PROPERTY_ID_FETCHSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bEscapeProcessing );
+ case PROPERTY_ID_USEBOOKMARKS:
+ // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void java_sql_Statement_Base::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& rValue
+ )
+ throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ setQueryTimeOut(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ setMaxFieldSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXROWS:
+ setMaxRows(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ setCursorName(comphelper::getString(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ setResultSetConcurrency(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ setResultSetType(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ setEscapeProcessing( ::comphelper::getBOOL( rValue ) );
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ // return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, m_bAsLink);
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void java_sql_Statement_Base::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ java_sql_Statement_Base* THIS = const_cast<java_sql_Statement_Base*>(this);
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ rValue <<= THIS->getQueryTimeOut();
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ rValue <<= THIS->getMaxFieldSize();
+ break;
+ case PROPERTY_ID_MAXROWS:
+ rValue <<= THIS->getMaxRows();
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= THIS->getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= THIS->getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= THIS->getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= THIS->getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= THIS->getFetchSize();
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ rValue <<= (sal_Bool)m_bEscapeProcessing;
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+ }
+ catch(const Exception&)
+ {
+ }
+}
+// -------------------------------------------------------------------------
+jclass java_sql_Statement::theClass = 0;
+
+java_sql_Statement::~java_sql_Statement()
+{}
+
+jclass java_sql_Statement::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Statement");
+ return theClass;
+}
+
+// -----------------------------------------------------------------------------
+void java_sql_Statement::createStatement(JNIEnv* _pEnv)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ if( _pEnv && !object ){
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(II)Ljava/sql/Statement;";
+ static const char * cMethodName = "createStatement";
+ // Java-Call absetzen
+ jobject out = NULL;
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+ if( mID ){
+ out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID,m_nResultSetType,m_nResultSetConcurrency );
+ } //mID
+ else
+ {
+ static const char * cSignature2 = "()Ljava/sql/Statement;";
+ static jmethodID mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID2,"Unknown method id!");
+ if( mID2 ){
+ out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2);
+ } //mID
+ }
+ ThrowLoggedSQLException( m_aLogger, _pEnv, *this );
+
+ if ( out )
+ object = _pEnv->NewGlobalRef( out );
+ } //_pEnv
+}
+// -----------------------------------------------------------------------------
+
+
+IMPLEMENT_SERVICE_INFO(java_sql_Statement,"com.sun.star.sdbcx.JStatement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement_Base::acquire() throw()
+{
+ java_sql_Statement_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement_Base::release() throw()
+{
+ java_sql_Statement_BASE::release();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_Statement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL java_sql_Statement_Base::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/Object.cxx b/connectivity/source/drivers/jdbc/Object.cxx
new file mode 100644
index 000000000000..4866781d23dd
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Object.cxx
@@ -0,0 +1,437 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#ifndef _CONNECTIVITY_JAVA_LANG_OBJJECT_HXX_
+#include "java/lang/Class.hxx"
+#endif
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/uno/Exception.hpp>
+#include "java/tools.hxx"
+#include "java/sql/SQLException.hxx"
+#include <vos/process.hxx>
+#include <vos/mutex.hxx>
+#include <osl/thread.h>
+#include <com/sun/star/uno/Sequence.hxx>
+#include "java/LocalRef.hxx"
+#include "resource/jdbc_log.hrc"
+#include <rtl/logfile.hxx>
+#include <comphelper/logging.hxx>
+
+#include <memory>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+
+// -----------------------------------------------------------------------------
+::rtl::Reference< jvmaccess::VirtualMachine > getJavaVM2(const ::rtl::Reference< jvmaccess::VirtualMachine >& _rVM = ::rtl::Reference< jvmaccess::VirtualMachine >(),
+ sal_Bool _bSet = sal_False)
+{
+ static ::rtl::Reference< jvmaccess::VirtualMachine > s_VM;
+ if ( _rVM.is() || _bSet )
+ s_VM = _rVM;
+ return s_VM;
+}
+// -----------------------------------------------------------------------------
+::rtl::Reference< jvmaccess::VirtualMachine > java_lang_Object::getVM(const Reference<XMultiServiceFactory >& _rxFactory)
+{
+ ::rtl::Reference< jvmaccess::VirtualMachine > xVM = getJavaVM2();
+ if ( !xVM.is() && _rxFactory.is() )
+ xVM = getJavaVM2(::connectivity::getJavaVM(_rxFactory));
+
+ return xVM;
+}
+// -----------------------------------------------------------------------------
+SDBThreadAttach::SDBThreadAttach()
+ : m_aGuard(java_lang_Object::getVM())
+ , pEnv(NULL)
+{
+ pEnv = m_aGuard.getEnvironment();
+ OSL_ENSURE(pEnv,"Environment is nULL!");
+}
+// -----------------------------------------------------------------------------
+SDBThreadAttach::~SDBThreadAttach()
+{
+}
+// -----------------------------------------------------------------------------
+oslInterlockedCount& getJavaVMRefCount()
+{
+ static oslInterlockedCount s_nRefCount = 0;
+ return s_nRefCount;
+}
+// -----------------------------------------------------------------------------
+void SDBThreadAttach::addRef()
+{
+ osl_incrementInterlockedCount(&getJavaVMRefCount());
+}
+// -----------------------------------------------------------------------------
+void SDBThreadAttach::releaseRef()
+{
+ osl_decrementInterlockedCount(&getJavaVMRefCount());
+ if ( getJavaVMRefCount() == 0 )
+ {
+ getJavaVM2(::rtl::Reference< jvmaccess::VirtualMachine >(),sal_True);
+ }
+}
+// -----------------------------------------------------------------------------
+// statische Variablen der Klasse:
+jclass java_lang_Object::theClass = 0;
+
+jclass java_lang_Object::getMyClass() const
+{
+ if( !theClass )
+ theClass = findMyClass("java/lang/Object");
+ return theClass;
+}
+// der eigentliche Konstruktor
+java_lang_Object::java_lang_Object(const Reference<XMultiServiceFactory >& _rxFactory)
+ : m_xFactory(_rxFactory),object( 0 )
+{
+ SDBThreadAttach::addRef();
+}
+
+// der protected-Konstruktor fuer abgeleitete Klassen
+java_lang_Object::java_lang_Object( JNIEnv * pXEnv, jobject myObj )
+ : object( NULL )
+{
+ SDBThreadAttach::addRef();
+ if( pXEnv && myObj )
+ object = pXEnv->NewGlobalRef( myObj );
+}
+
+java_lang_Object::~java_lang_Object()
+{
+ if( object )
+ {
+ SDBThreadAttach t;
+ clearObject(*t.pEnv);
+ }
+ SDBThreadAttach::releaseRef();
+}
+void java_lang_Object::clearObject(JNIEnv& rEnv)
+{
+ if( object )
+ {
+ rEnv.DeleteGlobalRef( object );
+ object = NULL;
+ }
+}
+
+void java_lang_Object::clearObject()
+{
+ if( object )
+ {
+ SDBThreadAttach t;
+ clearObject(*t.pEnv);
+ }
+}
+// der protected-Konstruktor fuer abgeleitete Klassen
+void java_lang_Object::saveRef( JNIEnv * pXEnv, jobject myObj )
+{
+ OSL_ENSURE( myObj, "object in c++ -> Java Wrapper" );
+ if( myObj )
+ object = pXEnv->NewGlobalRef( myObj );
+}
+
+
+java_lang_Class * java_lang_Object::getClass()
+{
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getClass","()Ljava/lang/Class;", mID);
+ return out ? new java_lang_Class( t.pEnv, out ) : NULL;
+}
+
+::rtl::OUString java_lang_Object::toString() const
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("toString",mID);
+}
+
+// --------------------------------------------------------------------------------
+namespace
+{
+ bool lcl_translateJNIExceptionToUNOException(
+ JNIEnv* _pEnvironment, const Reference< XInterface >& _rxContext, SQLException& _out_rException )
+ {
+ jthrowable jThrow = _pEnvironment ? _pEnvironment->ExceptionOccurred() : NULL;
+ if ( !jThrow )
+ return false;
+
+ _pEnvironment->ExceptionClear();
+ // we have to clear the exception here because we want to handle it itself
+
+ if ( _pEnvironment->IsInstanceOf( jThrow, java_sql_SQLException_BASE::st_getMyClass() ) )
+ {
+ ::std::auto_ptr< java_sql_SQLException_BASE > pException( new java_sql_SQLException_BASE( _pEnvironment, jThrow ) );
+ _out_rException = SQLException( pException->getMessage(), _rxContext,
+ pException->getSQLState(), pException->getErrorCode(), Any() );
+ return true;
+ }
+ else if ( _pEnvironment->IsInstanceOf( jThrow, java_lang_Throwable::st_getMyClass() ) )
+ {
+ ::std::auto_ptr< java_lang_Throwable > pThrow( new java_lang_Throwable( _pEnvironment, jThrow ) );
+ ::rtl::OUString sMessage = pThrow->getMessage();
+ if ( !sMessage.getLength() )
+ sMessage = pThrow->getLocalizedMessage();
+ if( !sMessage.getLength() )
+ sMessage = pThrow->toString();
+ _out_rException = SQLException( sMessage, _rxContext, ::rtl::OUString(), -1, Any() );
+ return true;
+ }
+ else
+ _pEnvironment->DeleteLocalRef( jThrow );
+ return false;
+ }
+}
+
+// --------------------------------------------------------------------------------
+void java_lang_Object::ThrowLoggedSQLException( const ::comphelper::ResourceBasedEventLogger& _rLogger, JNIEnv* _pEnvironment,
+ const Reference< XInterface >& _rxContext )
+{
+ SQLException aException;
+ if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) )
+ {
+ _rLogger.log( ::com::sun::star::logging::LogLevel::SEVERE, STR_LOG_THROWING_EXCEPTION, aException.Message, aException.SQLState, aException.ErrorCode );
+ throw aException;
+ }
+}
+
+// --------------------------------------------------------------------------------
+void java_lang_Object::ThrowSQLException( JNIEnv* _pEnvironment, const Reference< XInterface>& _rxContext )
+{
+ SQLException aException;
+ if ( lcl_translateJNIExceptionToUNOException( _pEnvironment, _rxContext, aException ) )
+ throw aException;
+}
+// -----------------------------------------------------------------------------
+void java_lang_Object::obtainMethodId(JNIEnv* _pEnv,const char* _pMethodName, const char* _pSignature,jmethodID& _inout_MethodID) const
+{
+ if ( !_inout_MethodID )
+ {
+ _inout_MethodID = _pEnv->GetMethodID( getMyClass(), _pMethodName, _pSignature );
+ OSL_ENSURE( _inout_MethodID, _pSignature );
+ if ( !_inout_MethodID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+}
+// -----------------------------------------------------------------------------
+sal_Bool java_lang_Object::callBooleanMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ jboolean out( sal_False );
+
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()Z", _inout_MethodID);
+ // call method
+ out = t.pEnv->CallBooleanMethod( object, _inout_MethodID );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return out;
+}
+// -----------------------------------------------------------------------------
+sal_Bool java_lang_Object::callBooleanMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument ) const
+{
+ jboolean out( sal_False );
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callBooleanMethodWithIntArg: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)Z", _inout_MethodID);
+ // call method
+ out = t.pEnv->CallBooleanMethod( object, _inout_MethodID, _nArgument );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return out;
+}
+// -------------------------------------------------------------------------
+jobject java_lang_Object::callResultSetMethod( JNIEnv& _rEnv,const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ // call method
+ jobject out = callObjectMethod(&_rEnv,_pMethodName,"()Ljava/sql/ResultSet;", _inout_MethodID);
+ return out;
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethod( const char* _pMethodName, jmethodID& _inout_MethodID,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()I", _inout_MethodID);
+
+ // call method
+ jint out( t.pEnv->CallIntMethod( object, _inout_MethodID ) );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+
+ return (sal_Int32)out;
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID,sal_Int32 _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)I", _inout_MethodID);
+ // call method
+ jint out( t.pEnv->CallIntMethod( object, _inout_MethodID , _nArgument) );
+ ThrowSQLException( t.pEnv, NULL );
+
+ return (sal_Int32)out;
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethod( const char* _pMethodName, jmethodID& _inout_MethodID) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"()V", _inout_MethodID);
+
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID );
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(I)V", _inout_MethodID);
+
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithBoolArg( const char* _pMethodName, jmethodID& _inout_MethodID, sal_Int32 _nArgument,bool _bIgnoreException ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Z)V", _inout_MethodID);
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID,_nArgument );
+ if ( _bIgnoreException )
+ isExceptionOccured(t.pEnv,sal_True);
+ else
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_lang_Object::callStringMethod( const char* _pMethodName, jmethodID& _inout_MethodID ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" );
+
+ // call method
+ jstring out = (jstring)callObjectMethod(t.pEnv,_pMethodName,"()Ljava/lang/String;", _inout_MethodID);
+ return JavaString2String( t.pEnv, out );
+}
+// -----------------------------------------------------------------------------
+jobject java_lang_Object::callObjectMethod( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID ) const
+{
+ // obtain method ID
+ obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ // call method
+ jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID);
+ ThrowSQLException( _pEnv, NULL );
+ return out;
+}
+
+// -----------------------------------------------------------------------------
+jobject java_lang_Object::callObjectMethodWithIntArg( JNIEnv * _pEnv,const char* _pMethodName,const char* _pSignature, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
+{
+ obtainMethodId(_pEnv, _pMethodName,_pSignature, _inout_MethodID);
+ // call method
+ jobject out = _pEnv->CallObjectMethod( object, _inout_MethodID,_nArgument );
+ ThrowSQLException( _pEnv, NULL );
+ return out;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString java_lang_Object::callStringMethodWithIntArg( const char* _pMethodName, jmethodID& _inout_MethodID , sal_Int32 _nArgument) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callStringMethod: no Java enviroment anymore!" );
+ jstring out = (jstring)callObjectMethodWithIntArg(t.pEnv,_pMethodName,"(I)Ljava/lang/String;",_inout_MethodID,_nArgument);
+ return JavaString2String( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+void java_lang_Object::callVoidMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethod: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)V", _inout_MethodID);
+
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
+ // call method
+ t.pEnv->CallVoidMethod( object, _inout_MethodID , str.get());
+ ThrowSQLException( t.pEnv, NULL );
+}
+// -------------------------------------------------------------------------
+sal_Int32 java_lang_Object::callIntMethodWithStringArg( const char* _pMethodName, jmethodID& _inout_MethodID,const ::rtl::OUString& _nArgument ) const
+{
+ SDBThreadAttach t;
+ OSL_ENSURE( t.pEnv, "java_lang_Object::callIntMethodWithStringArg: no Java enviroment anymore!" );
+ obtainMethodId(t.pEnv, _pMethodName,"(Ljava/lang/String;)I", _inout_MethodID);
+
+ //TODO: Check if the code below is needed
+ //jdbc::LocalRef< jstring > str( t.env(), convertwchar_tToJavaString( t.pEnv, sql ) );
+ //{
+ // jdbc::ContextClassLoaderScope ccl( t.env(),
+ // m_pConnection ? m_pConnection->getDriverClassLoader() : jdbc::GlobalRef< jobject >(),
+ // m_aLogger,
+ // *this
+ // );
+
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,_nArgument));
+ // call method
+ jint out = t.pEnv->CallIntMethod( object, _inout_MethodID , str.get());
+ ThrowSQLException( t.pEnv, NULL );
+ return (sal_Int32)out;
+}
+// -----------------------------------------------------------------------------
+jclass java_lang_Object::findMyClass(const char* _pClassName)
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ SDBThreadAttach t;
+ jclass tempClass = t.pEnv->FindClass(_pClassName); OSL_ENSURE(tempClass,"Java : FindClass nicht erfolgreich!");
+ if(!tempClass)
+ {
+ t.pEnv->ExceptionDescribe();
+ t.pEnv->ExceptionClear();
+ }
+ jclass globClass = (jclass)t.pEnv->NewGlobalRef( tempClass );
+ t.pEnv->DeleteLocalRef( tempClass );
+ return globClass;
+}
+
diff --git a/connectivity/source/drivers/jdbc/PreparedStatement.cxx b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
new file mode 100644
index 000000000000..55abc30e9e26
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/PreparedStatement.cxx
@@ -0,0 +1,666 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/PreparedStatement.hxx"
+#include "java/sql/ResultSet.hxx"
+#include "java/sql/ResultSetMetaData.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/sql/Timestamp.hxx"
+#include "java/math/BigDecimal.hxx"
+#include "java/tools.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/FValue.hxx"
+#include "connectivity/dbexception.hxx"
+#include "resource/jdbc_log.hrc"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include "java/LocalRef.hxx"
+#include <string.h>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+//**************************************************************
+//************ Class: java.sql.PreparedStatement
+//**************************************************************
+IMPLEMENT_SERVICE_INFO(java_sql_PreparedStatement,"com.sun.star.sdbcx.JPreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+java_sql_PreparedStatement::java_sql_PreparedStatement( JNIEnv * pEnv, java_sql_Connection& _rCon, const ::rtl::OUString& sql )
+ : OStatement_BASE2( pEnv, _rCon )
+{
+ m_sSqlStatement = sql;
+}
+// -----------------------------------------------------------------------------
+jclass java_sql_PreparedStatement::theClass = 0;
+
+java_sql_PreparedStatement::~java_sql_PreparedStatement()
+{
+}
+// -----------------------------------------------------------------------------
+
+jclass java_sql_PreparedStatement::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/PreparedStatement");
+ return theClass;
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::uno::Any SAL_CALL java_sql_PreparedStatement::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::com::sun::star::uno::Any aRet = OStatement_BASE2::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ::cppu::queryInterface( rType,
+ static_cast< XPreparedStatement*>(this),
+ static_cast< XParameters*>(this),
+ static_cast< XResultSetMetaDataSupplier*>(this),
+ static_cast< XPreparedBatchExecution*>(this));
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_PreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedStatement > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XParameters > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XResultSetMetaDataSupplier > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< XPreparedBatchExecution > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OStatement_BASE2::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_PreparedStatement::execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "execute", mID );
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_PreparedStatement::executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_UPDATE );
+ static jmethodID mID(NULL);
+ return callIntMethod("executeUpdate",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ m_aLogger.log( LogLevel::FINER, STR_LOG_STRING_PARAMETER, parameterIndex, x );
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ { // temporaere Variable initialisieren
+ createStatement(t.pEnv);
+ static const char * cSignature = "(ILjava/lang/String;)V";
+ static const char * cMethodName = "setString";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x));
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,str.get());
+ // und aufraeumen
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL java_sql_PreparedStatement::getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL java_sql_PreparedStatement::executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINE, STR_LOG_EXECUTING_PREPARED_QUERY );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callResultSetMethod(t.env(),"executeQuery",mID);
+
+ return out==0 ? 0 : new java_sql_ResultSet( t.pEnv, out, m_aLogger, *m_pConnection,this);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_BOOLEAN_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setBoolean", "(IZ)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_BYTE_PARAMETER, parameterIndex, (sal_Int32)x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setByte", "(IB)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_DATE_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ java_sql_Date aT(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("setDate", "(ILjava/sql/Date;)V", mID, parameterIndex, aT.getJavaObject());
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL java_sql_PreparedStatement::setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_TIME_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ java_sql_Time aT(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("setTime", "(ILjava/sql/Time;)V", mID, parameterIndex, aT.getJavaObject());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_TIMESTAMP_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ java_sql_Timestamp aD(x);
+ callVoidMethod("setTimestamp", "(ILjava/sql/Timestamp;)V", mID, parameterIndex, aD.getJavaObject());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_PreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_DOUBLE_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setDouble", "(ID)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_FLOAT_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setFloat", "(IF)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_INT_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setInt", "(II)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_LONG_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setLong", "(IJ)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_NULL_PARAMETER, parameterIndex, sqlType );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setNull", "(II)V", mID, parameterIndex, sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& /*x*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(ILjava/lang/Object;II)V";
+ static const char * cMethodName = "setObject";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ {
+ jobject obj = NULL;
+ double nTemp = 0.0;
+ switch(targetSqlType)
+ {
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ {
+ ::std::auto_ptr<java_math_BigDecimal> pBigDecimal;
+ if ( x >>= nTemp)
+ {
+ pBigDecimal.reset(new java_math_BigDecimal(nTemp));
+ //setDouble(parameterIndex,nTemp);
+ //return;
+ }
+ else
+ {
+ ORowSetValue aValue;
+ aValue.fill(x);
+ const ::rtl::OUString sValue = aValue;
+ if ( sValue.getLength() )
+ pBigDecimal.reset(new java_math_BigDecimal(sValue));
+ else
+ pBigDecimal.reset(new java_math_BigDecimal(0.0));
+ }
+ //obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x));
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,pBigDecimal->getJavaObject(),targetSqlType,scale);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ return;
+ }
+ default:
+ obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x));
+ break;
+ }
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,obj,targetSqlType,scale);
+ t.pEnv->DeleteLocalRef(obj);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ // und aufraeumen
+ } //mID
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/, const ::rtl::OUString& /*typeName*/ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_OBJECT_NULL_PARAMETER, parameterIndex );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod<jobject>("setObject", "(ILjava/lang/Object;)V", mID, parameterIndex, NULL);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_SHORT_PARAMETER, parameterIndex, x );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("setShort", "(IS)V", mID, parameterIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_BYTES_PARAMETER, parameterIndex );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(I[B)V";
+ static const char * cMethodName = "setBytes";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ jbyteArray pByteArray = t.pEnv->NewByteArray(x.getLength());
+ t.pEnv->SetByteArrayRegion(pByteArray,0,x.getLength(),(jbyte*)x.getConstArray());
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,pByteArray);
+ t.pEnv->DeleteLocalRef(pByteArray);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_CHARSTREAM_PARAMETER, parameterIndex );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(ILjava/io/InputStream;I)V";
+ static const char * cMethodName = "setCharacterStream";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ Sequence< sal_Int8 > aSeq;
+ if ( x.is() )
+ x->readBytes( aSeq, length );
+ sal_Int32 actualLength = aSeq.getLength();
+
+ jvalue args2[3];
+ jbyteArray pByteArray = t.pEnv->NewByteArray( actualLength );
+ t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
+ args2[0].l = pByteArray;
+ args2[1].i = 0;
+ args2[2].i = actualLength;
+ // temporaere Variable initialisieren
+ const char * cSignatureStream = "([BII)V";
+ // Java-Call absetzen
+ jclass aClass = t.pEnv->FindClass("java/io/CharArrayInputStream");
+ static jmethodID mID2 = NULL;
+ if ( !mID2 )
+ mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
+ jobject tempObj = NULL;
+ if(mID2)
+ tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
+
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,actualLength);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(pByteArray);
+ t.pEnv->DeleteLocalRef(tempObj);
+ t.pEnv->DeleteLocalRef(aClass);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_BINARYSTREAM_PARAMETER, parameterIndex );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(ILjava/io/InputStream;I)V";
+ static const char * cMethodName = "setBinaryStream";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ {
+ Sequence< sal_Int8 > aSeq;
+ if ( x.is() )
+ x->readBytes( aSeq, length );
+ sal_Int32 actualLength = aSeq.getLength();
+
+ jvalue args2[3];
+ jbyteArray pByteArray = t.pEnv->NewByteArray(actualLength);
+ t.pEnv->SetByteArrayRegion(pByteArray,0,actualLength,(jbyte*)aSeq.getConstArray());
+ args2[0].l = pByteArray;
+ args2[1].i = 0;
+ args2[2].i = (sal_Int32)actualLength;
+
+ // temporaere Variable initialisieren
+ const char * cSignatureStream = "([BII)V";
+ // Java-Call absetzen
+ jclass aClass = t.pEnv->FindClass("java/io/ByteArrayInputStream");
+ static jmethodID mID2 = NULL;
+ if ( !mID2 )
+ mID2 = t.pEnv->GetMethodID( aClass, "<init>", cSignatureStream );
+ jobject tempObj = NULL;
+ if(mID2)
+ tempObj = t.pEnv->NewObjectA( aClass, mID2, args2 );
+ t.pEnv->CallVoidMethod( object, mID, parameterIndex,tempObj,(sal_Int32)actualLength);
+ // und aufraeumen
+ t.pEnv->DeleteLocalRef(pByteArray);
+ t.pEnv->DeleteLocalRef(tempObj);
+ t.pEnv->DeleteLocalRef(aClass);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ m_aLogger.log( LogLevel::FINER, STR_LOG_CLEAR_PARAMETERS );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ SDBThreadAttach t;
+ {
+ createStatement(t.pEnv);
+
+ static jmethodID mID(NULL);
+ callVoidMethod("clearParameters",mID);
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_PreparedStatement::clearBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("clearBatch",mID);
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_PreparedStatement::addBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ callVoidMethod("addBatch",mID);
+ } //t.pEnv
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL java_sql_PreparedStatement::executeBatch( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ ::com::sun::star::uno::Sequence< sal_Int32 > aSeq;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jintArray out = (jintArray)callObjectMethod(t.pEnv,"executeBatch","()[I", mID);
+ if(out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetIntArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
+ return aSeq;
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_PreparedStatement::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ createStatement(t.pEnv);
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID);
+
+ return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection );
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_PreparedStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_PreparedStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+void java_sql_PreparedStatement::createStatement(JNIEnv* _pEnv)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(java_sql_Statement_BASE::rBHelper.bDisposed);
+
+ if( !object && _pEnv ){
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;II)Ljava/sql/PreparedStatement;";
+ static const char * cMethodName = "prepareStatement";
+
+ jvalue args[1];
+ // Parameter konvertieren
+ args[0].l = convertwchar_tToJavaString(_pEnv,m_sSqlStatement);
+ // Java-Call absetzen
+ jobject out = NULL;
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature );
+ if( mID )
+ {
+ out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID, args[0].l ,m_nResultSetType,m_nResultSetConcurrency);
+ }
+ else
+ {
+ static const char * cSignature2 = "(Ljava/lang/String;)Ljava/sql/PreparedStatement;";
+ static jmethodID mID2 = NULL;
+ if ( !mID2)
+ mID2 = _pEnv->GetMethodID( m_pConnection->getMyClass(), cMethodName, cSignature2 );OSL_ENSURE(mID,"Unknown method id!");
+ if ( mID2 )
+ out = _pEnv->CallObjectMethod( m_pConnection->getJavaObject(), mID2, args[0].l );
+ }
+ _pEnv->DeleteLocalRef((jstring)args[0].l);
+ ThrowLoggedSQLException( m_aLogger, _pEnv, *this );
+ if ( out )
+ object = _pEnv->NewGlobalRef( out );
+ } //t.pEnv
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/jdbc/Reader.cxx b/connectivity/source/drivers/jdbc/Reader.cxx
new file mode 100644
index 000000000000..4224929332fa
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Reader.cxx
@@ -0,0 +1,121 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/io/Reader.hxx"
+#ifndef _INC_MEMORY
+//#include <memory.h>
+#endif
+#include <string.h>
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.io.Reader
+//**************************************************************
+
+jclass java_io_Reader::theClass = 0;
+java_io_Reader::java_io_Reader( JNIEnv * pEnv, jobject myObj )
+ : java_lang_Object( pEnv, myObj )
+{
+ SDBThreadAttach::addRef();
+}
+java_io_Reader::~java_io_Reader()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_io_Reader::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/io/Reader");
+ return theClass;
+}
+
+sal_Int32 SAL_CALL java_io_Reader::readSomeBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nMaxBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ return readBytes(aData,nMaxBytesToRead);
+}
+
+void SAL_CALL java_io_Reader::skipBytes( sal_Int32 nBytesToSkip ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callIntMethodWithIntArg("skip",mID,nBytesToSkip);
+}
+
+sal_Int32 SAL_CALL java_io_Reader::available( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ jboolean out(sal_False);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ static const char * cSignature = "()Z";
+ static const char * cMethodName = "available";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallBooleanMethod( object, mID);
+ ThrowSQLException(t.pEnv,*this);
+ } //t.pEnv
+ return out;
+}
+
+void SAL_CALL java_io_Reader::closeInput( ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+}
+// -----------------------------------------------------
+sal_Int32 SAL_CALL java_io_Reader::readBytes( ::com::sun::star::uno::Sequence< sal_Int8 >& aData, sal_Int32 nBytesToRead ) throw(::com::sun::star::io::NotConnectedException, ::com::sun::star::io::BufferSizeExceededException, ::com::sun::star::io::IOException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_ENSURE(aData.getLength() < nBytesToRead," Sequence is smaller than BytesToRead");
+ jint out(0);
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+
+ {
+ jcharArray pCharArray = t.pEnv->NewCharArray(nBytesToRead);
+ static const char * cSignature = "([CII)I";
+ static const char * cMethodName = "read";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallIntMethod( object, mID, pCharArray, 0, nBytesToRead );
+ if ( !out )
+ ThrowSQLException(t.pEnv,*this);
+ if(out > 0)
+ {
+ jboolean p = sal_False;
+ if(aData.getLength() < out)
+ aData.realloc(out-aData.getLength());
+
+ memcpy(aData.getArray(),t.pEnv->GetCharArrayElements(pCharArray,&p),out);
+ }
+ t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
+ } //t.pEnv
+ return out;
+}
+
diff --git a/connectivity/source/drivers/jdbc/Ref.cxx b/connectivity/source/drivers/jdbc/Ref.cxx
new file mode 100644
index 000000000000..eb9fc1e53880
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Ref.cxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Ref.hxx"
+#include "java/tools.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.Ref
+//**************************************************************
+
+jclass java_sql_Ref::theClass = 0;
+java_sql_Ref::java_sql_Ref( JNIEnv * pEnv, jobject myObj )
+: java_lang_Object( pEnv, myObj )
+{
+ SDBThreadAttach::addRef();
+}
+java_sql_Ref::~java_sql_Ref()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_sql_Ref::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Ref");
+ return theClass;
+}
+
+::rtl::OUString SAL_CALL java_sql_Ref::getBaseTypeName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("getBaseTypeName",mID);
+}
+
diff --git a/connectivity/source/drivers/jdbc/ResultSet.cxx b/connectivity/source/drivers/jdbc/ResultSet.cxx
new file mode 100644
index 000000000000..2dc9760169f8
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/ResultSet.cxx
@@ -0,0 +1,1087 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/String.hxx"
+#include "java/lang/Boolean.hxx"
+#include "java/sql/ResultSet.hxx"
+#include "java/math/BigDecimal.hxx"
+#include "java/sql/JStatement.hxx"
+#include "java/sql/SQLWarning.hxx"
+#include "java/sql/Timestamp.hxx"
+#include "java/sql/Array.hxx"
+#include "java/sql/Ref.hxx"
+#include "java/sql/Clob.hxx"
+#include "java/sql/Timestamp.hxx"
+#include "java/sql/Blob.hxx"
+#include "java/sql/ResultSetMetaData.hxx"
+#include "java/io/InputStream.hxx"
+#include "java/io/Reader.hxx"
+#include "java/tools.hxx"
+#include <comphelper/property.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include "TConnection.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+#include "java/LocalRef.hxx"
+
+#include <rtl/logfile.hxx>
+#include <string.h>
+
+using namespace ::comphelper;
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+IMPLEMENT_SERVICE_INFO(java_sql_ResultSet,"com.sun.star.sdbcx.JResultSet","com.sun.star.sdbc.ResultSet");
+//**************************************************************
+//************ Class: java.sql.ResultSet
+//**************************************************************
+
+jclass java_sql_ResultSet::theClass = 0;
+java_sql_ResultSet::java_sql_ResultSet( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rParentLogger,java_sql_Connection& _rConnection, java_sql_Statement_Base* pStmt)
+ :java_sql_ResultSet_BASE(m_aMutex)
+ ,java_lang_Object( pEnv, myObj )
+ ,OPropertySetHelper(java_sql_ResultSet_BASE::rBHelper)
+ ,m_aLogger( _rParentLogger, java::sql::ConnectionLog::RESULTSET )
+ ,m_pConnection(&_rConnection)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::java_sql_ResultSet" );
+ SDBThreadAttach::addRef();
+ osl_incrementInterlockedCount(&m_refCount);
+ if ( pStmt )
+ m_xStatement = *pStmt;
+
+ osl_decrementInterlockedCount(&m_refCount);
+}
+// -----------------------------------------------------------------------------
+java_sql_ResultSet::~java_sql_ResultSet()
+{
+ if ( !java_sql_ResultSet_BASE::rBHelper.bDisposed && !java_sql_ResultSet_BASE::rBHelper.bInDispose )
+ {
+ // increment ref count to prevent double call of Dtor
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+}
+
+jclass java_sql_ResultSet::getMyClass() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMyClass" );
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/ResultSet");
+ return theClass;
+}
+
+// -------------------------------------------------------------------------
+void java_sql_ResultSet::disposing(void)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::disposing" );
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+m_xMetaData.clear();
+ if( object )
+ {
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ callVoidMethod("close",mID);
+ clearObject(*t.pEnv);
+ }
+
+ SDBThreadAttach::releaseRef();
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::queryInterface" );
+ ::com::sun::star::uno::Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : java_sql_ResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL java_sql_ResultSet::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTypes" );
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),java_sql_ResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSet::findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::findColumn" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithStringArg("findColumn",mID,columnName);
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBinaryStream" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBinaryStream","(I)Ljava/io/InputStream;", mID, columnIndex);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_io_InputStream( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL java_sql_ResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCharacterStream" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getCharacterStream","(I)Ljava/io/Reader;", mID, columnIndex);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_io_Reader( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBoolean" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "getBoolean", mID,columnIndex );
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL java_sql_ResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getByte" );
+ static jmethodID mID(NULL);
+ jbyte (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallByteMethod;
+ return callMethodWithIntArg<jbyte>(pCallMethod,"getByte","(I)B",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL java_sql_ResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBytes" );
+ Sequence< sal_Int8 > aSeq;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jbyteArray out = (jbyteArray)callObjectMethodWithIntArg(t.pEnv,"getBytes","(I)[B", mID, columnIndex);
+ if (out)
+ {
+ jboolean p = sal_False;
+ aSeq.realloc(t.pEnv->GetArrayLength(out));
+ memcpy(aSeq.getArray(),t.pEnv->GetByteArrayElements(out,&p),aSeq.getLength());
+ t.pEnv->DeleteLocalRef(out);
+ }
+ return aSeq;
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL java_sql_ResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDate" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getDate","(I)Ljava/sql/Date;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out ? static_cast <com::sun::star::util::Date> (java_sql_Date( t.pEnv, out )) : ::com::sun::star::util::Date();
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL java_sql_ResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getDouble" );
+ static jmethodID mID(NULL);
+ jdouble (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallDoubleMethod;
+ return callMethodWithIntArg<double>(pCallMethod,"getDouble","(I)D",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL java_sql_ResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFloat" );
+ static jmethodID mID(NULL);
+ jfloat (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallFloatMethod;
+ return callMethodWithIntArg<jfloat>(pCallMethod,"getFloat","(I)F",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInt" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getInt",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRow" );
+ static jmethodID mID(NULL);
+ return callIntMethod("getRow",mID);
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL java_sql_ResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getLong" );
+ static jmethodID mID(NULL);
+ jlong (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallLongMethod;
+ return callMethodWithIntArg<jlong>(pCallMethod,"getLong","(I)J",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL java_sql_ResultSet::getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getMetaData" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getMetaData","()Ljava/sql/ResultSetMetaData;", mID);
+
+ return out==0 ? 0 : new java_sql_ResultSetMetaData( t.pEnv, out, m_aLogger,*m_pConnection );
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL java_sql_ResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getArray" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getArray","(I)Ljava/sql/Array;", mID, columnIndex);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Array( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL java_sql_ResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getClob" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getClob","(I)Ljava/sql/Clob;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Clob( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL java_sql_ResultSet::getBlob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getBlob" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getBlob","(I)Ljava/sql/Blob;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Blob( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL java_sql_ResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getRef" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getRef","(I)Ljava/sql/Ref;", mID, columnIndex);
+
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out==0 ? 0 : new java_sql_Ref( t.pEnv, out );
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL java_sql_ResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getObject" );
+ jobject out(0);
+ Any aRet;
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ {
+ jvalue args[2];
+ // Parameter konvertieren
+ args[0].i = (sal_Int32)columnIndex;
+ args[1].l = convertTypeMapToJavaMap(t.pEnv,typeMap);
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(I)Ljava/lang/Object;";
+ static const char * cMethodName = "getObject";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ out = t.pEnv->CallObjectMethodA( object, mID, args);
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ // und aufraeumen
+ if ( out )
+ {
+ if ( t.pEnv->IsInstanceOf(out,java_lang_String::st_getMyClass()) )
+ {
+ java_lang_String aVal(t.pEnv,out);
+ aRet <<= (::rtl::OUString)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_lang_Boolean::st_getMyClass()) )
+ {
+ java_lang_Boolean aVal(t.pEnv,out);
+ static jmethodID methodID = NULL;
+ aRet <<= aVal.callBooleanMethod("booleanValue",methodID);
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Date::st_getMyClass()) )
+ {
+ java_sql_Date aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::Date)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Time::st_getMyClass()) )
+ {
+ java_sql_Time aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::Time)aVal;
+ }
+ else if ( t.pEnv->IsInstanceOf(out,java_sql_Timestamp::st_getMyClass()) )
+ {
+ java_sql_Timestamp aVal(t.pEnv,out);
+ aRet <<= (::com::sun::star::util::DateTime)aVal;
+ }
+ else
+ t.pEnv->DeleteLocalRef(out);
+ }
+ } //t.pEnv
+ return aRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL java_sql_ResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getShort" );
+ static jmethodID mID(NULL);
+ jshort (JNIEnv::*pCallMethod)( jobject obj, jmethodID methodID, ... ) = &JNIEnv::CallShortMethod;
+ return callMethodWithIntArg<jshort>(pCallMethod,"getShort","(I)S",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+
+::rtl::OUString SAL_CALL java_sql_ResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getString" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getString",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::Time SAL_CALL java_sql_ResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTime" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTime","(I)Ljava/sql/Time;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out ? static_cast <com::sun::star::util::Time> (java_sql_Time( t.pEnv, out )) : ::com::sun::star::util::Time();
+}
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::DateTime SAL_CALL java_sql_ResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getTimestamp" );
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethodWithIntArg(t.pEnv,"getTimestamp","(I)Ljava/sql/Timestamp;", mID, columnIndex);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ return out ? static_cast <com::sun::star::util::DateTime> (java_sql_Timestamp( t.pEnv, out )) : ::com::sun::star::util::DateTime();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isAfterLast" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isAfterLast", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isFirst" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isFirst", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isLast" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isLast", mID );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::beforeFirst" );
+ static jmethodID mID(NULL);
+ callVoidMethod("beforeFirst",mID);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::afterLast" );
+ static jmethodID mID(NULL);
+ callVoidMethod("afterLast",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::close" );
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::first" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "first", mID );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::last" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "last", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::absolute" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "absolute", mID,row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::relative" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "relative", mID,row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::previous" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "previous", mID );
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL java_sql_ResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getStatement" );
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowDeleted" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowDeleted", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowInserted" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowInserted", mID );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::rowUpdated" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "rowUpdated", mID );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::isBeforeFirst" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "isBeforeFirst", mID );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::next" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "next", mID );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::wasNull" );
+ static jmethodID mID(NULL);
+ return callBooleanMethod( "wasNull", mID );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::cancel( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancel" );
+ static jmethodID mID(NULL);
+ callVoidMethod("cancel",mID);
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::clearWarnings" );
+ static jmethodID mID(NULL);
+ callVoidMethod("clearWarnings",mID);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Any SAL_CALL java_sql_ResultSet::getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getWarnings" );
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getWarnings","()Ljava/sql/SQLWarning;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ if( out )
+ {
+ java_sql_SQLWarning_BASE warn_base( t.pEnv, out );
+ return makeAny(
+ static_cast< starsdbc::SQLException >(
+ java_sql_SQLWarning(warn_base,*this)));
+ }
+
+ return ::com::sun::star::uno::Any();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::insertRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("insertRow",mID);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateRow",mID);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::deleteRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("deleteRow",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::cancelRowUpdates" );
+ static jmethodID mID(NULL);
+ callVoidMethod("cancelRowUpdates",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToInsertRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("moveToInsertRow",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::moveToCurrentRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("moveToCurrentRow",mID);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateNull" );
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("updateNull",mID,columnIndex);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBoolean" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateBoolean", "(IZ)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateByte" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateByte", "(IB)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateShort" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateShort", "(IS)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateInt" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateInt", "(II)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateLong" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateLong", "(IJ)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+
+// -----------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateFloat" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateFloat", "(IF)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDouble" );
+ static jmethodID mID(NULL);
+ callVoidMethod("updateDouble", "(ID)V", mID, columnIndex, x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateString" );
+ SDBThreadAttach t;
+
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/lang/String;)V";
+ static const char * cMethodName = "updateString";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ jdbc::LocalRef< jstring > str( t.env(),convertwchar_tToJavaString(t.pEnv,x));
+ t.pEnv->CallVoidMethod( object, mID,columnIndex,str.get());
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBytes" );
+ SDBThreadAttach t;
+
+ {
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(I[B)V";
+ static const char * cMethodName = "updateBytes";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ jbyteArray aArray = t.pEnv->NewByteArray(x.getLength());
+ t.pEnv->SetByteArrayRegion(aArray,0,x.getLength(),(jbyte*)x.getConstArray());
+ // Parameter konvertieren
+ t.pEnv->CallVoidMethod( object, mID,columnIndex,aArray);
+ t.pEnv->DeleteLocalRef(aArray);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateDate" );
+ java_sql_Date aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateDate", "(ILjava/sql/Date;)V", mID, columnIndex, aD.getJavaObject());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTime" );
+ java_sql_Time aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateTime", "(ILjava/sql/Time;)V", mID, columnIndex, aD.getJavaObject());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateTimestamp" );
+ java_sql_Timestamp aD(x);
+ static jmethodID mID(NULL);
+ callVoidMethod("updateTimestamp", "(ILjava/sql/Timestamp;)V", mID, columnIndex, aD.getJavaObject());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateBinaryStream" );
+ try
+ {
+ SDBThreadAttach t;
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/io/InputStream;I)V";
+ static const char * cMethodName = "updateBinaryStream";
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ jobject obj = createByteInputStream(x,length);
+ t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+ }
+ catch(Exception)
+ {
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateBinaryStream", *this );
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateCharacterStream" );
+ try
+ {
+ SDBThreadAttach t;
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/io/Reader;I)V";
+ static const char * cMethodName = "updateCharacterStream";
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ jobject obj = createCharArrayReader(x,length);
+ t.pEnv->CallVoidMethod( object, mID, columnIndex,obj,length);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+ }
+ catch(Exception)
+ {
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateCharacterStream", *this );
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateObject" );
+ if(!::dbtools::implUpdateObject(this,columnIndex,x))
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_UNKNOWN_COLUMN_TYPE,
+ "$position$", ::rtl::OUString::valueOf(columnIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL java_sql_ResultSet::updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::updateNumericObject" );
+ // OSL_ENSURE(0,"java_sql_ResultSet::updateNumericObject: NYI");
+ try
+ {
+ SDBThreadAttach t;
+
+ {
+
+ // temporaere Variable initialisieren
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "(ILjava/lang/Object;I)V";
+ static const char * cMethodName = "updateObject";
+
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ }
+
+ {
+ // Parameter konvertieren
+ double nTemp = 0.0;
+ ::std::auto_ptr<java_math_BigDecimal> pBigDecimal;
+ if ( x >>= nTemp)
+ {
+ pBigDecimal.reset(new java_math_BigDecimal(nTemp));
+ }
+ else
+ pBigDecimal.reset(new java_math_BigDecimal(::comphelper::getString(x)));
+ //obj = convertwchar_tToJavaString(t.pEnv,::comphelper::getString(x));
+ t.pEnv->CallVoidMethod( object, mID, columnIndex,pBigDecimal->getJavaObject(),scale);
+ ThrowLoggedSQLException( m_aLogger, t.pEnv, *this );
+ }
+ }
+ }
+ catch(Exception)
+ {
+ updateObject( columnIndex,x);
+ }
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_ResultSet::getResultSetConcurrency() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetConcurrency" );
+ static jmethodID mID(NULL);
+ return callIntMethod("getConcurrency",mID,true);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_ResultSet::getResultSetType() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getResultSetType" );
+ static jmethodID mID(NULL);
+ return callIntMethod("getType",mID,true);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_ResultSet::getFetchDirection() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchDirection" );
+ static jmethodID mID(NULL);
+ return callIntMethod("getFetchDirection",mID,true);
+}
+//------------------------------------------------------------------------------
+sal_Int32 java_sql_ResultSet::getFetchSize() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFetchSize" );
+ static jmethodID mID(NULL);
+ return callIntMethod("getFetchSize",mID,true);
+}
+//------------------------------------------------------------------------------
+::rtl::OUString java_sql_ResultSet::getCursorName() const throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getCursorName" );
+ static jmethodID mID(NULL);
+ return callStringMethod("getCursorName",mID);
+}
+
+//------------------------------------------------------------------------------
+void java_sql_ResultSet::setFetchDirection(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchDirection" );
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchDirection",mID,_par0,true);
+}
+//------------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::refreshRow" );
+ static jmethodID mID(NULL);
+ callVoidMethod("refreshRow",mID);
+}
+//------------------------------------------------------------------------------
+void java_sql_ResultSet::setFetchSize(sal_Int32 _par0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFetchSize" );
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setFetchSize",mID,_par0,true);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* java_sql_ResultSet::createArrayHelper( ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::createArrayHelper" );
+ Sequence< Property > aProps(5);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & java_sql_ResultSet::getInfoHelper()
+{
+ //RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getInfoHelper" );
+ return *const_cast<java_sql_ResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool java_sql_ResultSet::convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::convertFastPropertyValue" );
+ sal_Bool bRet = sal_False;
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ case PROPERTY_ID_FETCHDIRECTION:
+ bRet = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ bRet = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ default:
+ ;
+ }
+ return bRet;
+}
+
+// -------------------------------------------------------------------------
+void java_sql_ResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::setFastPropertyValue_NoBroadcast" );
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::uno::Exception();
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(comphelper::getINT32(rValue));
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void java_sql_ResultSet::getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getFastPropertyValue" );
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::acquire() throw()
+{
+ java_sql_ResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL java_sql_ResultSet::release() throw()
+{
+ java_sql_ResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL java_sql_ResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSet::getPropertySetInfo" );
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx
new file mode 100644
index 000000000000..c487f3ccab26
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/ResultSetMetaData.cxx
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/ResultSetMetaData.hxx"
+#include "java/sql/Connection.hxx"
+#include "java/tools.hxx"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+#define NULLABLE_UNDEFINED 99
+//**************************************************************
+//************ Class: java.sql.ResultSetMetaData
+//**************************************************************
+
+jclass java_sql_ResultSetMetaData::theClass = 0;
+java_sql_ResultSetMetaData::java_sql_ResultSetMetaData( JNIEnv * pEnv, jobject myObj, const java::sql::ConnectionLog& _rResultSetLogger, java_sql_Connection& _rCon )
+ :java_lang_Object( pEnv, myObj )
+ ,m_aLogger( _rResultSetLogger )
+ ,m_pConnection( &_rCon )
+ ,m_nColumnCount(-1)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::java_sql_ResultSetMetaData" );
+ SDBThreadAttach::addRef();
+}
+java_sql_ResultSetMetaData::~java_sql_ResultSetMetaData()
+{
+ SDBThreadAttach::releaseRef();
+}
+
+jclass java_sql_ResultSetMetaData::getMyClass() const
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getMyClass" );
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/ResultSetMetaData");
+ return theClass;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnDisplaySize" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getColumnDisplaySize",mID,column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnType" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getColumnType",mID,column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnCount" );
+ if ( m_nColumnCount == -1 )
+ {
+ static jmethodID mID(NULL);
+ m_nColumnCount = callIntMethod("getColumnCount",mID);
+ } // if ( m_nColumnCount == -1 )
+ return m_nColumnCount;
+
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCaseSensitive" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isCaseSensitive", mID,column );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getSchemaName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getSchemaName",mID,column);
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnName",mID,column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getTableName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getTableName",mID,column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getCatalogName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getCatalogName",mID,column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnTypeName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnTypeName",mID,column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnLabel" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnLabel",mID,column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL java_sql_ResultSetMetaData::getColumnServiceName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getColumnServiceName" );
+ static jmethodID mID(NULL);
+ return callStringMethodWithIntArg("getColumnClassName",mID,column);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isCurrency" );
+ if ( m_pConnection->isIgnoreCurrencyEnabled() )
+ return sal_False;
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isCurrency", mID,column );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isAutoIncrement" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isAutoIncrement", mID,column );
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSigned" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isSigned", mID,column );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getPrecision" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getPrecision",mID,column);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::getScale" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("getScale",mID,column);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL java_sql_ResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isNullable" );
+ static jmethodID mID(NULL);
+ return callIntMethodWithIntArg("isNullable",mID,column);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isSearchable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isSearchable", mID,column );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isReadOnly" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isReadOnly", mID,column );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isDefinitelyWritable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isDefinitelyWritable", mID,column );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL java_sql_ResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "jdbc", "Ocke.Janssen@sun.com", "java_sql_ResultSetMetaData::isWritable" );
+ static jmethodID mID(NULL);
+ return callBooleanMethodWithIntArg( "isWritable", mID,column );
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/jdbc/SQLException.cxx b/connectivity/source/drivers/jdbc/SQLException.cxx
new file mode 100644
index 000000000000..25a1d5b06024
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/SQLException.cxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/SQLException.hxx"
+#include "java/tools.hxx"
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+//**************************************************************
+//************ Class: java.sql.SQLException
+//**************************************************************
+java_sql_SQLException::java_sql_SQLException( const java_sql_SQLException_BASE& _rException,const Reference< XInterface> & _rContext)
+ : starsdbc::SQLException( _rException.getMessage(),
+ _rContext,
+ _rException.getSQLState(),
+ _rException.getErrorCode(),
+ makeAny(_rException.getNextException())
+ )
+{
+}
+
+java_sql_SQLException_BASE::java_sql_SQLException_BASE( JNIEnv * pEnv, jobject myObj ) : java_lang_Exception( pEnv, myObj )
+{
+}
+
+jclass java_sql_SQLException_BASE::theClass = 0;
+
+java_sql_SQLException_BASE::~java_sql_SQLException_BASE()
+{}
+
+
+jclass java_sql_SQLException_BASE::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_sql_SQLException_BASE::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/SQLException");
+ return theClass;
+}
+
+starsdbc::SQLException java_sql_SQLException_BASE::getNextException() const
+{
+ SDBThreadAttach t;
+ static jmethodID mID(NULL);
+ jobject out = callObjectMethod(t.pEnv,"getNextException","()Ljava/sql/SQLException;", mID);
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+ if( out )
+ {
+ java_sql_SQLException_BASE warn_base(t.pEnv,out);
+ return (starsdbc::SQLException)java_sql_SQLException(warn_base,0);
+ }
+
+ return starsdbc::SQLException();
+}
+
+::rtl::OUString java_sql_SQLException_BASE::getSQLState() const
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("getSQLState",mID);
+}
+sal_Int32 java_sql_SQLException_BASE::getErrorCode() const
+{
+ static jmethodID mID(NULL);
+ return callIntMethod("getErrorCode",mID);
+}
+
diff --git a/connectivity/source/drivers/jdbc/SQLWarning.cxx b/connectivity/source/drivers/jdbc/SQLWarning.cxx
new file mode 100644
index 000000000000..cf30b8b0e530
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/SQLWarning.cxx
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/SQLWarning.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.SQLWarning
+//**************************************************************
+
+jclass java_sql_SQLWarning_BASE::theClass = 0;
+
+java_sql_SQLWarning_BASE::~java_sql_SQLWarning_BASE()
+{}
+
+jclass java_sql_SQLWarning_BASE::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/SQLWarning");
+ return theClass;
+}
+
diff --git a/connectivity/source/drivers/jdbc/String.cxx b/connectivity/source/drivers/jdbc/String.cxx
new file mode 100644
index 000000000000..e6102fc3a471
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/String.cxx
@@ -0,0 +1,82 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/String.hxx"
+#include "java/tools.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.String
+//**************************************************************
+
+jclass java_lang_String::theClass = 0;
+
+java_lang_String::~java_lang_String()
+{}
+
+jclass java_lang_String::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_lang_String::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/String");
+ return theClass;
+}
+
+//--------------------------------------------------------------------------
+java_lang_String::java_lang_String( const ::rtl::OUString& _par0 ): java_lang_Object( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ jvalue args[1];
+ // Parameter konvertieren
+ args[0].l = convertwchar_tToJavaString(t.pEnv,_par0);
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)V";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+ tempObj = t.pEnv->NewObjectA( getMyClass(), mID, args );
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+}
+//--------------------------------------------------------------------------
+java_lang_String::operator ::rtl::OUString()
+{
+ SDBThreadAttach t;
+ if(!t.pEnv)
+ return ::rtl::OUString();
+ return JavaString2String(t.pEnv,(jstring)object);
+}
+
diff --git a/connectivity/source/drivers/jdbc/Throwable.cxx b/connectivity/source/drivers/jdbc/Throwable.cxx
new file mode 100644
index 000000000000..9bbd81f62b0e
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Throwable.cxx
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/lang/Throwable.hxx"
+#include "java/tools.hxx"
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.lang.Throwable
+//**************************************************************
+
+jclass java_lang_Throwable::theClass = 0;
+
+java_lang_Throwable::~java_lang_Throwable()
+{}
+
+jclass java_lang_Throwable::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_lang_Throwable::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/lang/Throwable");
+ return theClass;
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString java_lang_Throwable::getMessage() const
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("getMessage",mID);
+}
+// -----------------------------------------------------------------------------
+
+::rtl::OUString java_lang_Throwable::getLocalizedMessage() const
+{
+ static jmethodID mID(NULL);
+ return callStringMethod("getLocalizedMessage",mID);
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/Timestamp.cxx b/connectivity/source/drivers/jdbc/Timestamp.cxx
new file mode 100644
index 000000000000..7fcc3686eaaa
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/Timestamp.cxx
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Timestamp.hxx"
+#include "java/tools.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbconversion.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+//**************************************************************
+//************ Class: java.sql.Date
+//**************************************************************
+const double fMilliSecondsPerDay = 86400000.0;
+jclass java_sql_Date::theClass = 0;
+java_sql_Date::java_sql_Date( const ::com::sun::star::util::Date& _rOut ) : java_util_Date( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ jvalue args[1];
+ // Parameter konvertieren
+ ::rtl::OUString sDateStr;
+ sDateStr = ::dbtools::DBTypeConversion::toDateString(_rOut);
+ args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
+
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Date;";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ // und aufraeumen
+}
+
+java_sql_Date::~java_sql_Date()
+{}
+
+jclass java_sql_Date::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_sql_Date::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Date");
+ return theClass;
+}
+// -----------------------------------------------------------------------------
+
+java_sql_Date::operator ::com::sun::star::util::Date()
+{
+ return ::dbtools::DBTypeConversion::toDate(toString());
+}
+
+//**************************************************************
+//************ Class: java.sql.Time
+//**************************************************************
+
+jclass java_sql_Time::theClass = 0;
+
+java_sql_Time::~java_sql_Time()
+{}
+
+jclass java_sql_Time::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_sql_Time::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Time");
+ return theClass;
+}
+java_sql_Time::java_sql_Time( const ::com::sun::star::util::Time& _rOut ): java_util_Date( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ jvalue args[1];
+ // Parameter konvertieren
+ ::rtl::OUString sDateStr;
+ sDateStr = ::dbtools::DBTypeConversion::toTimeString(_rOut);
+ args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
+
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Time;";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ // und aufraeumen
+}
+// -----------------------------------------------------------------------------
+java_sql_Time::operator ::com::sun::star::util::Time()
+{
+ return ::dbtools::DBTypeConversion::toTime(toString());
+}
+//**************************************************************
+//************ Class: java.sql.Timestamp
+//**************************************************************
+
+jclass java_sql_Timestamp::theClass = 0;
+
+java_sql_Timestamp::~java_sql_Timestamp()
+{}
+
+jclass java_sql_Timestamp::getMyClass() const
+{
+ return st_getMyClass();
+}
+jclass java_sql_Timestamp::st_getMyClass()
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/sql/Timestamp");
+ return theClass;
+}
+java_sql_Timestamp::java_sql_Timestamp(const ::com::sun::star::util::DateTime& _rOut)
+ :java_util_Date( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ jvalue args[1];
+ // Parameter konvertieren
+ ::rtl::OUString sDateStr;
+ sDateStr = ::dbtools::DBTypeConversion::toDateTimeString(_rOut);
+
+ args[0].l = convertwchar_tToJavaString(t.pEnv,sDateStr);
+
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;)Ljava/sql/Timestamp;";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ if ( !mID )
+ mID = t.pEnv->GetStaticMethodID( getMyClass(), "valueOf", cSignature );OSL_ENSURE(mID,"Unknown method id!");
+ tempObj = t.pEnv->CallStaticObjectMethod( getMyClass(), mID, args[0].l );
+
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+ // und aufraeumen
+}
+
+sal_Int32 java_sql_Timestamp::getNanos()
+{
+ static jmethodID mID(NULL);
+ return callIntMethod("getNanos",mID);
+}
+
+void java_sql_Timestamp::setNanos( sal_Int32 _par0 )
+{
+ static jmethodID mID(NULL);
+ callVoidMethodWithIntArg("setNanos",mID,_par0);
+}
+// -----------------------------------------------------------------------------
+java_sql_Timestamp::operator ::com::sun::star::util::DateTime()
+{
+ return ::dbtools::DBTypeConversion::toDateTime(toString());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/jdbc/exports.dxp b/connectivity/source/drivers/jdbc/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/jdbc/jdbc.mxp.map b/connectivity/source/drivers/jdbc/jdbc.mxp.map
new file mode 100644
index 000000000000..a4457e2478af
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/jdbc.mxp.map
@@ -0,0 +1,154 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
+__mh_dylib_header
+___builtin_delete
+___check_eh_spec
+___cp_pop_exception
+___get_eh_context
+___pure_virtual
+___rtti_class
+___rtti_si
+___rtti_user
+___sjthrow
+___start_cp_handler
+___terminate
+dyld_stub_binding_helper
+rest_world
+save_world
+___builtin_new
+___builtin_vec_delete
+___builtin_vec_new
+___cp_push_exception
+___eh_alloc
+_terminate__Fv
+___eh_rtime_match
+__._10bad_typeid
+__._8bad_cast
+___get_eh_info
+___is_pointer__FPv
+___throw_type_match_rtti
+___vt_10bad_typeid
+___vt_8bad_cast
+__keymgr_get_per_thread_data
+__keymgr_set_per_thread_data
+___tf9exception
+___ti9exception
+___vt_9exception
+_what__C9exception
+__._9bad_alloc
+___tf9bad_alloc
+___vt_9bad_alloc
+__._9type_info
+___eq__C9type_infoRCB0
+___tf16__user_type_info
+___tf9type_info
+___ti9type_info
+___vt_9type_info
+_getMyClass__Q212connectivity14java_sql_Array
+_saveClassRef__Q212connectivity14java_sql_ArrayP7_jclass
+_getMyClass__Q212connectivity13java_sql_Blob
+_saveClassRef__Q212connectivity13java_sql_BlobP7_jclass
+_saveClassRef__Q212connectivity17java_lang_BooleanP7_jclass
+__._Q212connectivity26java_sql_CallableStatement
+_release__Q212connectivity26java_sql_CallableStatement
+_acquire__Q212connectivity26java_sql_CallableStatement
+_saveClassRef__Q212connectivity26java_sql_CallableStatementP7_jclass
+_getMyClass__Q212connectivity26java_sql_CallableStatement
+_getMyClass__Q212connectivity15java_lang_Class
+_saveClassRef__Q212connectivity15java_lang_ClassP7_jclass
+_getMyClass__Q212connectivity13java_sql_Clob
+_saveClassRef__Q212connectivity13java_sql_ClobP7_jclass
+_getMyClass__Q212connectivity19java_sql_Connection
+_saveClassRef__Q212connectivity19java_sql_ConnectionP7_jclass
+_getMyClass__Q212connectivity25java_sql_DatabaseMetaData
+_saveClassRef__Q212connectivity25java_sql_DatabaseMetaDataP7_jclass
+_saveClassRef__Q212connectivity14java_util_DateP7_jclass
+_getMyClass__Q212connectivity14java_util_Date
+_getMyClass__Q212connectivity22java_sql_DriverManager
+_saveClassRef__Q212connectivity22java_sql_DriverManagerP7_jclass
+_choices__CQ212connectivity27java_sql_DriverPropertyInfo
+_value__CQ212connectivity27java_sql_DriverPropertyInfo
+_required__CQ212connectivity27java_sql_DriverPropertyInfo
+_description__CQ212connectivity27java_sql_DriverPropertyInfo
+_name__CQ212connectivity27java_sql_DriverPropertyInfo
+_saveClassRef__Q212connectivity27java_sql_DriverPropertyInfoP7_jclass
+_saveClassRef__Q212connectivity19java_lang_ExceptionP7_jclass
+_getMyClass__Q212connectivity19java_io_InputStream
+_saveClassRef__Q212connectivity19java_io_InputStreamP7_jclass
+_getMyClass__Q212connectivity15java_sql_Driver
+_saveClassRef__Q212connectivity15java_sql_DriverP7_jclass
+___Q212connectivity15java_sql_DriverRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory
+_getMyClass__Q212connectivity16java_lang_Object
+_setError__Q212connectivity15SDBThreadAttach
+_StartJava__Q212connectivity15SDBThreadAttachRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory
+_xInit__Q212connectivity15SDBThreadAttachRCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory
+_detachThread__Q212connectivity15SDBThreadAttach
+_attachThread__Q212connectivity15SDBThreadAttachRP7JNIEnv_RCQ53com3sun4star3unot9Reference1ZQ53com3sun4star4lang20XMultiServiceFactory
+_release__Q212connectivity26java_sql_PreparedStatement
+_acquire__Q212connectivity26java_sql_PreparedStatement
+_getMyClass__Q212connectivity26java_sql_PreparedStatement
+_saveClassRef__Q212connectivity26java_sql_PreparedStatementP7_jclass
+_getMyClass__Q212connectivity14java_io_Reader
+_saveClassRef__Q212connectivity14java_io_ReaderP7_jclass
+_getMyClass__Q212connectivity12java_sql_Ref
+_saveClassRef__Q212connectivity12java_sql_RefP7_jclass
+__._Q312connectivity4jdbc18UStringDescription
+___Q312connectivity4jdbc18UStringDescriptionPFv_PCc
+_getPropertySetInfo__Q212connectivity18java_sql_ResultSet
+_release__Q212connectivity18java_sql_ResultSet
+_acquire__Q212connectivity18java_sql_ResultSet
+_getResultSetType__CQ212connectivity18java_sql_ResultSet
+_getResultSetConcurrency__CQ212connectivity18java_sql_ResultSet
+_getCursorName__CQ212connectivity18java_sql_ResultSet
+_setFetchSize__Q212connectivity18java_sql_ResultSetl
+_setFetchDirection__Q212connectivity18java_sql_ResultSetl
+_getFetchSize__CQ212connectivity18java_sql_ResultSet
+_getFetchDirection__CQ212connectivity18java_sql_ResultSet
+_saveClassRef__Q212connectivity18java_sql_ResultSetP7_jclass
+_getMyClass__Q212connectivity18java_sql_ResultSet
+_getMyClass__Q212connectivity26java_sql_ResultSetMetaData
+_saveClassRef__Q212connectivity26java_sql_ResultSetMetaDataP7_jclass
+_saveClassRef__Q212connectivity26java_sql_SQLException_BASEP7_jclass
+_getNextException__CQ212connectivity26java_sql_SQLException_BASE
+_getErrorCode__CQ212connectivity26java_sql_SQLException_BASE
+_getSQLState__CQ212connectivity26java_sql_SQLException_BASE
+_saveClassRef__Q212connectivity24java_sql_SQLWarning_BASEP7_jclass
+_disposing__Q212connectivity23java_sql_Statement_Base
+_release__Q212connectivity23java_sql_Statement_Base
+_acquire__Q212connectivity23java_sql_Statement_Base
+__._Q212connectivity16OStatement_BASE2
+_release__Q212connectivity18java_sql_Statement
+_acquire__Q212connectivity18java_sql_Statement
+_saveClassRef__Q212connectivity18java_sql_StatementP7_jclass
+_setFetchSize__Q212connectivity23java_sql_Statement_Basel
+_setFetchDirection__Q212connectivity23java_sql_Statement_Basel
+_setResultSetType__Q212connectivity23java_sql_Statement_Basel
+_setResultSetConcurrency__Q212connectivity23java_sql_Statement_Basel
+_setCursorName__Q212connectivity23java_sql_Statement_BaseRCQ23rtl8OUString
+_setMaxRows__Q212connectivity23java_sql_Statement_Basel
+_setMaxFieldSize__Q212connectivity23java_sql_Statement_Basel
+_setQueryTimeOut__Q212connectivity23java_sql_Statement_Basel
+_getFetchSize__CQ212connectivity23java_sql_Statement_Base
+_getFetchDirection__CQ212connectivity23java_sql_Statement_Base
+_getResultSetType__CQ212connectivity23java_sql_Statement_Base
+_getResultSetConcurrency__CQ212connectivity23java_sql_Statement_Base
+_getCursorName__CQ212connectivity23java_sql_Statement_Base
+_getMaxRows__CQ212connectivity23java_sql_Statement_Base
+_getMaxFieldSize__CQ212connectivity23java_sql_Statement_Base
+_getQueryTimeOut__CQ212connectivity23java_sql_Statement_Base
+_getMyClass__Q212connectivity18java_sql_Statement
+_saveClassRef__Q212connectivity23java_sql_Statement_BaseP7_jclass
+_getMyClass__Q212connectivity23java_sql_Statement_Base
+_saveClassRef__Q212connectivity16java_lang_StringP7_jclass
+_saveClassRef__Q212connectivity19java_lang_ThrowableP7_jclass
+_getMyClass__Q212connectivity18java_sql_Timestamp
+_saveClassRef__Q212connectivity18java_sql_TimestampP7_jclass
+_getMyClass__Q212connectivity13java_sql_Time
+_saveClassRef__Q212connectivity13java_sql_TimeP7_jclass
+_saveClassRef__Q212connectivity13java_sql_DateP7_jclass
+___tf13bad_exception
+___uncatch_exception
+___eh_free
+___tfv
+___dynamic_cast
diff --git a/connectivity/source/drivers/jdbc/jdbc.xcu b/connectivity/source/drivers/jdbc/jdbc.xcu
new file mode 100755
index 000000000000..f4f599a701d9
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/jdbc.xcu
@@ -0,0 +1,214 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="jdbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.JDBCDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">JDBC</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="JavaDriverClass" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="JavaDriverClassPath" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AutoIncrementCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AutoRetrievingStatement" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="IsAutoRetrievingEnabled" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="GeneratedValues" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="ParameterNameSubstitution" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseCatalogInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSchemaInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseIndexDirectionKeyword" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="PrimaryKeySupport" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseJava" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="jdbc:oracle:thin:*" oor:op="replace">
+ <prop oor:name="ParentURLPattern">
+ <value>jdbc:*</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Oracle JDBC</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="IgnoreCurrency" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="TypeInfoSettings" oor:op="replace">
+ <prop oor:name="Value" oor:type="oor:string-list">
+ <value oor:separator=",">Column(2) = -5,Column(6) = PRECISION,Column(2) = -4,Column(6) = PRECISION,Column(2) = -3,Column(6) = PRECISION,Column(2) = -2,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = -1,Column(6) = PRECISION,Column(2) = 2,Column(6) = PRECISION,Column(2) = 12,Column(6) = PRECISION</value>
+ </prop>
+ </node>
+ <node oor:name="JavaDriverClass" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>oracle.jdbc.driver.OracleDriver</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="IgnoreCurrency" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/jdbc/jdbc.xml b/connectivity/source/drivers/jdbc/jdbc.xml
new file mode 100644
index 000000000000..b8433f2bdd46
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/jdbc.xml
@@ -0,0 +1,30 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> jdbc </module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.comp.sdbc.JDBCDriver</name>
+ <description>
+ This is the implementation of the sdbc-jdbc bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.sdbc.Driver </supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>osl</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/drivers/jdbc/jservices.cxx b/connectivity/source/drivers/jdbc/jservices.cxx
new file mode 100644
index 000000000000..cadbbdcbcd49
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/jservices.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "java/sql/Driver.hxx"
+#include <cppuhelper/factory.hxx>
+
+using namespace connectivity;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pModCount
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "SBA::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ java_sql_Driver::getImplementationName_Static(),
+ java_sql_Driver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "SBA::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ java_sql_Driver::getImplementationName_Static(),
+ java_sql_Driver::getSupportedServiceNames_Static(),
+ java_sql_Driver_CreateInstance,
+ ::cppu::createSingleFactory);
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+}
+
+
+
+
+
diff --git a/connectivity/source/drivers/jdbc/makefile.mk b/connectivity/source/drivers/jdbc/makefile.mk
new file mode 100644
index 000000000000..46619952163b
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/makefile.mk
@@ -0,0 +1,112 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=jdbc
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+.IF "$(SOLAR_JAVA)" != ""
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/Array.obj \
+ $(SLO)$/Blob.obj \
+ $(SLO)$/Boolean.obj \
+ $(SLO)$/CallableStatement.obj \
+ $(SLO)$/Class.obj \
+ $(SLO)$/Clob.obj \
+ $(SLO)$/ConnectionLog.obj \
+ $(SLO)$/DatabaseMetaData.obj \
+ $(SLO)$/Date.obj \
+ $(SLO)$/DriverPropertyInfo.obj \
+ $(SLO)$/Exception.obj \
+ $(SLO)$/InputStream.obj \
+ $(SLO)$/JConnection.obj \
+ $(SLO)$/JDriver.obj \
+ $(SLO)$/JStatement.obj \
+ $(SLO)$/Object.obj \
+ $(SLO)$/PreparedStatement.obj \
+ $(SLO)$/Reader.obj \
+ $(SLO)$/Ref.obj \
+ $(SLO)$/ResultSet.obj \
+ $(SLO)$/ResultSetMetaData.obj \
+ $(SLO)$/SQLException.obj \
+ $(SLO)$/SQLWarning.obj \
+ $(SLO)$/String.obj \
+ $(SLO)$/Throwable.obj \
+ $(SLO)$/Timestamp.obj \
+ $(SLO)$/jservices.obj \
+ $(SLO)$/JBigDecimal.obj \
+ $(SLO)$/tools.obj \
+ $(SLO)$/ContextClassLoader.obj
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(JDBC_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(JVMACCESSLIB) \
+ $(DBTOOLSLIB) \
+ $(UNOTOOLSLIB) \
+ $(JVMFWKLIB) \
+ $(COMPHELPERLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(JDBC_TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+.ENDIF # SOLAR_JAVA
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/jdbc/tools.cxx b/connectivity/source/drivers/jdbc/tools.cxx
new file mode 100644
index 000000000000..65315774a601
--- /dev/null
+++ b/connectivity/source/drivers/jdbc/tools.cxx
@@ -0,0 +1,274 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <cstdarg>
+#include "java/tools.hxx"
+#include "java/lang/String.hxx"
+#include "java/lang/Class.hxx"
+#include "java/util/Property.hxx"
+#include <com/sun/star/sdbc/DriverPropertyInfo.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+#include <connectivity/dbexception.hxx>
+
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+void java_util_Properties::setProperty(const ::rtl::OUString key, const ::rtl::OUString& value)
+{
+ SDBThreadAttach t; OSL_ENSURE(t.pEnv,"Java Enviroment geloescht worden!");
+ jobject out(0);
+
+ {
+ jvalue args[2];
+ // Parameter konvertieren
+ args[0].l = convertwchar_tToJavaString(t.pEnv,key);
+ args[1].l = convertwchar_tToJavaString(t.pEnv,value);
+ // temporaere Variable initialisieren
+ static const char * cSignature = "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;";
+ static const char * cMethodName = "setProperty";
+ // Java-Call absetzen
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, cMethodName,cSignature, mID);
+ out = t.pEnv->CallObjectMethod(object, mID, args[0].l,args[1].l);
+ ThrowSQLException(t.pEnv,NULL);
+ t.pEnv->DeleteLocalRef((jstring)args[1].l);
+ t.pEnv->DeleteLocalRef((jstring)args[0].l);
+ ThrowSQLException(t.pEnv,0);
+ if(out)
+ t.pEnv->DeleteLocalRef(out);
+ } //t.pEnv
+ // ACHTUNG: der Aufrufer wird Eigentuemer des zurueckgelieferten Zeigers !!!
+}
+jclass java_util_Properties::theClass = 0;
+
+java_util_Properties::~java_util_Properties()
+{}
+
+jclass java_util_Properties::getMyClass() const
+{
+ // die Klasse muss nur einmal geholt werden, daher statisch
+ if( !theClass )
+ theClass = findMyClass("java/util/Properties");
+ return theClass;
+}
+
+//--------------------------------------------------------------------------
+java_util_Properties::java_util_Properties( ): java_lang_Object( NULL, (jobject)NULL )
+{
+ SDBThreadAttach t;
+ if( !t.pEnv )
+ return;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ static const char * cSignature = "()V";
+ jobject tempObj;
+ static jmethodID mID(NULL);
+ obtainMethodId(t.pEnv, "<init>",cSignature, mID);
+ tempObj = t.pEnv->NewObject( getMyClass(), mID);
+ saveRef( t.pEnv, tempObj );
+ t.pEnv->DeleteLocalRef( tempObj );
+}
+
+// --------------------------------------------------------------------------------
+jstring connectivity::convertwchar_tToJavaString(JNIEnv *pEnv,const ::rtl::OUString& _rTemp)
+{
+ OSL_ENSURE(pEnv,"Environment is NULL!");
+ jstring pStr = pEnv->NewString(_rTemp.getStr(), _rTemp.getLength());
+ pEnv->ExceptionClear();
+ OSL_ENSURE(pStr,"Could not create a jsstring object!");
+ return pStr;
+}
+
+// --------------------------------------------------------------------------------
+java_util_Properties* connectivity::createStringPropertyArray(const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ java_util_Properties* pProps = new java_util_Properties();
+ const PropertyValue* pBegin = info.getConstArray();
+ const PropertyValue* pEnd = pBegin + info.getLength();
+
+ for(;pBegin != pEnd;++pBegin)
+ {
+ // this is a special property to find the jdbc driver
+ if ( pBegin->Name.compareToAscii( "JavaDriverClass" )
+ && pBegin->Name.compareToAscii( "JavaDriverClassPath" )
+ && pBegin->Name.compareToAscii( "SystemProperties" )
+ && pBegin->Name.compareToAscii( "CharSet" )
+ && pBegin->Name.compareToAscii( "AppendTableAliasName" )
+ && pBegin->Name.compareToAscii( "AddIndexAppendix" )
+ && pBegin->Name.compareToAscii( "FormsCheckRequiredFields" )
+ && pBegin->Name.compareToAscii( "GenerateASBeforeCorrelationName" )
+ && pBegin->Name.compareToAscii( "EscapeDateTime" )
+ && pBegin->Name.compareToAscii( "ParameterNameSubstitution" )
+ && pBegin->Name.compareToAscii( "IsPasswordRequired" )
+ && pBegin->Name.compareToAscii( "IsAutoRetrievingEnabled" )
+ && pBegin->Name.compareToAscii( "AutoRetrievingStatement" )
+ && pBegin->Name.compareToAscii( "UseCatalogInSelect" )
+ && pBegin->Name.compareToAscii( "UseSchemaInSelect" )
+ && pBegin->Name.compareToAscii( "AutoIncrementCreation" )
+ && pBegin->Name.compareToAscii( "Extension" )
+ && pBegin->Name.compareToAscii( "NoNameLengthLimit" )
+ && pBegin->Name.compareToAscii( "EnableSQL92Check" )
+ && pBegin->Name.compareToAscii( "EnableOuterJoinEscape" )
+ && pBegin->Name.compareToAscii( "BooleanComparisonMode" )
+ && pBegin->Name.compareToAscii( "IgnoreCurrency" )
+ && pBegin->Name.compareToAscii( "TypeInfoSettings" )
+ && pBegin->Name.compareToAscii( "IgnoreDriverPrivileges" )
+ && pBegin->Name.compareToAscii( "ImplicitCatalogRestriction" )
+ && pBegin->Name.compareToAscii( "ImplicitSchemaRestriction" )
+ && pBegin->Name.compareToAscii( "SupportsTableCreation" )
+ && pBegin->Name.compareToAscii( "UseJava" )
+ && pBegin->Name.compareToAscii( "Authentication" )
+ && pBegin->Name.compareToAscii( "PreferDosLikeLineEnds" )
+ && pBegin->Name.compareToAscii( "PrimaryKeySupport" )
+ )
+ {
+ ::rtl::OUString aStr;
+ OSL_VERIFY( pBegin->Value >>= aStr );
+ pProps->setProperty(pBegin->Name,aStr);
+ }
+ }
+ return pProps;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString connectivity::JavaString2String(JNIEnv *pEnv,jstring _Str)
+{
+ ::rtl::OUString aStr;
+ if(_Str)
+ {
+ jboolean bCopy(sal_True);
+ const jchar* pChar = pEnv->GetStringChars(_Str,&bCopy);
+ jsize len = pEnv->GetStringLength(_Str);
+ aStr = ::rtl::OUString(pChar,len);
+
+ if(bCopy)
+ pEnv->ReleaseStringChars(_Str,pChar);
+ pEnv->DeleteLocalRef(_Str);
+ }
+ return aStr;
+}
+// --------------------------------------------------------------------------------
+jobject connectivity::convertTypeMapToJavaMap(JNIEnv* /*pEnv*/,const Reference< ::com::sun::star::container::XNameAccess > & _rMap)
+{
+ if ( _rMap.is() )
+ {
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aNames = _rMap->getElementNames();
+ if ( aNames.getLength() > 0 )
+ ::dbtools::throwFeatureNotImplementedException( "Type maps", NULL );
+ }
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool connectivity::isExceptionOccured(JNIEnv *pEnv,sal_Bool _bClear)
+{
+ if ( !pEnv )
+ return sal_False;
+
+ jthrowable pThrowable = pEnv->ExceptionOccurred();
+ sal_Bool bRet = pThrowable != NULL;
+ if ( pThrowable )
+ {
+ if ( _bClear )
+ pEnv->ExceptionClear();
+#if OSL_DEBUG_LEVEL > 1
+ if(pEnv->IsInstanceOf(pThrowable,java_sql_SQLException_BASE::st_getMyClass()))
+ {
+
+ java_sql_SQLException_BASE* pException = new java_sql_SQLException_BASE(pEnv,pThrowable);
+ ::rtl::OUString sError = pException->getMessage();
+ delete pException;
+ }
+#else
+ pEnv->DeleteLocalRef(pThrowable);
+#endif
+
+ }
+
+ return bRet;
+}
+// -----------------------------------------------------------------------------
+jobject connectivity::createByteInputStream(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
+{
+ SDBThreadAttach t;
+ if( !t.pEnv || !x.is() )
+ return NULL;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ jclass clazz = java_lang_Object::findMyClass("java/io/ByteArrayInputStream");
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "([B)V";
+ mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
+ OSL_ENSURE( mID, cSignature );
+ if ( !mID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+ jbyteArray pByteArray = t.pEnv->NewByteArray(length);
+ Sequence< sal_Int8 > aData;
+ x->readBytes(aData,length);
+ jboolean p = sal_False;
+ rtl_copyMemory(t.pEnv->GetByteArrayElements(pByteArray,&p),aData.getArray(),aData.getLength());
+ jobject out = t.pEnv->NewObject( clazz, mID,pByteArray);
+ t.pEnv->DeleteLocalRef((jbyteArray)pByteArray);
+ return out;
+}
+// -----------------------------------------------------------------------------
+jobject connectivity::createCharArrayReader(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x,sal_Int32 length)
+{
+ SDBThreadAttach t;
+ if( !t.pEnv || !x.is() )
+ return NULL;
+ // Java-Call fuer den Konstruktor absetzen
+ // temporaere Variable initialisieren
+ jclass clazz = java_lang_Object::findMyClass("java/io/CharArrayReader");
+ static jmethodID mID(NULL);
+ if ( !mID )
+ {
+ static const char * cSignature = "([C)V";
+ mID = t.pEnv->GetMethodID( clazz, "<init>", cSignature );
+ OSL_ENSURE( mID, cSignature );
+ if ( !mID )
+ throw SQLException();
+ } // if ( !_inout_MethodID )
+ jcharArray pCharArray = t.pEnv->NewCharArray(length);
+ Sequence< sal_Int8 > aData;
+ x->readBytes(aData,length);
+ jboolean p = sal_False;
+ rtl_copyMemory(t.pEnv->GetCharArrayElements(pCharArray,&p),aData.getArray(),aData.getLength());
+ jobject out = t.pEnv->NewObject( clazz, mID,pCharArray);
+ t.pEnv->DeleteLocalRef((jcharArray)pCharArray);
+ return out;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/kab/KCatalog.cxx b/connectivity/source/drivers/kab/KCatalog.cxx
new file mode 100644
index 000000000000..c1309a562154
--- /dev/null
+++ b/connectivity/source/drivers/kab/KCatalog.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KCatalog.hxx"
+#include "KConnection.hxx"
+#include "KTables.hxx"
+
+using namespace connectivity::kab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+
+// -------------------------------------------------------------------------
+KabCatalog::KabCatalog(KabConnection* _pCon)
+ : connectivity::sdbcx::OCatalog(_pCon),
+ m_pConnection(_pCon),
+ m_xMetaData(m_pConnection->getMetaData())
+{
+}
+// -------------------------------------------------------------------------
+void KabCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(
+ Any(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
+ aTypes);
+
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+ // const ::rtl::OUString& sDot = KabCatalog::getDot();
+
+ while (xResult->next())
+ {
+ // aName = xRow->getString(2);
+ // aName += sDot;
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if (m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new KabTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void KabCatalog::refreshViews()
+{
+}
+// -------------------------------------------------------------------------
+void KabCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void KabCatalog::refreshUsers()
+{
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString& KabCatalog::getDot()
+{
+ static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("."));
+ return sDot;
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL KabCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ try
+ {
+ if (!m_pTables)
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return m_pTables;
+}
diff --git a/connectivity/source/drivers/kab/KCatalog.hxx b/connectivity/source/drivers/kab/KCatalog.hxx
new file mode 100644
index 000000000000..5129f72b28f9
--- /dev/null
+++ b/connectivity/source/drivers/kab/KCatalog.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_CATALOG_HXX_
+#define _CONNECTIVITY_KAB_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+namespace connectivity
+{
+ namespace kab
+ {
+ class KabConnection;
+
+ class KabCatalog : public connectivity::sdbcx::OCatalog
+ {
+ KabConnection* m_pConnection; // used to get the metadata
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
+
+ public:
+ KabCatalog(KabConnection* _pCon);
+
+ inline KabConnection* getConnection() const { return m_pConnection; }
+
+ static const ::rtl::OUString& getDot();
+
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews();
+ virtual void refreshGroups();
+ virtual void refreshUsers();
+
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(
+ ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_CATALOG_HXX_
diff --git a/connectivity/source/drivers/kab/KColumns.cxx b/connectivity/source/drivers/kab/KColumns.cxx
new file mode 100644
index 000000000000..4adcbe304c82
--- /dev/null
+++ b/connectivity/source/drivers/kab/KColumns.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KColumns.hxx"
+#include "KTable.hxx"
+#include "KTables.hxx"
+#include "KCatalog.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::kab;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+sdbcx::ObjectType KabColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
+ Any(),
+ m_pTable->getSchema(),
+ m_pTable->getTableName(),
+ _rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+
+ while (xResult->next())
+ {
+ if (xRow->getString(4) == _rName)
+ {
+ OColumn* pRet = new OColumn(
+ _rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False,
+ sal_False,
+ sal_False,
+ sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void KabColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+KabColumns::KabColumns( KabTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(*_pTable, sal_True, _rMutex, _rVector),
+ m_pTable(_pTable)
+{
+}
diff --git a/connectivity/source/drivers/kab/KColumns.hxx b/connectivity/source/drivers/kab/KColumns.hxx
new file mode 100644
index 000000000000..76ce272ed902
--- /dev/null
+++ b/connectivity/source/drivers/kab/KColumns.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_COLUMNS_HXX_
+#define _CONNECTIVITY_KAB_COLUMNS_HXX_
+
+#include "KTable.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+
+namespace connectivity
+{
+ namespace kab
+ {
+ class KabColumns : public sdbcx::OCollection
+ {
+ protected:
+ KabTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ KabColumns( KabTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_COLUMNS_HXX_
diff --git a/connectivity/source/drivers/kab/KConnection.cxx b/connectivity/source/drivers/kab/KConnection.cxx
new file mode 100644
index 000000000000..32e047748983
--- /dev/null
+++ b/connectivity/source/drivers/kab/KConnection.cxx
@@ -0,0 +1,328 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KConnection.hxx"
+#include "KDatabaseMetaData.hxx"
+#include "KStatement.hxx"
+#include "KPreparedStatement.hxx"
+#include "KDriver.hxx"
+#include "KCatalog.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <shell/kde_headers.h>
+
+using namespace connectivity::kab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+IMPLEMENT_SERVICE_INFO(KabConnection, "com.sun.star.sdbc.drivers.KabConnection", "com.sun.star.sdbc.Connection")
+//-----------------------------------------------------------------------------
+KabConnection::KabConnection(KabDriver* _pDriver)
+ : OMetaConnection_BASE(m_aMutex),
+ OSubComponent<KabConnection, KabConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
+ m_xMetaData(NULL),
+ m_pAddressBook(NULL),
+ m_pDriver(_pDriver)
+{
+ m_pDriver->acquire();
+}
+//-----------------------------------------------------------------------------
+KabConnection::~KabConnection()
+{
+ if (!isClosed())
+ close();
+
+ m_pDriver->release();
+ m_pDriver = NULL;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL KabConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+void KabConnection::construct(const ::rtl::OUString&, const Sequence< PropertyValue >&) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ // create a KDE address book object
+ m_pAddressBook = KABC::StdAddressBook::self();
+ m_pAddressBook->setAutomaticSave(false);
+// perharps we should analyze the URL to know whether the addressbook is local, over LDAP, etc...
+// perharps we should get some user and password information from "info" properties
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL KabConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed once
+ Reference< XStatement > xReturn = new KabStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL KabConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed more than once
+ Reference< XPreparedStatement > xReturn = new KabPreparedStatement(this, _sSql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL KabConnection::prepareCall( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // not implemented yet :-) a task to do
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // when you need to transform SQL92 to you driver specific you can do it here
+
+ return _sSql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::setAutoCommit( sal_Bool ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+ // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL KabConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+ // you have to distinguish which if you are in autocommit mode or not
+ // at normal case true should be fine here
+
+ return sal_True;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // when you database does support transactions you should commit here
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // same as commit but for the other case
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL KabConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // just simple -> we are closed when we are disposed, that means someone called dispose(); (XComponent)
+ return KabConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL KabConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // here we have to create the class with biggest interface
+ // The answer is 42 :-)
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if (!xMetaData.is())
+ {
+ xMetaData = new KabDatabaseMetaData(this); // need the connection because it can return it
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::setReadOnly( sal_Bool ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // set you connection to readonly
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL KabConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // return if your connection to readonly
+ return sal_False;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::setCatalog( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // if your database doesn't work with catalogs you go to next method otherwise you kjnow what to do
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+
+ // return your current catalog
+ return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::setTransactionIsolation( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // set your isolation level
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+ return TransactionIsolation::NONE;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL KabConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+
+ // if your driver has special database types you can return it here
+
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& ) throw(SQLException, RuntimeException)
+{
+ // the other way around
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL KabConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabConnection_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL KabConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ // when you collected some warnings -> return it
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ // you should clear your collected warnings here
+}
+//------------------------------------------------------------------------------
+void KabConnection::disposing()
+{
+ // we noticed that we should be destroied in near future so we have to dispose our statements
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_aStatements.clear();
+
+ if (m_pAddressBook != NULL)
+ {
+ m_pAddressBook->close();
+ m_pAddressBook = NULL;
+ }
+
+ m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
+
+ dispose_ChildImpl();
+ KabConnection_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL KabConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if (!m_xCatalog.is())
+ {
+ KabCatalog *pCat = new KabCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+::KABC::AddressBook* KabConnection::getAddressBook() const
+{
+ return m_pAddressBook;
+}
+// -----------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL createKabConnection( void* _pDriver )
+{
+ KabConnection* pConnection = new KabConnection( static_cast< KabDriver* >( _pDriver ) );
+ // by definition, the pointer crossing library boundaries as void ptr is acquired once
+ pConnection->acquire();
+ return pConnection;
+}
diff --git a/connectivity/source/drivers/kab/KConnection.hxx b/connectivity/source/drivers/kab/KConnection.hxx
new file mode 100644
index 000000000000..c7a9fcc82b11
--- /dev/null
+++ b/connectivity/source/drivers/kab/KConnection.hxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_CONNECTION_HXX_
+#define _CONNECTIVITY_KAB_CONNECTION_HXX_
+
+#include <map>
+#include "OSubComponent.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include <cppuhelper/compbase3.hxx>
+
+namespace KABC
+{
+ class StdAddressBook;
+ class AddressBook;
+}
+
+namespace connectivity
+{
+ namespace kab
+ {
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::lang::XServiceInfo
+ > OMetaConnection_BASE;
+
+ class KabStatement_Base;
+ class KabDriver;
+ class KabDatabaseMetaData;
+
+ typedef OMetaConnection_BASE KabConnection_BASE; // implements basics and text encoding
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+
+ class KabConnection : public comphelper::OBaseMutex,
+ public KabConnection_BASE,
+ public OSubComponent<KabConnection, KabConnection_BASE>
+ {
+ friend class OSubComponent<KabConnection, KabConnection_BASE>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ OWeakRefArray m_aStatements; // vector containing a list of all the Statement objects
+ // for this Connection
+
+ ::KABC::StdAddressBook* m_pAddressBook; // the address book
+ KabDriver* m_pDriver; // pointer to the owning driver object
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>
+ m_xCatalog; // needed for the SQL interpreter
+
+ public:
+ virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+
+ KabConnection(KabDriver* _pDriver);
+ virtual ~KabConnection();
+
+ void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // needed for the SQL interpreter
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
+
+ // accessors
+ inline KabDriver* getDriver() const { return m_pDriver;}
+ ::KABC::AddressBook* getAddressBook() const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_CONNECTION_HXX_
diff --git a/connectivity/source/drivers/kab/KDEInit.cxx b/connectivity/source/drivers/kab/KDEInit.cxx
new file mode 100644
index 000000000000..86098c1b8866
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDEInit.cxx
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "KDEInit.h"
+#include <osl/diagnose.h>
+#include <osl/process.h>
+#include <shell/kde_headers.h>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ // ===============================================================
+ // = KDEInit
+ // ===============================================================
+ class KDEInit
+ {
+ private:
+ /// KDE application if we own it
+ static KApplication* s_pKApplication;
+ static bool s_bDidInsertCatalogue;
+
+ public:
+ static void Init();
+ static void Shutdown();
+ };
+
+ // ---------------------------------------------------------------
+ KApplication* KDEInit::s_pKApplication = NULL;
+ bool KDEInit::s_bDidInsertCatalogue = false;
+
+ // ---------------------------------------------------------------
+ void KDEInit::Init()
+ {
+ // TODO: All this is not thread-safe
+
+ // we create a KDE application only if it is not already done
+ if (KApplication::kApplication() == NULL)
+ {
+ OSL_ENSURE(s_pKApplication == NULL, "KDEInit::Init: inconsistency in the application pointers!");
+
+ char *kabargs[1] = {(char*)"libkab1"};
+ KCmdLineArgs::init(1, kabargs, "KAddressBook", *kabargs, "Address Book driver", KAB_DRIVER_VERSION);
+
+ s_pKApplication = new KApplication(false, false);
+ }
+
+ // set language
+ rtl_Locale *pProcessLocale;
+ osl_getProcessLocale(&pProcessLocale);
+ // sal_Unicode and QChar are (currently) both 16 bits characters
+ QString aLanguage(
+ (const QChar *) pProcessLocale->Language->buffer,
+ (int) pProcessLocale->Language->length);
+ KGlobal::locale()->setLanguage(aLanguage);
+
+ // load KDE address book's localized messages
+ KGlobal::locale()->insertCatalogue("kaddressbook");
+ s_bDidInsertCatalogue = true;
+ }
+
+ // ---------------------------------------------------------------
+ void KDEInit::Shutdown()
+ {
+ if ( s_bDidInsertCatalogue )
+ // this guard is necessary, since KDE 3.3 seems to crash if we remove a catalogue
+ // which we did not previously insert
+ KGlobal::locale()->removeCatalogue("kaddressbook");
+
+ if ( s_pKApplication != NULL )
+ {
+ delete s_pKApplication;
+ s_pKApplication = NULL;
+ }
+ }
+ }
+}
+
+// =======================================================================
+namespace
+{
+ double normalizeVersion( unsigned int major, unsigned int minor )
+ {
+ return major + 1.0 * minor / 1000;
+ }
+}
+
+// -----------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL initKApplication()
+{
+ ::connectivity::kab::KDEInit::Init();
+}
+
+// -----------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL shutdownKApplication()
+{
+ ::connectivity::kab::KDEInit::Shutdown();
+}
+// -----------------------------------------------------------------------
+/** checks whether the KDE version on the system we're running at is supported
+ by the driver
+
+ Has to be called before any other code from this library, in particular,
+ it has to be called before initKApplication()
+
+ If this function returns <code>0</code>, then no other code from this library
+ has to be called, else the results are unpredictable.
+
+ @return
+ <ul><li><code>0</code> if the KDE version is supportednon</li>
+ <li>a negative value if the version is too old</li>
+ <li>a positive value if the version is too new to know whether it works with this driver</li>
+ </ul>
+
+ #i60062# / 2006-01-06 / frank.schoenheit@sun.com
+*/
+extern "C" SAL_DLLPUBLIC_EXPORT int SAL_CALL matchKDEVersion()
+{
+ double nMinVersion = normalizeVersion( MIN_KDE_VERSION_MAJOR, MIN_KDE_VERSION_MINOR );
+ double nCurVersion = normalizeVersion( ::KDE::versionMajor(), ::KDE::versionMinor() );
+ double nMaxVersion = normalizeVersion( MAX_KDE_VERSION_MAJOR, MAX_KDE_VERSION_MINOR );
+
+ if ( nCurVersion < nMinVersion )
+ return -1;
+ if ( nCurVersion > nMaxVersion )
+ return 1;
+
+ return 0;
+}
diff --git a/connectivity/source/drivers/kab/KDEInit.h b/connectivity/source/drivers/kab/KDEInit.h
new file mode 100644
index 000000000000..8e401a05e8d6
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDEInit.h
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_KAB_KDEINIT_H
+#define CONNECTIVITY_KAB_KDEINIT_H
+
+// the address book driver's version
+#define KAB_DRIVER_VERSION "0.2"
+#define KAB_DRIVER_VERSION_MAJOR 0
+#define KAB_DRIVER_VERSION_MINOR 2
+
+// the minimum KDE version which is required at runtime
+#define MIN_KDE_VERSION_MAJOR 3
+#define MIN_KDE_VERSION_MINOR 2
+
+#define MAX_KDE_VERSION_MAJOR 3
+#define MAX_KDE_VERSION_MINOR 6
+
+
+#endif // CONNECTIVITY_KAB_KDEINIT_H
diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.cxx b/connectivity/source/drivers/kab/KDatabaseMetaData.cxx
new file mode 100644
index 000000000000..b972f362b45a
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDatabaseMetaData.cxx
@@ -0,0 +1,1080 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KDatabaseMetaData.hxx"
+#include "kfields.hxx"
+#include "KDEInit.h"
+#include <shell/kde_headers.h>
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "OTypeInfo.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+using namespace connectivity::kab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+KabDatabaseMetaData::KabDatabaseMetaData(KabConnection* _pCon)
+ : m_xConnection(_pCon),
+ m_bUseCatalog(sal_True)
+{
+ OSL_ENSURE(_pCon,"KabDatabaseMetaData::KabDatabaseMetaData: No connection set!");
+
+ osl_incrementInterlockedCount( &m_refCount );
+ m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+KabDatabaseMetaData::~KabDatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString & KabDatabaseMetaData::getAddressBookTableName()
+{
+ static const ::rtl::OUString aAddressBookTableName
+ (::rtl::OUString::createFromAscii( i18n("Address Book") ));
+
+ return aAddressBookTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if (m_bUseCatalog)
+ { // do some special here for you database
+ }
+
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException)
+{
+ // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
+ // currently, the resultset/statement implementations can cope with one table only
+ sal_Int32 nValue = 1;
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if (m_bUseCatalog)
+ {
+ }
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
+{
+ // normally this is "
+ ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\"");
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bValue = sal_False;
+ if (m_bUseCatalog)
+ {
+ }
+ return bValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ // for the moment, we have read-only addresses, but this might change in the future
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ // if someday we support more than the default address book,
+ // this method should return the URL which was used to create it
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:address:kab:");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("kab");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii(KAB_DRIVER_VERSION);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return KAB_DRIVER_VERSION_MAJOR;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return KAB_DRIVER_VERSION_MINOR;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ switch (setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ case ResultSetType::SCROLL_INSENSITIVE:
+ return sal_True;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ switch (setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ case ResultSetType::SCROLL_INSENSITIVE:
+ return sal_True;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::updatesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::deletesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::insertsAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL KabDatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException)
+{
+ return (Reference< XConnection >) m_xConnection.get();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(2);
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = new ORowSetValueDecorator(aTable);
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::CHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32) 254);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) ColumnValue::NULLABLE);
+ aRow[8] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[9] = new ORowSetValueDecorator((sal_Int32) ColumnSearch::CHAR);
+ aRow[10] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[11] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[12] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[14] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[16] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[18] = new ORowSetValueDecorator((sal_Int32) 10);
+ aRows.push_back(aRow);
+// Much more types might appear in KDE address books
+// To be completed
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs );
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumnPrivileges(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
+ const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getColumns(
+ const Any&,
+ const ::rtl::OUString&,
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+ if (match(tableNamePattern, getAddressBookTableName(), '\0'))
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = new ORowSetValueDecorator(getAddressBookTableName());
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[9] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[10] = new ORowSetValueDecorator((sal_Int32) 10);
+ aRow[11] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[16] = new ORowSetValueDecorator((sal_Int32) 254);
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+
+ sal_Int32 nPosition = 1;
+ QString aQtName;
+ ::rtl::OUString sName;
+
+ aQtName = ::KABC::Addressee::revisionLabel();
+ sName = (const sal_Unicode *) aQtName.ucs2();
+ if (match(columnNamePattern, sName, '\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(sName);
+ aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[17] = new ORowSetValueDecorator(nPosition++);
+ aRows.push_back(aRow);
+ }
+
+ ::KABC::Field::List aFields = ::KABC::Field::allFields();
+ ::KABC::Field::List::iterator aField;
+
+ for ( aField = aFields.begin();
+ aField != aFields.end();
+ ++aField, ++nPosition)
+ {
+ aQtName = (*aField)->label();
+ sName = (const sal_Unicode *) aQtName.ucs2();
+ if (match(columnNamePattern, sName, '\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(sName);
+ aRow[5] = new ORowSetValueDecorator(DataType::CHAR);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) 256);
+// Might be VARCHAR and not CHAR[256]...
+ aRow[17] = new ORowSetValueDecorator(nPosition);
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTables(
+ const Any&,
+ const ::rtl::OUString&,
+ const ::rtl::OUString&,
+ const Sequence< ::rtl::OUString >& types) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xRef = pResult;
+
+ // check whether we have tables in the requested types
+ // for the moment, we answer only the "TABLE" table type
+ // when no types are given at all, we return all the tables
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+ sal_Bool bTableFound = sal_False;
+ const ::rtl::OUString* p = types.getConstArray(),
+ * pEnd = p + types.getLength();
+
+ if (p == pEnd)
+ {
+ bTableFound = sal_True;
+ }
+ else while (p < pEnd)
+ {
+ if (match(*p, aTable, '\0'))
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ p++;
+ }
+ if (!bTableFound)
+ return xRef;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(6);
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = new ORowSetValueDecorator(getAddressBookTableName());
+ aRow[4] = new ORowSetValueDecorator(aTable);
+ aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedureColumns(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getProcedures(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getVersionColumns(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
+
+ Reference< XResultSet > xRef = pResult;
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+ if (table == getAddressBookTableName())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow( 9 );
+ QString aQtName = ::KABC::Addressee::revisionLabel();
+ ::rtl::OUString sName = (const sal_Unicode *) aQtName.ucs2();
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+
+ aRow[2] = new ORowSetValueDecorator(sName);
+ aRow[3] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[4] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+
+ aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[7] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getExportedKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getImportedKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getPrimaryKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getIndexInfo(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
+ sal_Bool, sal_Bool ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getBestRowIdentifier(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&, sal_Int32,
+ sal_Bool ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getTablePrivileges(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getCrossReference(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString&, const Any&,
+ const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabDatabaseMetaData::getUDTs( const Any&, const ::rtl::OUString&, const ::rtl::OUString&, const Sequence< sal_Int32 >& ) throw(SQLException, RuntimeException)
+{
+ OSL_ENSURE(0,"Not implemented yet!");
+ throw SQLException();
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/kab/KDatabaseMetaData.hxx b/connectivity/source/drivers/kab/KDatabaseMetaData.hxx
new file mode 100644
index 000000000000..2c56869fcb6d
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDatabaseMetaData.hxx
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_
+#define _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_
+
+#include "KConnection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ //**************************************************************
+ //************ Class: KabDatabaseMetaData
+ //**************************************************************
+
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> KabDatabaseMetaData_BASE;
+
+ class KabDatabaseMetaData : public KabDatabaseMetaData_BASE
+ {
+ ::com::sun::star::uno::Reference< KabConnection > m_xConnection;
+ sal_Bool m_bUseCatalog;
+
+ public:
+
+ inline KabConnection* getOwnConnection() const { return m_xConnection.get(); }
+
+ KabDatabaseMetaData(KabConnection* _pCon);
+ static const ::rtl::OUString & getAddressBookTableName();
+ virtual ~KabDatabaseMetaData();
+
+ // this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_DATABASEMETADATA_HXX_
diff --git a/connectivity/source/drivers/kab/KDriver.cxx b/connectivity/source/drivers/kab/KDriver.cxx
new file mode 100644
index 000000000000..72753f10662a
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDriver.cxx
@@ -0,0 +1,473 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KDriver.hxx"
+#include "KDEInit.h"
+#include "KConnection.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+#include "resource/kab_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::frame;
+using namespace connectivity::kab;
+
+// =======================================================================
+// = KabImplModule
+// =======================================================================
+// --------------------------------------------------------------------------------
+KabImplModule::KabImplModule( const Reference< XMultiServiceFactory >& _rxFactory )
+ :m_xORB(_rxFactory)
+ ,m_bAttemptedLoadModule(false)
+ ,m_bAttemptedInitialize(false)
+ ,m_hConnectorModule(NULL)
+ ,m_pConnectionFactoryFunc(NULL)
+ ,m_pApplicationInitFunc(NULL)
+ ,m_pApplicationShutdownFunc(NULL)
+ ,m_pKDEVersionCheckFunc(NULL)
+{
+ if ( !m_xORB.is() )
+ throw NullPointerException();
+}
+
+// --------------------------------------------------------------------------------
+bool KabImplModule::isKDEPresent()
+{
+ if ( !impl_loadModule() )
+ return false;
+
+ return true;
+}
+
+// --------------------------------------------------------------------------------
+KabImplModule::KDEVersionType KabImplModule::matchKDEVersion()
+{
+ OSL_PRECOND( m_pKDEVersionCheckFunc, "KabImplModule::matchKDEVersion: module not loaded!" );
+
+ int nVersionInfo = (*m_pKDEVersionCheckFunc)();
+ if ( nVersionInfo < 0 )
+ return eTooOld;
+ if ( nVersionInfo > 0 )
+ return eToNew;
+ return eSupported;
+}
+
+// --------------------------------------------------------------------------------
+namespace
+{
+ template< typename FUNCTION >
+ void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction )
+ {
+ _rFunction = NULL;
+ if ( _rModule )
+ {
+ //
+ const ::rtl::OUString sSymbolName = ::rtl::OUString::createFromAscii( _pAsciiSymbolName );
+ _rFunction = (FUNCTION)( osl_getSymbol( _rModule, sSymbolName.pData ) );
+
+ if ( !_rFunction )
+ { // did not find the symbol
+ OSL_ENSURE( false, ::rtl::OString( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ) + ::rtl::OString( _pAsciiSymbolName ) );
+ osl_unloadModule( _rModule );
+ _rModule = NULL;
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------------------
+extern "C" { void SAL_CALL thisModule() {} }
+
+bool KabImplModule::impl_loadModule()
+{
+ if ( m_bAttemptedLoadModule )
+ return ( m_hConnectorModule != NULL );
+ m_bAttemptedLoadModule = true;
+
+ OSL_ENSURE( !m_hConnectorModule && !m_pConnectionFactoryFunc && !m_pApplicationInitFunc && !m_pApplicationShutdownFunc && !m_pKDEVersionCheckFunc,
+ "KabImplModule::impl_loadModule: inconsistence: inconsistency (never attempted load before, but some values already set)!");
+
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii( SAL_MODULENAME( "kabdrv1" ) );
+ m_hConnectorModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, SAL_LOADMODULE_NOW ); // LAZY! #i61335#
+ OSL_ENSURE( m_hConnectorModule, "KabImplModule::impl_loadModule: could not load the implementation library!" );
+ if ( !m_hConnectorModule )
+ return false;
+
+ lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "createKabConnection", m_pConnectionFactoryFunc );
+ lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "initKApplication", m_pApplicationInitFunc );
+ lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "shutdownKApplication", m_pApplicationShutdownFunc );
+ lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "matchKDEVersion", m_pKDEVersionCheckFunc );
+
+ if ( !m_hConnectorModule )
+ // one of the symbols did not exist
+ throw RuntimeException();
+
+ return true;
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::impl_unloadModule()
+{
+ OSL_PRECOND( m_hConnectorModule != NULL, "KabImplModule::impl_unloadModule: no module!" );
+
+ osl_unloadModule( m_hConnectorModule );
+ m_hConnectorModule = NULL;
+
+ m_pConnectionFactoryFunc = NULL;
+ m_pApplicationInitFunc = NULL;
+ m_pApplicationShutdownFunc = NULL;
+ m_pKDEVersionCheckFunc = NULL;
+
+ m_bAttemptedLoadModule = false;
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::init()
+{
+ if ( !impl_loadModule() )
+ impl_throwNoKdeException();
+
+ // if we're not running on a supported version, throw
+ KabImplModule::KDEVersionType eKDEVersion = matchKDEVersion();
+
+ if ( eKDEVersion == eTooOld )
+ impl_throwKdeTooOldException();
+
+ if ( ( eKDEVersion == eToNew ) && !impl_doAllowNewKDEVersion() )
+ impl_throwKdeTooNewException();
+
+ if ( !m_bAttemptedInitialize )
+ {
+ m_bAttemptedInitialize = true;
+ (*m_pApplicationInitFunc)();
+ }
+}
+
+// --------------------------------------------------------------------------------
+bool KabImplModule::impl_doAllowNewKDEVersion()
+{
+ try
+ {
+ Reference< XMultiServiceFactory > xConfigProvider(
+ m_xORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationProvider" ) ) ),
+ UNO_QUERY_THROW );
+ Sequence< Any > aCreationArgs(1);
+ aCreationArgs[0] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ) ),
+ 0,
+ makeAny( KabDriver::impl_getConfigurationSettingsPath() ),
+ PropertyState_DIRECT_VALUE );
+ Reference< XPropertySet > xSettings( xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.configuration.ConfigurationAccess" ) ),
+ aCreationArgs ),
+ UNO_QUERY_THROW );
+
+ sal_Bool bDisableCheck = sal_False;
+ xSettings->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DisableKDEMaximumVersionCheck" ) ) ) >>= bDisableCheck;
+
+ return bDisableCheck != sal_False;
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return false;
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::impl_throwNoKdeException()
+{
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_NO_KDE_INST
+ ) );
+ impl_throwGenericSQLException( sError );
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::impl_throwKdeTooOldException()
+{
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_KDE_VERSION_TOO_OLD,
+ "$major$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MAJOR),
+ "$minor$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MINOR)
+ ) );
+ impl_throwGenericSQLException( sError );
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::impl_throwGenericSQLException( const ::rtl::OUString& _rMessage )
+{
+ SQLException aError;
+ aError.Message = _rMessage;
+ aError.SQLState = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) );
+ aError.ErrorCode = 0;
+ throw aError;
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::impl_throwKdeTooNewException()
+{
+ ::connectivity::SharedResources aResources;
+
+ SQLException aError;
+ aError.Message = aResources.getResourceStringWithSubstitution(
+ STR_KDE_VERSION_TOO_NEW,
+ "$major$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MAJOR),
+ "$minor$",::rtl::OUString::valueOf((sal_Int32)MIN_KDE_VERSION_MINOR)
+ );
+ aError.SQLState = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) );
+ aError.ErrorCode = 0;
+
+ SQLContext aDetails;
+ ::rtl::OUStringBuffer aMessage;
+ aMessage.append( aResources.getResourceString(STR_KDE_VERSION_TOO_NEW_WORK_AROUND) );
+
+ aMessage.appendAscii( "Sub disableKDEMaxVersionCheck\n" );
+ aMessage.appendAscii( " BasicLibraries.LoadLibrary( \"Tools\" )\n" );
+
+ aMessage.appendAscii( " Dim configNode as Object\n" );
+ aMessage.appendAscii( " configNode = GetRegistryKeyContent( \"" );
+ aMessage.append( KabDriver::impl_getConfigurationSettingsPath() );
+ aMessage.appendAscii( "\", true )\n" );
+
+ aMessage.appendAscii( " configNode.DisableKDEMaximumVersionCheck = TRUE\n" );
+ aMessage.appendAscii( " configNode.commitChanges\n" );
+ aMessage.appendAscii( "End Sub\n" );
+
+ aDetails.Message = aMessage.makeStringAndClear();
+
+ aError.NextException <<= aDetails;
+
+ throw aError;
+}
+
+// --------------------------------------------------------------------------------
+KabConnection* KabImplModule::createConnection( KabDriver* _pDriver ) const
+{
+ OSL_PRECOND( m_hConnectorModule, "KabImplModule::createConnection: not initialized!" );
+
+ void* pUntypedConnection = (*m_pConnectionFactoryFunc)( _pDriver );
+ if ( !pUntypedConnection )
+ throw RuntimeException();
+
+ return static_cast< KabConnection* >( pUntypedConnection );
+}
+
+// --------------------------------------------------------------------------------
+void KabImplModule::shutdown()
+{
+ if ( !m_hConnectorModule )
+ return;
+
+ (*m_pApplicationShutdownFunc)();
+ m_bAttemptedInitialize = false;
+
+ impl_unloadModule();
+}
+
+// =======================================================================
+// = KabDriver
+// =======================================================================
+KabDriver::KabDriver(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : KDriver_BASE(m_aMutex),
+ m_xMSFactory(_rxFactory),
+ m_aImplModule(_rxFactory)
+{
+ if ( !m_xMSFactory.is() )
+ throw NullPointerException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ Reference< XDesktop > xDesktop(
+ m_xMSFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
+ UNO_QUERY_THROW );
+ xDesktop->addTerminateListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// --------------------------------------------------------------------------------
+void KabDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroied so all our connections have to be destroied as well
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ WeakComponentImplHelperBase::disposing();
+}
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString KabDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii( impl_getAsciiImplementationName() );
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > KabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+
+ return aSNS;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+//------------------------------------------------------------------
+sal_Bool SAL_CALL KabDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+
+ while (pSupported != pEnd && !pSupported->equals(_rServiceName))
+ ++pSupported;
+ return pSupported != pEnd;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL KabDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL KabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aImplModule.init();
+
+ // create a new connection with the given properties and append it to our vector
+ KabConnection* pConnection = m_aImplModule.createConnection( this );
+ OSL_POSTCOND( pConnection, "KabDriver::connect: no connection has been created by the factory!" );
+
+ // by definition, the factory function returned an object which was acquired once
+ Reference< XConnection > xConnection = pConnection;
+ pConnection->release();
+
+ // late constructor call which can throw exception and allows a correct dtor call when so
+ pConnection->construct( url, info );
+
+ // remember it
+ m_xConnections.push_back( WeakReferenceHelper( *pConnection ) );
+
+ return xConnection;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL KabDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_aImplModule.isKDEPresent() )
+ return sal_False;
+
+ // here we have to look whether we support this URL format
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:address:kab:"), 16));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL KabDriver::getPropertyInfo( const ::rtl::OUString&, const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException)
+{
+ // if you have something special to say, return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return KAB_DRIVER_VERSION_MAJOR;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return KAB_DRIVER_VERSION_MINOR;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabDriver::queryTermination( const EventObject& ) throw (TerminationVetoException, RuntimeException)
+{
+ // nothing to do, nothing to veto
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabDriver::notifyTermination( const EventObject& ) throw (RuntimeException)
+{
+ m_aImplModule.shutdown();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL KabDriver::disposing( const EventObject& ) throw (RuntimeException)
+{
+ // not interested in (this is the disposing of the desktop, if any)
+}
+// --------------------------------------------------------------------------------
+const sal_Char* KabDriver::impl_getAsciiImplementationName()
+{
+ return "com.sun.star.comp.sdbc.kab.Driver";
+ // this name is referenced in the configuration and in the kab.xml
+ // Please be careful when changing it.
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString KabDriver::impl_getConfigurationSettingsPath()
+{
+ ::rtl::OUStringBuffer aPath;
+ aPath.appendAscii( "/org.openoffice.Office.DataAccess/DriverSettings/" );
+ aPath.appendAscii( "com.sun.star.comp.sdbc.kab.Driver" );
+ return aPath.makeStringAndClear();
+}
+// --------------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL KabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) throw( Exception )
+{
+ return *(new KabDriver(_rxFactory));
+}
+
diff --git a/connectivity/source/drivers/kab/KDriver.hxx b/connectivity/source/drivers/kab/KDriver.hxx
new file mode 100644
index 000000000000..5bceb27efdec
--- /dev/null
+++ b/connectivity/source/drivers/kab/KDriver.hxx
@@ -0,0 +1,223 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_DRIVER_HXX_
+#define _CONNECTIVITY_KAB_DRIVER_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase3.hxx>
+#include <osl/module.h>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ class KabConnection;
+ class KabDriver;
+
+ typedef void* (SAL_CALL * ConnectionFactoryFunction)( void* _pDriver );
+ typedef void (SAL_CALL * ApplicationInitFunction)( void );
+ typedef void (SAL_CALL * ApplicationShutdownFunction)( void );
+ typedef int (SAL_CALL * KDEVersionCheckFunction)( void );
+
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+
+ // ===============================================================
+ // = KabImplModule
+ // ===============================================================
+ class KabImplModule
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ /// Did we already attempt to load the module and to retrieve the symbols?
+ bool m_bAttemptedLoadModule;
+ /// Did we already check the KDE version and initialize the impl module (or at least attempted to)?
+ bool m_bAttemptedInitialize;
+
+ oslModule m_hConnectorModule;
+ ConnectionFactoryFunction m_pConnectionFactoryFunc;
+ ApplicationInitFunction m_pApplicationInitFunc;
+ ApplicationShutdownFunction m_pApplicationShutdownFunc;
+ KDEVersionCheckFunction m_pKDEVersionCheckFunc;
+
+ public:
+ KabImplModule( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
+
+ /** determines whether there is a KDE present in the environment
+ */
+ bool isKDEPresent();
+
+ enum KDEVersionType
+ {
+ eTooOld,
+ eSupported,
+ eToNew
+ };
+ /** checks whether the KDE version we're running against is supported
+ @precond
+ the module is loaded, i.e impl_loadModule has successfully been called
+ */
+ KDEVersionType matchKDEVersion();
+
+ /** initializes the implementation module.
+
+ @raises ::com::sun::star::uno::RuntimeException
+ if the module could be loaded, but required symbols are missing
+ @raises ::com::sun::star::sdbc::SQLException
+ if the KDE version we're running against is not supported, or no KDE was found at all
+ */
+ void init();
+
+ /** shuts down the impl module (and the KDE application, if we own it)
+ */
+ void shutdown();
+
+ /** creates a new connection
+ @precond
+ <member>init</member> has been called before
+ @raises ::com::sun::star::uno::RuntimeException
+ if no connection object could be created (which is a severe error, normally impossible)
+ */
+ KabConnection* createConnection( KabDriver* _pDriver ) const;
+
+ private:
+ /** loads the implementation module and retrieves the needed symbols
+
+ Save against being called multiple times.
+
+ @return <TRUE/> if the module could be loaded successfully.
+
+ @raises ::com::sun::star::uno::RuntimeException
+ if the module could be loaded, but required symbols are missing
+ */
+ bool impl_loadModule();
+
+ /** unloads the implementation module, and resets all function pointers to <NULL/>
+ @precond m_hConnectorModule is not <NULL/>
+ */
+ void impl_unloadModule();
+
+ /** throws an SQLException saying than no KDE installation was found
+ */
+ void impl_throwNoKdeException();
+
+ /** throws an SQLException saying that the found KDE version is too old
+ */
+ void impl_throwKdeTooOldException();
+
+ /** throws an SQLException saying that the found KDE version is too new
+ */
+ void impl_throwKdeTooNewException();
+
+ /** throws a generic SQL exception with SQLState S1000 and error code 0
+ */
+ void impl_throwGenericSQLException( const ::rtl::OUString& _rMessage );
+
+ /** determines whether it's allowed to run on a too-new (not confirmed to work) version
+ */
+ bool impl_doAllowNewKDEVersion();
+ };
+
+ // ===============================================================
+ // = KabDriver
+ // ===============================================================
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::frame::XTerminateListener > KDriver_BASE;
+ class KabDriver : public KDriver_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ OWeakRefArray m_xConnections; // vector containing a list of all the
+ // KabConnection objects for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xMSFactory; // the multi-service factory
+ KabImplModule m_aImplModule;
+
+ public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ getMSFactory() const { return m_xMSFactory; }
+
+ /** returns the driver's implementation name (being pure ASCII) for reference in various places
+ */
+ static const sal_Char* impl_getAsciiImplementationName();
+
+ /** returns the path of our configuration settings
+ */
+ static ::rtl::OUString impl_getConfigurationSettingsPath();
+
+ protected:
+ KabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMajorVersion() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinorVersion() throw(::com::sun::star::uno::RuntimeException);
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** shuts down the library which contains the real implementations
+
+ This method is safe against being called multiple times
+
+ @precond our mutex is locked
+ */
+ void impl_shutdownImplementationModule();
+ };
+ }
+
+}
+
+#endif // _CONNECTIVITY_KAB_DRIVER_HXX_
diff --git a/connectivity/source/drivers/kab/KPreparedStatement.cxx b/connectivity/source/drivers/kab/KPreparedStatement.cxx
new file mode 100644
index 000000000000..02bdd32ef90b
--- /dev/null
+++ b/connectivity/source/drivers/kab/KPreparedStatement.cxx
@@ -0,0 +1,390 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KPreparedStatement.hxx"
+#include "propertyids.hxx"
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+#include "resource/kab_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity::kab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(KabPreparedStatement, "com.sun.star.sdbc.drivers.KabPreparedStatement", "com.sun.star.sdbc.PreparedStatement");
+// -------------------------------------------------------------------------
+void KabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) throw(SQLException)
+{
+ if ( !m_aParameterRow.isValid() )
+ m_aParameterRow = new OValueVector();
+
+ if (nParams < 1)
+ ::dbtools::throwInvalidIndexException(*(KabPreparedStatement *) this,Any());
+
+ if (nParams >= (sal_Int32) (m_aParameterRow->get()).size())
+ (m_aParameterRow->get()).resize(nParams);
+}
+// -------------------------------------------------------------------------
+void KabPreparedStatement::setKabFields() const throw(SQLException)
+{
+ ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns
+
+ xColumns = m_aSQLIterator.getSelectColumns();
+ if (!xColumns.isValid())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_INVALID_COLUMN_SELECTION
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+ m_xMetaData->setKabFields(xColumns);
+}
+// -------------------------------------------------------------------------
+void KabPreparedStatement::resetParameters() const throw(SQLException)
+{
+ m_nParameterIndex = 0;
+}
+// -------------------------------------------------------------------------
+void KabPreparedStatement::getNextParameter(::rtl::OUString &rParameter) const throw(SQLException)
+{
+ if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_INVALID_PARA_COUNT
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*(KabPreparedStatement *) this);
+ } // if (m_nParameterIndex >= (sal_Int32) (*m_aParameterRow).size())
+
+ rParameter = (m_aParameterRow->get())[m_nParameterIndex];
+
+ m_nParameterIndex++;
+}
+// -------------------------------------------------------------------------
+KabPreparedStatement::KabPreparedStatement(
+ KabConnection* _pConnection,
+ const ::rtl::OUString& sql)
+ : KabPreparedStatement_BASE(_pConnection),
+ m_sSqlStatement(sql),
+ m_bPrepared(sal_False),
+ m_nParameterIndex(0),
+ m_aParameterRow()
+{
+}
+// -------------------------------------------------------------------------
+KabPreparedStatement::~KabPreparedStatement()
+{
+}
+// -------------------------------------------------------------------------
+void KabPreparedStatement::disposing()
+{
+ KabPreparedStatement_BASE::disposing();
+
+ if (m_aParameterRow.isValid())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+}
+// -------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL KabPreparedStatement::getMetaData() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ if (!m_xMetaData.is())
+ {
+ m_xMetaData = new KabResultSetMetaData(getOwnConnection());
+ setKabFields();
+ }
+ Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
+ return xMetaData;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::close() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // Reset last warning message
+ try {
+ clearWarnings ();
+ KabCommonStatement::close();
+ }
+ catch (SQLException &) {
+ // If we get an error, ignore
+ }
+
+ // Remove this Statement object from the Connection object's
+ // list
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabPreparedStatement::execute() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet> xRS = KabCommonStatement::executeQuery(m_sSqlStatement);
+
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabPreparedStatement::executeUpdate() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // same as in statement with the difference that this statement also can contain parameter
+ return 0;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL KabPreparedStatement::getConnection() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >) m_pConnection;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabPreparedStatement::executeQuery() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > rs = KabCommonStatement::executeQuery(m_sSqlStatement);
+
+ return rs;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex - 1].setNull();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setObjectNull", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBoolean", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setByte", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setShort", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setInt", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setFloat(sal_Int32, float) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setFloat", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setDouble(sal_Int32, double) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setDouble", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setString(sal_Int32 parameterIndex, const ::rtl::OUString &x) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex - 1] = x;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBytes", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setDate(sal_Int32, const Date&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setDate", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setTime(sal_Int32, const Time&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setTime", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setTimestamp", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setBinaryStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBinaryStream", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setCharacterStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setCharacterStream", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x) throw(SQLException, RuntimeException)
+{
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ throw SQLException();
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setObjectWithInfo", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setRef", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBlob", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setClob", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setArray", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabPreparedStatement::clearParameters() throw(SQLException, RuntimeException)
+{
+::dbtools::throwFunctionNotSupportedException("clearParameters", NULL);
+}
+// -------------------------------------------------------------------------
+void KabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ break;
+ default:
+ KabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+}
diff --git a/connectivity/source/drivers/kab/KPreparedStatement.hxx b/connectivity/source/drivers/kab/KPreparedStatement.hxx
new file mode 100644
index 000000000000..779bdf22e620
--- /dev/null
+++ b/connectivity/source/drivers/kab/KPreparedStatement.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_
+
+#include "KStatement.hxx"
+#include "KResultSetMetaData.hxx"
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplInheritanceHelper4< KabCommonStatement,
+ ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::lang::XServiceInfo> KabPreparedStatement_BASE;
+
+ class KabPreparedStatement : public KabPreparedStatement_BASE
+ {
+ protected:
+ ::rtl::OUString m_sSqlStatement;
+ ::rtl::Reference< KabResultSetMetaData >
+ m_xMetaData;
+ sal_Bool m_bPrepared;
+ mutable sal_Int32 m_nParameterIndex;
+ OValueRow m_aParameterRow;
+
+ void checkAndResizeParameters(sal_Int32 nParams) throw(::com::sun::star::sdbc::SQLException);
+ void setKabFields() const throw(::com::sun::star::sdbc::SQLException);
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+
+ virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
+ virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
+ virtual ~KabPreparedStatement();
+
+ public:
+ DECLARE_SERVICE_INFO();
+ KabPreparedStatement(KabConnection* _pConnection, const ::rtl::OUString& sql);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_PREPAREDSTATEMENT_HXX_
diff --git a/connectivity/source/drivers/kab/KResultSet.cxx b/connectivity/source/drivers/kab/KResultSet.cxx
new file mode 100644
index 000000000000..22df0c4854c5
--- /dev/null
+++ b/connectivity/source/drivers/kab/KResultSet.cxx
@@ -0,0 +1,987 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KResultSet.hxx"
+#include "KResultSetMetaData.hxx"
+#include "KConnection.hxx"
+#include "kcondition.hxx"
+#include "korder.hxx"
+#include "kfields.hxx"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include "TConnection.hxx"
+#include <connectivity/dbexception.hxx>
+#include "resource/kab_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity::kab;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(KabResultSet, "com.sun.star.sdbc.drivers.KabResultSet", "com.sun.star.sdbc.ResultSet");
+// -------------------------------------------------------------------------
+KabResultSet::KabResultSet(KabCommonStatement* pStmt)
+ : KabResultSet_BASE(m_aMutex),
+ OPropertySetHelper(KabResultSet_BASE::rBHelper),
+ m_xStatement(pStmt),
+ m_xMetaData(NULL),
+ m_aKabAddressees(),
+ m_nRowPos(-1),
+ m_bWasNull(sal_True)
+{
+}
+// -------------------------------------------------------------------------
+KabResultSet::~KabResultSet()
+{
+}
+// -------------------------------------------------------------------------
+void KabResultSet::allKabAddressees()
+{
+ KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get());
+ KABC::AddressBook* pAddressBook = pConnection->getAddressBook();
+
+ m_aKabAddressees = pAddressBook->allAddressees();
+}
+// -------------------------------------------------------------------------
+void KabResultSet::someKabAddressees(const KabCondition *pCondition)
+{
+ KabConnection* pConnection = static_cast< KabConnection *>(m_xStatement->getConnection().get());
+ KABC::AddressBook* pAddressBook = pConnection->getAddressBook();
+
+ KABC::AddressBook::Iterator iterator;
+
+ for (iterator = pAddressBook->begin();
+ iterator != pAddressBook->end();
+ ++iterator)
+ {
+ if (pCondition->eval(*iterator))
+ m_aKabAddressees.push_back(*iterator);
+ }
+}
+// -------------------------------------------------------------------------
+void KabResultSet::sortKabAddressees(const KabOrder *pOrder)
+{
+ // We do not use class KAddresseeList, which has a sorting algorithm in it, because
+ // it uses templates. It would expand to more or less the same code as the one
+ // which follows, but it would need not be called in a much less convenient way.
+
+ KABC::Addressee::List::Iterator
+ begin = m_aKabAddressees.begin(),
+ end = m_aKabAddressees.end(),
+ iterator;
+
+ // Bubble sort. Feel free to implement a better algorithm.
+ while (begin != end)
+ {
+ end--;
+ for (iterator = begin; iterator != end; ++iterator)
+ {
+ if (pOrder->compare(*iterator, *end) > 0)
+ qSwap(*iterator, *end);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+void KabResultSet::disposing()
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+m_xStatement.clear();
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL KabResultSet::queryInterface(const Type & rType) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if (!aRet.hasValue())
+ aRet = KabResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::acquire() throw()
+{
+ KabResultSet_BASE::acquire();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::release() throw()
+{
+ KabResultSet_BASE::release();
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL KabResultSet::getTypes() throw(RuntimeException)
+{
+ OTypeCollection aTypes(
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet >*) 0),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet >*) 0),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet >*) 0));
+
+ return comphelper::concatSequences(aTypes.getTypes(), KabResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL KabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSet::findColumn(const ::rtl::OUString& columnName) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // find the first column with the name columnName
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+
+ for (sal_Int32 i = 1; i <= nLen; ++i)
+ if (xMeta->isCaseSensitive(i) ?
+ columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ return i;
+
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$",columnName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSet::getString(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString aRet;
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ ::KABC::Field::List aFields = ::KABC::Field::allFields();
+
+ if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ QString aQtName;
+
+ switch (nFieldNumber)
+ {
+ case KAB_FIELD_REVISION:
+// trigger an exception here
+m_bWasNull = true;
+return aRet;
+ default:
+ aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->value(m_aKabAddressees[m_nRowPos]);
+ }
+// KDE address book currently does not use NULL values.
+// But it might do it someday
+ if (!aQtName.isNull())
+ {
+ m_bWasNull = false;
+ aRet = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
+ return aRet;
+ }
+ }
+// Trigger an exception ?
+ m_bWasNull = true;
+ return aRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::getBoolean(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBoolean", NULL);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL KabResultSet::getByte(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getByte", NULL);
+
+ sal_Int8 nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL KabResultSet::getShort(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getShort", NULL);
+
+ sal_Int16 nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSet::getInt(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getInt", NULL);
+
+ sal_Int32 nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL KabResultSet::getLong(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getLong", NULL);
+
+ return sal_Int64();
+}
+// -------------------------------------------------------------------------
+float SAL_CALL KabResultSet::getFloat(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getFloat", NULL);
+
+ float nVal(0);
+ return nVal;
+}
+// -------------------------------------------------------------------------
+double SAL_CALL KabResultSet::getDouble(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getDouble", NULL);
+
+ double nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL KabResultSet::getBytes(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("", NULL);
+
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+Date SAL_CALL KabResultSet::getDate(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getDate", NULL);
+
+ Date aRet;
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Time SAL_CALL KabResultSet::getTime(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getTime", NULL);
+
+ Time nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+DateTime SAL_CALL KabResultSet::getTimestamp(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ DateTime nRet;
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+
+ if (m_nRowPos != -1 && m_nRowPos != nAddressees && m_xMetaData.is())
+ {
+ KabResultSetMetaData *pMeta = static_cast<KabResultSetMetaData *>(m_xMetaData.get());
+ sal_Int32 nFieldNumber = pMeta->fieldAtColumn(columnIndex);
+
+ if (nFieldNumber == KAB_FIELD_REVISION)
+ {
+ QDateTime nRevision(m_aKabAddressees[m_nRowPos].revision());
+
+ if (!nRevision.isNull())
+ {
+ m_bWasNull = false;
+ nRet.Year = nRevision.date().year();
+ nRet.Month = nRevision.date().month();
+ nRet.Day = nRevision.date().day();
+ nRet.Hours = nRevision.time().hour();
+ nRet.Minutes = nRevision.time().minute();
+ nRet.Seconds = nRevision.time().second();
+ nRet.HundredthSeconds = nRevision.time().msec() / 10;
+ return nRet;
+ }
+ }
+ else {
+ ;
+ }
+// trigger an exception here
+ }
+// Trigger an exception ?
+ m_bWasNull = true;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL KabResultSet::getBinaryStream(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBinaryStream", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL KabResultSet::getCharacterStream(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getCharacterStream", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL KabResultSet::getObject(sal_Int32, const Reference< ::com::sun::star::container::XNameAccess >&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getObject", NULL);
+
+ return Any();
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL KabResultSet::getRef(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getRef", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL KabResultSet::getBlob(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBlob", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL KabResultSet::getClob(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getClob", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL KabResultSet::getArray(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getArray", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL KabResultSet::getMetaData() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ if (!m_xMetaData.is())
+ m_xMetaData = new KabResultSetMetaData(m_xStatement->getOwnConnection());
+
+ Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
+ return xMetaData;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::isBeforeFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ if (m_nRowPos == -1)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::isAfterLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ if (m_nRowPos == nAddressees)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::isFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ if (m_nRowPos == 0)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::isLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ if (m_nRowPos == nAddressees - 1)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::beforeFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // move before the first row
+ m_nRowPos = -1;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::afterLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // move after the last row
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ m_nRowPos = nAddressees;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::close() throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::first() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ if (nAddressees == 0)
+ return sal_False;
+
+ m_nRowPos = 0;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::last() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ if (nAddressees == 0)
+ return sal_False;
+
+ m_nRowPos = nAddressees - 1;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSet::getRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nRowPos;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::absolute(sal_Int32 row) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+ if (row <= -1 ||
+ row >= nAddressees)
+ return sal_False;
+
+ m_nRowPos = row;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos + row);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::next() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos + 1);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::previous() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos - 1);
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL KabResultSet::getStatement() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ Reference< XStatement > xStatement = m_xStatement.get();
+ return xStatement;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::rowDeleted() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::rowInserted() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::rowUpdated() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::wasNull() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::cancel() throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::clearWarnings() throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL KabResultSet::getWarnings() throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::insertRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // you only have to implement this if you want to insert new rows
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // only when you allow updates
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::deleteRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::cancelRowUpdates() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::moveToInsertRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ // only when you allow inserts
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::moveToCurrentRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateNull(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException)
+{
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -----------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateFloat(sal_Int32, float) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateDouble(sal_Int32, double) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateString(sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateDate(sal_Int32, const Date&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateTime(sal_Int32, const Time&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::refreshRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateObject(sal_Int32, const Any&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL KabResultSet::getBookmark() throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+
+ if (m_nRowPos != -1 && m_nRowPos != nAddressees)
+ {
+ QString aQtName = m_aKabAddressees[m_nRowPos].uid();
+ ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
+ return makeAny(sUniqueIdentifier);
+ }
+ return Any();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sBookmark = comphelper::getString(bookmark);
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+
+ for (sal_Int32 nRow = 0; nRow < nAddressees; nRow++)
+ {
+ QString aQtName = m_aKabAddressees[nRow].uid();
+ ::rtl::OUString sUniqueIdentifier = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
+
+ if (sUniqueIdentifier == sBookmark)
+ {
+ m_nRowPos = nRow;
+ return sal_True;
+ }
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRowSave = m_nRowPos;
+
+ if (moveToBookmark(bookmark))
+ {
+ sal_Int32 nAddressees = m_aKabAddressees.size();
+
+ m_nRowPos += rows;
+
+ if (-1 < m_nRowPos && m_nRowPos < nAddressees)
+ return sal_True;
+ }
+
+ m_nRowPos = nRowSave;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sFirst = comphelper::getString(firstItem);
+ ::rtl::OUString sSecond = comphelper::getString(secondItem);
+
+ if (sFirst < sSecond)
+ return CompareBookmark::LESS;
+ if (sFirst > sSecond)
+ return CompareBookmark::GREATER;
+ return CompareBookmark::EQUAL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sBookmark = comphelper::getString(bookmark);
+
+ return sBookmark.hashCode();
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL KabResultSet::deleteRows(const Sequence< Any >&) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabResultSet_BASE::rBHelper.bDisposed);
+
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* KabResultSet::createArrayHelper() const
+{
+ Sequence< Property > aProps(6);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & KabResultSet::getInfoHelper()
+{
+ return *static_cast<KabResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool KabResultSet::convertFastPropertyValue(
+ Any &,
+ Any &,
+ sal_Int32 nHandle,
+ const Any& )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void KabResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& )
+ throw (Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void KabResultSet::getFastPropertyValue(
+ Any& _rValue,
+ sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ _rValue <<= (sal_Bool)sal_False;
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ ;
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/kab/KResultSet.hxx b/connectivity/source/drivers/kab/KResultSet.hxx
new file mode 100644
index 000000000000..9cabb48980be
--- /dev/null
+++ b/connectivity/source/drivers/kab/KResultSet.hxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_RESULTSET_HXX_
+#define _CONNECTIVITY_KAB_RESULTSET_HXX_
+
+#include "KStatement.hxx"
+#include "KResultSetMetaData.hxx"
+#include <shell/kde_headers.h>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/compbase12.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ /*
+ ** KabResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::lang::XServiceInfo> KabResultSet_BASE;
+
+ class KabResultSet : public comphelper::OBaseMutex,
+ public KabResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public comphelper::OPropertyArrayUsageHelper<KabResultSet>
+ {
+ protected:
+ ::rtl::Reference< KabCommonStatement > m_xStatement; // the statement that has created this result set
+ ::rtl::Reference< KabResultSetMetaData > m_xMetaData; // the description of the columns in this result set
+ ::KABC::Addressee::List m_aKabAddressees; // address book entries matching the query
+ sal_Int32 m_nRowPos; // the current row within the result set
+ sal_Bool m_bWasNull; // last entry retrieved from this result set was NULL
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+
+ // you can't delete objects of this type
+ virtual ~KabResultSet();
+
+ public:
+ DECLARE_SERVICE_INFO();
+
+ KabResultSet(KabCommonStatement *pStmt);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(KabResultSet_BASE*) this);
+ }
+
+ void allKabAddressees();
+ void someKabAddressees(const class KabCondition *pCondition);
+ void sortKabAddressees(const class KabOrder *pOrder);
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XResultSet
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& firstItem, const ::com::sun::star::uno::Any& secondItem ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_RESULTSET_HXX_
diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.cxx b/connectivity/source/drivers/kab/KResultSetMetaData.cxx
new file mode 100644
index 000000000000..c36b166b2a73
--- /dev/null
+++ b/connectivity/source/drivers/kab/KResultSetMetaData.cxx
@@ -0,0 +1,187 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KResultSetMetaData.hxx"
+#include "kfields.hxx"
+#include "KDatabaseMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+
+using namespace connectivity::kab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+KabResultSetMetaData::KabResultSetMetaData(KabConnection* _pConnection)
+ : m_pConnection(_pConnection),
+ m_aKabFields()
+{
+}
+// -------------------------------------------------------------------------
+KabResultSetMetaData::~KabResultSetMetaData()
+{
+}
+// -------------------------------------------------------------------------
+void KabResultSetMetaData::setKabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
+{
+ OSQLColumns::Vector::const_iterator aIter;
+ static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
+
+ for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
+ {
+ ::rtl::OUString aFieldName;
+ sal_uInt32 nFieldNumber;
+
+ (*aIter)->getPropertyValue(aName) >>= aFieldName;
+ nFieldNumber = findKabField(aFieldName);
+ m_aKabFields.push_back(nFieldNumber);
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ return m_aKabFields[column - 1] < KAB_DATA_FIELDS? 20: 50;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ return m_aKabFields[column - 1] == KAB_FIELD_REVISION? DataType::TIMESTAMP: DataType::CHAR;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException)
+{
+ return m_aKabFields.size();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nFieldNumber = m_aKabFields[column - 1];
+ ::KABC::Field::List aFields = ::KABC::Field::allFields();
+ QString aQtName;
+
+ switch (nFieldNumber)
+ {
+ case KAB_FIELD_REVISION:
+ aQtName = KABC::Addressee::revisionLabel();
+ break;
+ default:
+ aQtName = aFields[nFieldNumber - KAB_DATA_FIELDS]->label();
+ }
+ ::rtl::OUString aName((const sal_Unicode *) aQtName.ucs2());
+
+ return aName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return KabDatabaseMetaData::getAddressBookTableName();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL KabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return (sal_Int32) sal_True;
+// KDE address book currently does not use NULL values.
+// But it might do it someday
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/kab/KResultSetMetaData.hxx b/connectivity/source/drivers/kab/KResultSetMetaData.hxx
new file mode 100644
index 000000000000..2ee6ababa91a
--- /dev/null
+++ b/connectivity/source/drivers/kab/KResultSetMetaData.hxx
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_
+
+#include "KConnection.hxx"
+#include <connectivity/CommonTools.hxx>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vos/ref.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ /*
+ ** KabResultSetMetaData
+ */
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> KabResultSetMetaData_BASE;
+
+ class KabResultSetMetaData : public KabResultSetMetaData_BASE
+ {
+ KabConnection* m_pConnection;
+ ::std::vector<sal_Int32> m_aKabFields; // for each selected column, contains the number
+ // of the corresponding KAddressBook field
+
+ protected:
+ virtual ~KabResultSetMetaData();
+
+ public:
+ KabResultSetMetaData(KabConnection* _pConnection);
+
+ // avoid ambigous cast error from the compiler
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ void setKabFields(
+ const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(::com::sun::star::sdbc::SQLException);
+ inline sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const
+ { return m_aKabFields[columnIndex - 1]; }
+
+ virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_RESULTSETMETADATA_HXX_
diff --git a/connectivity/source/drivers/kab/KServices.cxx b/connectivity/source/drivers/kab/KServices.cxx
new file mode 100644
index 000000000000..5a0f4c3f9917
--- /dev/null
+++ b/connectivity/source/drivers/kab/KServices.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::kab;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pTemp
+ );
+
+//***************************************************************************************
+//
+// The following C Api must be provided!
+// It consists in three functions that must be exported by the module
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "KAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void*,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ KabDriver::getImplementationName_Static(),
+ KabDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "KAB::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void*)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ KabDriver::getImplementationName_Static(),
+ KabDriver::getSupportedServiceNames_Static(),
+ &KabDriver::Create,
+ ::cppu::createSingleFactory)
+ ;
+
+ if (aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/kab/KStatement.cxx b/connectivity/source/drivers/kab/KStatement.cxx
new file mode 100644
index 000000000000..f0069fc6875e
--- /dev/null
+++ b/connectivity/source/drivers/kab/KStatement.cxx
@@ -0,0 +1,584 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KStatement.hxx"
+#include "KConnection.hxx"
+#include "KDriver.hxx"
+#include "KResultSet.hxx"
+#include "KResultSetMetaData.hxx"
+#include "kcondition.hxx"
+#include "korder.hxx"
+#include "TConnection.hxx"
+#include <connectivity/dbexception.hxx>
+#include "resource/kab_res.hrc"
+#include "resource/sharedresources.hxx"
+
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace connectivity::kab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+namespace
+{
+ void lcl_throwError(sal_uInt16 _nErrorId)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(_nErrorId) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+}
+
+IMPLEMENT_SERVICE_INFO(KabStatement, "com.sun.star.sdbc.drivers.KabStatement", "com.sun.star.sdbc.Statement");
+//------------------------------------------------------------------------------
+KabCommonStatement::KabCommonStatement(KabConnection* _pConnection )
+ : KabCommonStatement_BASE(m_aMutex),
+ OPropertySetHelper(KabCommonStatement_BASE::rBHelper),
+ m_aParser(_pConnection->getDriver()->getMSFactory()),
+ m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ),
+ m_pParseTree(NULL),
+ m_pConnection(_pConnection),
+ rBHelper(KabCommonStatement_BASE::rBHelper)
+{
+ m_pConnection->acquire();
+}
+// -----------------------------------------------------------------------------
+KabCommonStatement::~KabCommonStatement()
+{
+}
+// -----------------------------------------------------------------------------
+void KabCommonStatement::disposing()
+{
+ KabCommonStatement_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+void KabCommonStatement::resetParameters() const throw(::com::sun::star::sdbc::SQLException)
+{
+ lcl_throwError(STR_PARA_ONLY_PREPARED);
+}
+// -----------------------------------------------------------------------------
+void KabCommonStatement::getNextParameter(::rtl::OUString &) const throw(::com::sun::star::sdbc::SQLException)
+{
+ lcl_throwError(STR_PARA_ONLY_PREPARED);
+}
+// -----------------------------------------------------------------------------
+KabCondition *KabCommonStatement::analyseWhereClause(const OSQLParseNode *pParseNode) const throw(SQLException)
+{
+ if (pParseNode->count() == 3)
+ {
+ const OSQLParseNode *pLeft = pParseNode->getChild(0),
+ *pMiddle = pParseNode->getChild(1),
+ *pRight = pParseNode->getChild(2);
+
+ // WHERE ( ... ) ?
+ if (SQL_ISPUNCTUATION(pLeft, "(") && SQL_ISPUNCTUATION(pRight, ")"))
+ {
+ return analyseWhereClause(pMiddle);
+ }
+ else if (SQL_ISRULE(pParseNode, comparison_predicate))
+ {
+ if (pLeft->isToken() && pRight->isToken())
+ {
+ switch (pMiddle->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // WHERE 0 = 1
+ return new KabConditionConstant(pLeft->getTokenValue() == pRight->getTokenValue());
+
+ case SQL_NODE_NOTEQUAL:
+ // WHERE 0 <> 1
+ // (might not be correct SQL... don't care, handling anyway)
+ return new KabConditionConstant(pLeft->getTokenValue() != pRight->getTokenValue());
+
+ default:
+ break;
+ }
+ }
+ else if (SQL_ISRULE(pLeft, column_ref))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (pRight->isToken() || SQL_ISRULE(pRight, parameter))
+ {
+ ::rtl::OUString sMatchString;
+
+ if (pRight->isToken()) // WHERE Name = 'Doe'
+ sMatchString = pRight->getTokenValue();
+ else if (SQL_ISRULE(pRight, parameter)) // WHERE Name = ?
+ getNextParameter(sMatchString);
+
+ switch (pMiddle->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // WHERE Name = 'Smith'
+ return new KabConditionEqual(sColumnName, sMatchString);
+
+ case SQL_NODE_NOTEQUAL:
+ // WHERE Name <> 'Jones'
+ return new KabConditionDifferent(sColumnName, sMatchString);
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, search_condition))
+ {
+ if (SQL_ISTOKEN(pMiddle, OR))
+ {
+ // WHERE Name = 'Smith' OR Name = 'Jones'
+ return new KabConditionOr(
+ analyseWhereClause(pLeft),
+ analyseWhereClause(pRight));
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, boolean_term))
+ {
+ if (SQL_ISTOKEN(pMiddle, AND))
+ {
+ // WHERE Name = 'Smith' AND "Given Name" = 'Peter'
+ return new KabConditionAnd(
+ analyseWhereClause(pLeft),
+ analyseWhereClause(pRight));
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, test_for_null) || SQL_ISRULE(pParseNode, like_predicate))
+ {
+ const OSQLParseNode *pLeft = pParseNode->getChild(0);
+ const OSQLParseNode* pPart2 = pParseNode->getChild(1);
+ const OSQLParseNode *pMiddleLeft = pPart2->getChild(0),
+ *pMiddleRight = pPart2->getChild(1),
+ *pRight = pPart2->getChild(2);
+
+ if (SQL_ISRULE(pParseNode, test_for_null))
+ {
+ if (SQL_ISRULE(pLeft, column_ref) &&
+ SQL_ISTOKEN(pMiddleLeft, IS) &&
+ SQL_ISTOKEN(pRight, NULL))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (SQL_ISTOKEN(pMiddleRight, NOT))
+ {
+ // WHERE "Mobile Phone" IS NOT NULL
+ return new KabConditionNotNull(sColumnName);
+ }
+ else
+ {
+ // WHERE "Mobile Phone" IS NULL
+ return new KabConditionNull(sColumnName);
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, like_predicate))
+ {
+ if (SQL_ISRULE(pLeft, column_ref))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (pMiddleRight->isToken() || SQL_ISRULE(pMiddleRight, parameter))
+ {
+ ::rtl::OUString sMatchString;
+
+ if (pMiddleRight->isToken()) // WHERE Name LIKE 'Sm%'
+ sMatchString = pMiddleRight->getTokenValue();
+ else if (SQL_ISRULE(pMiddleRight, parameter)) // WHERE Name LIKE ?
+ getNextParameter(sMatchString);
+
+ return new KabConditionSimilar(sColumnName, sMatchString);
+ }
+ }
+ }
+ }
+
+ lcl_throwError(STR_QUERY_TOO_COMPLEX);
+
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+// -----------------------------------------------------------------------------
+KabOrder *KabCommonStatement::analyseOrderByClause(const OSQLParseNode *pParseNode) const throw(SQLException)
+{
+ if (SQL_ISRULE(pParseNode, ordering_spec_commalist))
+ {
+ KabComplexOrder *list = new KabComplexOrder();
+ sal_uInt32 n = pParseNode->count();
+
+ // Iterate through the ordering columns
+ for (sal_uInt32 i = 0; i < n; i++)
+ {
+ list->addOrder
+ (analyseOrderByClause(pParseNode->getChild(i)));
+ }
+
+ return list;
+ }
+ else if (SQL_ISRULE(pParseNode, ordering_spec))
+ {
+ if (pParseNode->count() == 2)
+ {
+ OSQLParseNode* pColumnRef = pParseNode->getChild(0);
+ OSQLParseNode* pAscendingDescending = pParseNode->getChild(1);
+
+ if (SQL_ISRULE(pColumnRef, column_ref))
+ {
+ if (pColumnRef->count() == 3)
+ pColumnRef = pColumnRef->getChild(2);
+
+ if (pColumnRef->count() == 1)
+ {
+ ::rtl::OUString sColumnName =
+ pColumnRef->getChild(0)->getTokenValue();
+ sal_Bool bAscending =
+ SQL_ISTOKEN(pAscendingDescending, DESC)?
+ sal_False:
+ sal_True;
+
+ return new KabSimpleOrder(sColumnName, bAscending);
+ }
+ }
+ }
+ }
+ lcl_throwError(STR_QUERY_TOO_COMPLEX);
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+//------------------------------------------------------------------------------
+sal_Bool KabCommonStatement::isTableKnown(KabResultSet *pResult) const
+{
+ // can handle requests like SELECT * FROM addresses addresses
+ // but cannot handle requests like SELECT * FROM addresses persons
+ if (m_aSQLIterator.getTables().size() != 1)
+ return sal_False;
+
+ if (m_aSQLIterator.getTables().begin()->first != pResult->getMetaData()->getTableName(0))
+ return sal_False;
+
+ return sal_True;
+}
+//------------------------------------------------------------------------------
+void KabCommonStatement::setKabFields(KabResultSet *pResult) const throw(SQLException)
+{
+ ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns
+ KabResultSetMetaData *pMeta; // meta information - holds the list of KAddressBook fields
+
+ xColumns = m_aSQLIterator.getSelectColumns();
+ if (!xColumns.isValid())
+ {
+ lcl_throwError(STR_INVALID_COLUMN_SELECTION);
+ }
+ pMeta = static_cast<KabResultSetMetaData *>(pResult->getMetaData().get());
+ pMeta->setKabFields(xColumns);
+}
+// -------------------------------------------------------------------------
+void KabCommonStatement::selectAddressees(KabResultSet *pResult) const throw(SQLException)
+{
+ const OSQLParseNode *pParseNode;
+ KabCondition *pCondition;
+
+ pParseNode = m_aSQLIterator.getWhereTree();
+ if (pParseNode != NULL)
+ {
+ if (SQL_ISRULE(pParseNode, where_clause))
+ {
+ resetParameters();
+ pParseNode = pParseNode->getChild(1);
+ pCondition = analyseWhereClause(pParseNode);
+ if (pCondition->isAlwaysTrue())
+ pResult->allKabAddressees();
+ else if (!pCondition->isAlwaysFalse())
+ pResult->someKabAddressees(pCondition);
+ delete pCondition;
+ return;
+ }
+ }
+
+ // no WHERE clause: get all rows
+ pResult->allKabAddressees();
+}
+// -------------------------------------------------------------------------
+void KabCommonStatement::sortAddressees(KabResultSet *pResult) const throw(SQLException)
+{
+ const OSQLParseNode *pParseNode;
+ KabOrder *pOrder;
+
+ pParseNode = m_aSQLIterator.getOrderTree();
+ if (pParseNode != NULL)
+ {
+ if (SQL_ISRULE(pParseNode, opt_order_by_clause))
+ {
+ pParseNode = pParseNode->getChild(2);
+ pOrder = analyseOrderByClause(pParseNode);
+ pResult->sortKabAddressees(pOrder);
+ delete pOrder;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL KabCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = KabCommonStatement_BASE::queryInterface(rType);
+ if (!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL KabCommonStatement::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return comphelper::concatSequences(aTypes.getTypes(),KabCommonStatement_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabCommonStatement::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+ // cancel the current sql statement
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabCommonStatement::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL KabCommonStatement::execute(
+ const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > xRS = executeQuery(sql);
+
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL KabCommonStatement::executeQuery(
+ const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+OSL_TRACE("KDE Address book - SQL Request: %s", OUtoCStr(sql));
+
+ KabResultSet* pResult = new KabResultSet(this);
+ Reference< XResultSet > xRS = pResult;
+ ::rtl::OUString aErr;
+
+ m_pParseTree = m_aParser.parseTree(aErr, sql);
+ if (m_pParseTree == NULL)
+ throw SQLException(aErr, *this, aErr, 0, Any());
+
+ m_aSQLIterator.setParseTree(m_pParseTree);
+ m_aSQLIterator.traverseAll();
+ switch (m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+ if (isTableKnown(pResult)) // FROM which table ?
+ {
+ setKabFields(pResult); // SELECT which columns ?
+ selectAddressees(pResult); // WHERE which condition ?
+ sortAddressees(pResult); // ORDER BY which columns ?
+// To be continued: DISTINCT
+// etc...
+ }
+ break;
+
+ default:
+// To be continued: UPDATE
+// DELETE
+// etc...
+ lcl_throwError(STR_QUERY_TOO_COMPLEX);
+ }
+
+ return xRS;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL KabCommonStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // just return our connection here
+ return (Reference< XConnection >) m_pConnection;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL KabCommonStatement::executeUpdate( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // the return values gives information about how many rows are affected by executing the sql statement
+ return 0;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL KabCommonStatement::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL KabCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(KabCommonStatement_BASE::rBHelper.bDisposed);
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* KabCommonStatement::createArrayHelper( ) const
+{
+ // this properties are defined by the service statement
+ // they must be in alphabetic order
+ Sequence< Property > aProps(10);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & KabCommonStatement::getInfoHelper()
+{
+ return *const_cast<KabCommonStatement*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool KabCommonStatement::convertFastPropertyValue(
+ Any &,
+ Any &,
+ sal_Int32,
+ const Any&) throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bConverted = sal_False;
+ // here we have to try to convert
+ return bConverted;
+}
+// -------------------------------------------------------------------------
+void KabCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any&) throw (Exception)
+{
+ // set the value to whatever is nescessary
+ switch (nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void KabCommonStatement::getFastPropertyValue(Any&,sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL KabCommonStatement::acquire() throw()
+{
+ KabCommonStatement_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL KabCommonStatement::release() throw()
+{
+ KabCommonStatement_BASE::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL KabCommonStatement::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+KabStatement::KabStatement(KabConnection* _pConnection)
+ : KabStatement_BASE(_pConnection)
+{
+}
diff --git a/connectivity/source/drivers/kab/KStatement.hxx b/connectivity/source/drivers/kab/KStatement.hxx
new file mode 100644
index 000000000000..710647b10380
--- /dev/null
+++ b/connectivity/source/drivers/kab/KStatement.hxx
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_STATEMENT_HXX_
+#define _CONNECTIVITY_KAB_STATEMENT_HXX_
+
+#include "KConnection.hxx"
+#include <list>
+#include "connectivity/sqliterator.hxx"
+#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
+#include "connectivity/sqlparse.hxx"
+#endif
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/proparrhlp.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable> KabCommonStatement_BASE;
+
+ //**************************************************************
+ // Class KabCommonStatement
+ // is a base class for the normal statement and for the prepared statement
+ //**************************************************************
+ class KabCommonStatement : public comphelper::OBaseMutex,
+ public KabCommonStatement_BASE,
+ public ::cppu::OPropertySetHelper,
+ public comphelper::OPropertyArrayUsageHelper<KabCommonStatement>
+
+ {
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+
+ protected:
+ ::std::list< ::rtl::OUString> m_aBatchList;
+ connectivity::OSQLParser m_aParser;
+ connectivity::OSQLParseTreeIterator m_aSQLIterator;
+ connectivity::OSQLParseNode* m_pParseTree;
+ KabConnection* m_pConnection; // The owning Connection object
+
+ protected:
+ class KabCondition *analyseWhereClause(
+ const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
+ class KabOrder *analyseOrderByClause(
+ const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
+ sal_Bool isTableKnown(class KabResultSet *pResult) const;
+ void setKabFields(class KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+ void selectAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+ void sortAddressees(KabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+
+ virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
+ virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
+ virtual ~KabCommonStatement();
+
+ public:
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ KabCommonStatement(KabConnection *_pConnection);
+ using KabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCancellable
+ virtual void SAL_CALL cancel(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // other methods
+ inline KabConnection* getOwnConnection() const { return m_pConnection; }
+ };
+
+ //**************************************************************
+ // Class KabStatement
+ //**************************************************************
+ typedef ::cppu::ImplInheritanceHelper1<
+ KabCommonStatement, ::com::sun::star::lang::XServiceInfo > KabStatement_BASE;
+
+ class KabStatement : public KabStatement_BASE
+ {
+ protected:
+ virtual ~KabStatement() { }
+
+ public:
+ KabStatement(KabConnection* _pConnection);
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_STATEMENT_HXX_
diff --git a/connectivity/source/drivers/kab/KTable.cxx b/connectivity/source/drivers/kab/KTable.cxx
new file mode 100644
index 000000000000..916edcf9bda2
--- /dev/null
+++ b/connectivity/source/drivers/kab/KTable.cxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KTable.hxx"
+#include "KTables.hxx"
+#include "KColumns.hxx"
+#include "KCatalog.hxx"
+
+using namespace connectivity::kab;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+KabTable::KabTable( sdbcx::OCollection* _pTables, KabConnection* _pConnection)
+ : KabTable_TYPEDEF(_pTables, sal_True),
+ m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+KabTable::KabTable( sdbcx::OCollection* _pTables,
+ KabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : KabTable_TYPEDEF(_pTables,sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName),
+ m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void KabTable::refreshColumns()
+{
+ TStringVector aVector;
+
+ if (!isNew())
+ {
+ Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(
+ Any(),
+ m_SchemaName,
+ m_Name,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
+
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult, UNO_QUERY);
+ while (xResult->next())
+ aVector.push_back(xRow->getString(4));
+ }
+ }
+
+ if (m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new KabColumns(this,m_aMutex,aVector);
+}
diff --git a/connectivity/source/drivers/kab/KTable.hxx b/connectivity/source/drivers/kab/KTable.hxx
new file mode 100644
index 000000000000..eca7b9fb78b1
--- /dev/null
+++ b/connectivity/source/drivers/kab/KTable.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_TABLE_HXX_
+#define _CONNECTIVITY_KAB_TABLE_HXX_
+
+#include "KConnection.hxx"
+#include "connectivity/sdbcx/VTable.hxx"
+
+namespace connectivity
+{
+ namespace kab
+ {
+ typedef connectivity::sdbcx::OTable KabTable_TYPEDEF;
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class KabTable : public KabTable_TYPEDEF
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ KabConnection* m_pConnection;
+
+ public:
+ KabTable( sdbcx::OCollection* _pTables, KabConnection* _pConnection);
+ KabTable( sdbcx::OCollection* _pTables,
+ KabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description = ::rtl::OUString(),
+ const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
+ const ::rtl::OUString& _CatalogName = ::rtl::OUString()
+ );
+
+ KabConnection* getConnection() { return m_pConnection;}
+
+ virtual void refreshColumns();
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_TABLE_HXX_
diff --git a/connectivity/source/drivers/kab/KTables.cxx b/connectivity/source/drivers/kab/KTables.cxx
new file mode 100644
index 000000000000..418f7a1dd676
--- /dev/null
+++ b/connectivity/source/drivers/kab/KTables.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "KTables.hxx"
+#include "KTable.hxx"
+#include "KCatalog.hxx"
+#include "KConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::kab;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+sdbcx::ObjectType KabTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ aName = _rName;
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ ::rtl::OUString sEmpty;
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult, UNO_QUERY);
+ if (xResult->next()) // there can be only one table with this name
+ {
+ KabTable* pRet = new KabTable(
+ this,
+ static_cast<KabCatalog&>(m_rParent).getConnection(),
+ aName,
+ xRow->getString(4),
+ xRow->getString(5),
+ sEmpty);
+ xRet = pRet;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void KabTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<KabCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void KabTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
diff --git a/connectivity/source/drivers/kab/KTables.hxx b/connectivity/source/drivers/kab/KTables.hxx
new file mode 100644
index 000000000000..aaa06002751b
--- /dev/null
+++ b/connectivity/source/drivers/kab/KTables.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_TABLES_HXX_
+#define _CONNECTIVITY_KAB_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ class KabTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ KabTables(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector),
+ m_xMetaData(_rMetaData)
+ { }
+
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_TABLES_HXX_
diff --git a/connectivity/source/drivers/kab/exports.dxp b/connectivity/source/drivers/kab/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/kab/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/kab/kab.xcu b/connectivity/source/drivers/kab/kab.xcu
new file mode 100755
index 000000000000..d350014a3017
--- /dev/null
+++ b/connectivity/source/drivers/kab/kab.xcu
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:kab" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.kab.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">KDE Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/kab/kab.xml b/connectivity/source/drivers/kab/kab.xml
new file mode 100644
index 000000000000..4992d6fba096
--- /dev/null
+++ b/connectivity/source/drivers/kab/kab.xml
@@ -0,0 +1,79 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> kab1 </module-name>
+ <component-description>
+ <Author>Eric Bischoff</Author>
+ <Name>com.sun.star.comp.sdbc.kab.Driver</Name>
+ <description>This library implements the database driver for KDE address book formats.</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <project-build-dependency> vos </project-build-dependency>
+
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu1 </runtime-module-dependency>
+ <runtime-module-dependency> sal1 </runtime-module-dependency>
+ <runtime-module-dependency> vos </runtime-module-dependency>
+
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.util.XCancellable </type>
+ <type> com.sun.star.util.XNumberFormatter </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.beans.PropertyAttribute </type>
+ <type> com.sun.star.beans.XPropertyState </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XMultiPropertySet </type>
+ <type> com.sun.star.beans.XFastPropertySet </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.XSingleComponentFactory </type>
+ <type> com.sun.star.lang.EventObject </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.DisposedException </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XUnoTunnel </type>
+ <type> com.sun.star.java.XJavaThreadRegister_11 </type>
+ <type> com.sun.star.java.XJavaVM </type>
+ <type> com.sun.star.sdbc.FetchDirection </type>
+ <type> com.sun.star.sdbc.XConnection </type>
+ <type> com.sun.star.sdbc.XStatement </type>
+ <type> com.sun.star.sdbc.XResultSet </type>
+ <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type>
+ <type> com.sun.star.sdbc.XColumnLocate </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XWarningsSupplier </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbc.XMultipleResults </type>
+ <type> com.sun.star.sdbc.XBatchExecution </type>
+ <type> com.sun.star.sdbc.XPreparedBatchExecution </type>
+ <type> com.sun.star.sdbc.XParameters </type>
+ <type> com.sun.star.sdbc.XOutParameters </type>
+ <type> com.sun.star.sdbc.DriverPropertyInfo </type>
+ <type> com.sun.star.sdbc.SQLWarning </type>
+ <type> com.sun.star.sdbc.XRow </type>
+ <type> com.sun.star.sdbc.ColumnSearch </type>
+ <type> com.sun.star.sdbc.ColumnValue </type>
+ <type> com.sun.star.sdbc.DataType </type>
+ <type> com.sun.star.sdbc.XDriver </type>
+ <type> com.sun.star.sdbc.TransactionIsolation </type>
+ <type> com.sun.star.sdbc.ResultSetType </type>
+ <type> com.sun.star.sdbc.ResultSetConcurrency </type>
+ <type> com.sun.star.sdbcx.XRowLocate </type>
+ <type> com.sun.star.sdbcx.XDeleteRows </type>
+ <type> com.sun.star.sdbcx.CompareBookmark </type>
+ <type> com.sun.star.sdb.XColumnUpdate </type>
+ <type> com.sun.star.sdb.XColumn </type>
+</module-description>
diff --git a/connectivity/source/drivers/kab/kabdrv.map b/connectivity/source/drivers/kab/kabdrv.map
new file mode 100644
index 000000000000..5de866f2e52f
--- /dev/null
+++ b/connectivity/source/drivers/kab/kabdrv.map
@@ -0,0 +1,9 @@
+UDK_3_0_0 {
+ global:
+ createKabConnection;
+ initKApplication;
+ shutdownKApplication;
+ matchKDEVersion;
+ local:
+ *;
+};
diff --git a/connectivity/source/drivers/kab/kcondition.cxx b/connectivity/source/drivers/kab/kcondition.cxx
new file mode 100644
index 000000000000..c99905678242
--- /dev/null
+++ b/connectivity/source/drivers/kab/kcondition.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "kcondition.hxx"
+#include "kfields.hxx"
+#include "connectivity/CommonTools.hxx"
+
+using namespace ::connectivity::kab;
+using namespace ::com::sun::star::sdbc;
+// -----------------------------------------------------------------------------
+KabCondition::~KabCondition()
+{
+}
+// -----------------------------------------------------------------------------
+KabConditionConstant::KabConditionConstant(const sal_Bool bValue)
+ : KabCondition(),
+ m_bValue(bValue)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionConstant::isAlwaysTrue() const
+{
+ return m_bValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionConstant::isAlwaysFalse() const
+{
+ return !m_bValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionConstant::eval(const ::KABC::Addressee &) const
+{
+ return m_bValue;
+}
+// -----------------------------------------------------------------------------
+KabConditionColumn::KabConditionColumn(const ::rtl::OUString &sColumnName) throw(SQLException)
+ : KabCondition(),
+ m_nFieldNumber(findKabField(sColumnName))
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionColumn::isAlwaysTrue() const
+{
+ // Sometimes true, sometimes false
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionColumn::isAlwaysFalse() const
+{
+ // Sometimes true, sometimes false
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+KabConditionNull::KabConditionNull(const ::rtl::OUString &sColumnName) throw(SQLException)
+ : KabConditionColumn(sColumnName)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionNull::eval(const ::KABC::Addressee &aAddressee) const
+{
+ QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber);
+
+ return aQtName.isNull();
+// KDE address book currently does not use NULL values.
+// But it might do it someday
+}
+// -----------------------------------------------------------------------------
+KabConditionNotNull::KabConditionNotNull(const ::rtl::OUString &sColumnName) throw(SQLException)
+ : KabConditionColumn(sColumnName)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionNotNull::eval(const ::KABC::Addressee &aAddressee) const
+{
+ QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber);
+
+ return !aQtName.isNull();
+// KDE address book currently does not use NULL values.
+// But it might do it someday
+}
+// -----------------------------------------------------------------------------
+KabConditionCompare::KabConditionCompare(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : KabConditionColumn(sColumnName),
+ m_sMatchString(sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+KabConditionEqual::KabConditionEqual(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : KabConditionCompare(sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionEqual::eval(const ::KABC::Addressee &aAddressee) const
+{
+ QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber);
+// Timestamps should not be compared according to their string value
+// The syntax for such queries should be like
+// {ts '2004-03-29 12:55:00.000000'}
+// They should also support operators like '<' or '>='
+
+ if (aQtName.isNull()) return sal_False;
+
+ ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2());
+ return sValue == m_sMatchString;
+}
+// -----------------------------------------------------------------------------
+KabConditionDifferent::KabConditionDifferent(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : KabConditionCompare(sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionDifferent::eval(const ::KABC::Addressee &aAddressee) const
+{
+ QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber);
+
+ if (aQtName.isNull()) return sal_False;
+
+ ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2());
+ return sValue != m_sMatchString;
+}
+// -----------------------------------------------------------------------------
+KabConditionSimilar::KabConditionSimilar(const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : KabConditionCompare(sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionSimilar::eval(const ::KABC::Addressee &aAddressee) const
+{
+ QString aQtName = valueOfKabField(aAddressee, m_nFieldNumber);
+
+ if (aQtName.isNull()) return sal_False;
+
+ ::rtl::OUString sValue((const sal_Unicode *) aQtName.ucs2());
+ return match(m_sMatchString, sValue, '\0');
+}
+// -----------------------------------------------------------------------------
+KabConditionBoolean::KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight)
+ : KabCondition(),
+ m_pLeft(pLeft),
+ m_pRight(pRight)
+{
+}
+// -----------------------------------------------------------------------------
+KabConditionBoolean::~KabConditionBoolean()
+{
+ delete m_pLeft;
+ delete m_pRight;
+}
+// -----------------------------------------------------------------------------
+KabConditionOr::KabConditionOr(KabCondition *pLeft, KabCondition *pRight)
+ : KabConditionBoolean(pLeft, pRight)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionOr::isAlwaysTrue() const
+{
+ return m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionOr::isAlwaysFalse() const
+{
+ return m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse();
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionOr::eval(const ::KABC::Addressee &aAddressee) const
+{
+ // We avoid evaluating terms as much as we can
+ if (m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue()) return sal_True;
+ if (m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse()) return sal_False;
+
+ if (m_pLeft->eval(aAddressee)) return sal_True;
+ if (m_pRight->eval(aAddressee)) return sal_True;
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+KabConditionAnd::KabConditionAnd(KabCondition *pLeft, KabCondition *pRight)
+ : KabConditionBoolean(pLeft, pRight)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionAnd::isAlwaysTrue() const
+{
+ return m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionAnd::isAlwaysFalse() const
+{
+ return m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse();
+}
+// -----------------------------------------------------------------------------
+sal_Bool KabConditionAnd::eval(const ::KABC::Addressee &aAddressee) const
+{
+ // We avoid evaluating terms as much as we can
+ if (m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse()) return sal_False;
+ if (m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue()) return sal_True;
+
+ if (!m_pLeft->eval(aAddressee)) return sal_False;
+ if (!m_pRight->eval(aAddressee)) return sal_False;
+
+ return sal_True;
+}
diff --git a/connectivity/source/drivers/kab/kcondition.hxx b/connectivity/source/drivers/kab/kcondition.hxx
new file mode 100644
index 000000000000..26bc530a9960
--- /dev/null
+++ b/connectivity/source/drivers/kab/kcondition.hxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_CONDITION_HXX_
+#define _CONNECTIVITY_KAB_CONDITION_HXX_
+
+#ifndef _COMPHELPER_TYPES_H_
+#include <comphelper/types.hxx>
+#endif
+#include <shell/kde_headers.h>
+#include <connectivity/dbexception.hxx>
+
+namespace connectivity
+{
+ namespace kab
+ {
+// -----------------------------------------------------------------------------
+class KabCondition
+{
+ public:
+ virtual ~KabCondition();
+ virtual sal_Bool isAlwaysTrue() const = 0;
+ virtual sal_Bool isAlwaysFalse() const = 0;
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const = 0;
+};
+// -----------------------------------------------------------------------------
+class KabConditionConstant : public KabCondition
+{
+ protected:
+ sal_Bool m_bValue;
+
+ public:
+ KabConditionConstant(const sal_Bool bValue);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionColumn : public KabCondition
+{
+ protected:
+ sal_Int32 m_nFieldNumber;
+
+ QString value(const ::KABC::Addressee &aAddressee) const;
+
+ public:
+ KabConditionColumn(
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionNull : public KabConditionColumn
+{
+ public:
+ KabConditionNull(
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionNotNull : public KabConditionColumn
+{
+ public:
+ KabConditionNotNull(
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionCompare : public KabConditionColumn
+{
+ protected:
+ const ::rtl::OUString m_sMatchString;
+
+ public:
+ KabConditionCompare(
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+};
+// -----------------------------------------------------------------------------
+class KabConditionEqual : public KabConditionCompare
+{
+ public:
+ KabConditionEqual(
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionDifferent : public KabConditionCompare
+{
+ public:
+ KabConditionDifferent(
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionSimilar : public KabConditionCompare
+{
+ public:
+ KabConditionSimilar(
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionBoolean : public KabCondition
+{
+ protected:
+ KabCondition *m_pLeft, *m_pRight;
+
+ public:
+ KabConditionBoolean(KabCondition *pLeft, KabCondition *pRight);
+ virtual ~KabConditionBoolean();
+};
+// -----------------------------------------------------------------------------
+class KabConditionOr : public KabConditionBoolean
+{
+ public:
+ KabConditionOr(KabCondition *pLeft, KabCondition *pRight);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const ::KABC::Addressee &aAddressee) const;
+};
+// -----------------------------------------------------------------------------
+class KabConditionAnd : public KabConditionBoolean
+{
+ public:
+ KabConditionAnd(KabCondition *pLeft, KabCondition *pRight);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const ::KABC::Addressee &addressee) const;
+};
+// -----------------------------------------------------------------------------
+ }
+}
+
+#endif // _CONNECTIVITY_KAB_CONDITION_HXX_
diff --git a/connectivity/source/drivers/kab/kfields.cxx b/connectivity/source/drivers/kab/kfields.cxx
new file mode 100644
index 000000000000..e2ff003d98b0
--- /dev/null
+++ b/connectivity/source/drivers/kab/kfields.cxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "kfields.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace ::connectivity::kab;
+using namespace ::com::sun::star::sdbc;
+
+namespace connectivity
+{
+ namespace kab
+ {
+// -----------------------------------------------------------------------------
+// return the value of a KDE address book field, given an addressee and a field number
+QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber)
+{
+ switch (nFieldNumber)
+ {
+ case KAB_FIELD_REVISION:
+ return aAddressee.revision().toString("yyyy-MM-dd hh:mm:ss");
+ default:
+ ::KABC::Field::List aFields = ::KABC::Field::allFields();
+ return aFields[nFieldNumber - KAB_DATA_FIELDS]->value(aAddressee);
+ }
+}
+// ------------------------------------------------------------------------------
+// search the KDE address book field number of a given column name
+sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(SQLException)
+{
+ QString aQtName;
+ ::rtl::OUString aName;
+
+ aQtName = KABC::Addressee::revisionLabel();
+ aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
+ if (columnName == aName)
+ return KAB_FIELD_REVISION;
+
+ ::KABC::Field::List aFields = ::KABC::Field::allFields();
+ ::KABC::Field::List::iterator aField;
+ sal_uInt32 nResult;
+
+ for ( aField = aFields.begin(), nResult = KAB_DATA_FIELDS;
+ aField != aFields.end();
+ ++aField, ++nResult)
+ {
+ aQtName = (*aField)->label();
+ aName = ::rtl::OUString((const sal_Unicode *) aQtName.ucs2());
+
+ if (columnName == aName)
+ return nResult;
+ }
+
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$",columnName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+// ------------------------------------------------------------------------------
+ }
+}
diff --git a/connectivity/source/drivers/kab/kfields.hxx b/connectivity/source/drivers/kab/kfields.hxx
new file mode 100644
index 000000000000..ed5688d5b064
--- /dev/null
+++ b/connectivity/source/drivers/kab/kfields.hxx
@@ -0,0 +1,47 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_FIELDS_HXX_
+#define _CONNECTIVITY_KAB_FIELDS_HXX_
+
+#include <shell/kde_headers.h>
+#include <connectivity/dbexception.hxx>
+#include <rtl/ustring.hxx>
+
+#define KAB_FIELD_REVISION 0
+#define KAB_DATA_FIELDS 1
+
+namespace connectivity
+{
+ namespace kab
+ {
+ QString valueOfKabField(const ::KABC::Addressee &aAddressee, sal_Int32 nFieldNumber);
+ sal_uInt32 findKabField(const ::rtl::OUString& columnName) throw(::com::sun::star::sdbc::SQLException);
+ }
+}
+
+#endif
diff --git a/connectivity/source/drivers/kab/korder.cxx b/connectivity/source/drivers/kab/korder.cxx
new file mode 100644
index 000000000000..0df6b66babf6
--- /dev/null
+++ b/connectivity/source/drivers/kab/korder.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "korder.hxx"
+#include "kfields.hxx"
+
+using namespace ::connectivity::kab;
+
+KabOrder::~KabOrder()
+{
+}
+// -----------------------------------------------------------------------------
+KabSimpleOrder::KabSimpleOrder(::rtl::OUString &sColumnName, sal_Bool bAscending)
+ : KabOrder(),
+ m_nFieldNumber(findKabField(sColumnName)),
+ m_bAscending(bAscending)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Int32 KabSimpleOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const
+{
+ sal_Int32 result;
+
+ result = QString::compare(
+ valueOfKabField(aAddressee1, m_nFieldNumber),
+ valueOfKabField(aAddressee2, m_nFieldNumber));
+// Timestamps should be compared differently than with their string value
+
+ if (!m_bAscending) result = -result;
+
+ return result;
+}
+// -----------------------------------------------------------------------------
+KabComplexOrder::KabComplexOrder()
+ : KabOrder(),
+ m_aOrders()
+{
+}
+// -----------------------------------------------------------------------------
+KabComplexOrder::~KabComplexOrder()
+{
+ for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
+ delete m_aOrders[i];
+}
+// -----------------------------------------------------------------------------
+void KabComplexOrder::addOrder(KabOrder *pOrder)
+{
+ m_aOrders.push_back(pOrder);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 KabComplexOrder::compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const
+{
+ for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
+ {
+ const KabOrder *pOrder = m_aOrders[i];
+ sal_Int32 result = pOrder->compare(aAddressee1, aAddressee2);
+
+ if (result) return result;
+ }
+ return 0;
+}
diff --git a/connectivity/source/drivers/kab/korder.hxx b/connectivity/source/drivers/kab/korder.hxx
new file mode 100644
index 000000000000..6c88f9e3ab9f
--- /dev/null
+++ b/connectivity/source/drivers/kab/korder.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_KAB_ORDER_HXX_
+#define _CONNECTIVITY_KAB_ORDER_HXX_
+
+#include "rtl/ustring.hxx"
+#include <shell/kde_headers.h>
+
+#include <vector>
+
+namespace connectivity
+{
+ namespace kab
+ {
+ class KabOrder
+ {
+ public:
+ virtual ~KabOrder();
+
+ virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const = 0;
+ };
+
+ class KabSimpleOrder : public KabOrder
+ {
+ sal_Int32 m_nFieldNumber;
+ sal_Bool m_bAscending;
+
+ QString value(const ::KABC::Addressee &aAddressee) const;
+ public:
+ KabSimpleOrder(::rtl::OUString &sColumnName, sal_Bool bAscending);
+
+ virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const;
+ };
+
+ class KabComplexOrder : public KabOrder
+ {
+ ::std::vector<KabOrder *> m_aOrders;
+
+ public:
+ KabComplexOrder();
+ virtual ~KabComplexOrder();
+
+ void addOrder(KabOrder *pOrder);
+ virtual sal_Int32 compare(const ::KABC::Addressee &aAddressee1, const ::KABC::Addressee &aAddressee2) const;
+ };
+ }
+}
+
+#endif
diff --git a/connectivity/source/drivers/kab/makefile.mk b/connectivity/source/drivers/kab/makefile.mk
new file mode 100644
index 000000000000..2a0dc5cd8999
--- /dev/null
+++ b/connectivity/source/drivers/kab/makefile.mk
@@ -0,0 +1,137 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=kab
+TARGET2=$(TARGET)drv
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(GUI)" == "UNX"
+.IF "$(ENABLE_KAB)" == "TRUE"
+
+CFLAGS+=$(KDE_CFLAGS)
+
+.IF "$(KDE_ROOT)"!=""
+EXTRALIBPATHS+=-L$(KDE_ROOT)$/lib
+.ENDIF
+
+# === KAB base library ==========================
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/KDriver.obj \
+ $(SLO)$/KServices.obj
+
+DEPOBJFILES= \
+ $(SLO2FILES)
+
+# --- Library -----------------------------------
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+SHL1TARGET= $(TARGET)$(KAB_MAJOR)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(DBTOOLSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# === KAB impl library ==========================
+
+# --- Files -------------------------------------
+
+SLO2FILES=\
+ $(SLO)$/KColumns.obj \
+ $(SLO)$/KTable.obj \
+ $(SLO)$/KTables.obj \
+ $(SLO)$/KCatalog.obj \
+ $(SLO)$/KResultSet.obj \
+ $(SLO)$/KStatement.obj \
+ $(SLO)$/KPreparedStatement.obj \
+ $(SLO)$/KDatabaseMetaData.obj \
+ $(SLO)$/KConnection.obj \
+ $(SLO)$/KResultSetMetaData.obj \
+ $(SLO)$/kcondition.obj \
+ $(SLO)$/korder.obj \
+ $(SLO)$/kfields.obj \
+ $(SLO)$/KDEInit.obj
+
+KAB_LIB=$(KDE_LIBS) -lkabc
+
+# --- Library -----------------------------------
+
+SHL2VERSIONMAP=$(TARGET2).map
+
+SHL2TARGET= $(TARGET2)$(KAB_MAJOR)
+SHL2OBJS=$(SLO2FILES)
+SHL2STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(KAB_LIB)
+
+SHL2DEPN=
+SHL2IMPLIB= i$(TARGET2)
+
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+
+DEF2NAME= $(SHL2TARGET)
+
+# --- Targets -----------------------------------
+.ELSE # "$(ENABLE_KAB)" == "TRUE"
+dummy:
+ @echo KDE Addressbook disabled - nothing to build
+.ENDIF
+
+.ELSE # "$(GUI)" == "UNX"
+dummy:
+ @echo "Nothing to build for GUI $(GUI)"
+.ENDIF
+
+.INCLUDE : $(PRJ)$/target.pmk
+
diff --git a/connectivity/source/drivers/macab/MacabAddressBook.cxx b/connectivity/source/drivers/macab/MacabAddressBook.cxx
new file mode 100755
index 000000000000..6496702adc7a
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabAddressBook.cxx
@@ -0,0 +1,256 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabAddressBook.hxx"
+#include "MacabRecords.hxx"
+#include "MacabGroup.hxx"
+
+#include <vector>
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+#include "connectivity/CommonTools.hxx"
+
+using namespace connectivity::macab;
+using namespace ::com::sun::star::uno;
+
+// -----------------------------------------------------------------------------
+MacabAddressBook::MacabAddressBook( )
+{
+ m_aAddressBook = ABGetSharedAddressBook();
+ m_xMacabRecords = NULL;
+ m_bRetrievedGroups = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+MacabAddressBook::~MacabAddressBook()
+{
+ if(m_xMacabRecords != NULL)
+ {
+ delete m_xMacabRecords;
+ m_xMacabRecords = NULL;
+ }
+
+ if(!m_xMacabGroups.empty())
+ {
+ ::std::vector<MacabGroup *>::iterator iter, end;
+ iter = m_xMacabGroups.begin();
+ end = m_xMacabGroups.end();
+ for( ; iter != end; ++iter)
+ delete (*iter);
+ }
+
+ m_bRetrievedGroups = sal_False;
+}
+
+// -----------------------------------------------------------------------------
+/* Get the address book's default table name. This is the table name that
+ * refers to the table containing _all_ records in the address book.
+ */
+const ::rtl::OUString & MacabAddressBook::getDefaultTableName()
+{
+ /* This string probably needs to be localized. */
+ static const ::rtl::OUString aDefaultTableName
+ (::rtl::OUString::createFromAscii("Address Book"));
+
+ return aDefaultTableName;
+}
+
+// -----------------------------------------------------------------------------
+MacabRecords *MacabAddressBook::getMacabRecords()
+{
+ /* If the MacabRecords don't exist, create them. */
+ if(m_xMacabRecords == NULL)
+ {
+ m_xMacabRecords = new MacabRecords(m_aAddressBook);
+ m_xMacabRecords->setName(getDefaultTableName());
+ m_xMacabRecords->initialize();
+ }
+
+ return m_xMacabRecords;
+}
+
+// -----------------------------------------------------------------------------
+/* Get the MacabRecords for a given name: either a group name or the
+ * default table name.
+ */
+MacabRecords *MacabAddressBook::getMacabRecords(const ::rtl::OUString _tableName)
+{
+ if(_tableName == getDefaultTableName())
+ {
+ return getMacabRecords();
+ }
+ else
+ {
+ return getMacabGroup(_tableName);
+ }
+}
+
+// -----------------------------------------------------------------------------
+MacabRecords *MacabAddressBook::getMacabRecordsMatch(const ::rtl::OUString _tableName)
+{
+ if(match(_tableName, getDefaultTableName(), '\0'))
+ {
+ return getMacabRecords();
+ }
+
+ return getMacabGroupMatch(_tableName);
+}
+
+// -----------------------------------------------------------------------------
+::std::vector<MacabGroup *> MacabAddressBook::getMacabGroups()
+{
+ /* If the MacabGroups haven't been created yet, create them. */
+ if(m_bRetrievedGroups == sal_False)
+ {
+ /* If the MacabRecords haven't been created yet, create them. */
+ if(m_xMacabRecords == NULL)
+ {
+ m_xMacabRecords = new MacabRecords(m_aAddressBook);
+ m_xMacabRecords->setName(getDefaultTableName());
+ m_xMacabRecords->initialize();
+ }
+
+ CFArrayRef allGroups = ABCopyArrayOfAllGroups(m_aAddressBook);
+ sal_Int32 nGroups = CFArrayGetCount(allGroups);
+ m_xMacabGroups = ::std::vector<MacabGroup *>(nGroups);
+
+ sal_Int32 i;
+ ABGroupRef xGroup;
+
+ /* Go through each group and create a MacabGroup out of it. */
+ for(i = 0; i < nGroups; i++)
+ {
+ xGroup = (ABGroupRef) CFArrayGetValueAtIndex(allGroups, i);
+ m_xMacabGroups[i] = new MacabGroup(m_aAddressBook, m_xMacabRecords, xGroup);
+ }
+
+ CFRelease(allGroups);
+
+ /* Manage duplicates. */
+ manageDuplicateGroups(m_xMacabGroups);
+ m_bRetrievedGroups = sal_True;
+ }
+
+ return m_xMacabGroups;
+}
+
+// -----------------------------------------------------------------------------
+MacabGroup *MacabAddressBook::getMacabGroup(::rtl::OUString _groupName)
+{
+ // initialize groups if not already initialized
+ if(m_bRetrievedGroups == sal_False)
+ getMacabGroups();
+
+ sal_Int32 nGroups = m_xMacabGroups.size();
+ sal_Int32 i;
+
+ for(i = 0; i < nGroups; i++)
+ {
+ if(m_xMacabGroups[i] != NULL)
+ {
+ if(m_xMacabGroups[i]->getName() == _groupName)
+ {
+ return m_xMacabGroups[i];
+ }
+ }
+ }
+
+ return NULL;
+}
+
+// -----------------------------------------------------------------------------
+MacabGroup *MacabAddressBook::getMacabGroupMatch(::rtl::OUString _groupName)
+{
+ // initialize groups if not already initialized
+ if(m_bRetrievedGroups == sal_False)
+ getMacabGroups();
+
+ sal_Int32 nGroups = m_xMacabGroups.size();
+ sal_Int32 i;
+
+ for(i = 0; i < nGroups; i++)
+ {
+ if(m_xMacabGroups[i] != NULL)
+ {
+ if(match(m_xMacabGroups[i]->getName(), _groupName, '\0'))
+ {
+ return m_xMacabGroups[i];
+ }
+ }
+ }
+
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+void MacabAddressBook::manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) const
+{
+ /* If we have two cases of groups, say, family, this makes it:
+ * family
+ * family (2)
+ */
+ ::std::vector<MacabGroup *>::reverse_iterator iter1, iter2;
+ sal_Int32 count;
+
+ for(iter1 = _xGroups.rbegin(); iter1 != _xGroups.rend(); ++iter1)
+ {
+ /* If the name matches the default table name, there is already
+ * (obviously) a conflict. So, start the count of groups with this
+ * name at 2 instead of 1.
+ */
+ if( (*iter1)->getName() == getDefaultTableName() )
+ count = 2;
+ else
+ count = 1;
+
+ iter2 = iter1;
+ for( ++iter2; iter2 != _xGroups.rend(); ++iter2)
+ {
+ if( (*iter1)->getName() == (*iter2)->getName() )
+ {
+ count++;
+ }
+ }
+
+ // duplicate!
+ if(count != 1)
+ {
+ ::rtl::OUString sName = (*iter1)->getName();
+ sName += ::rtl::OUString::createFromAscii(" (") +
+ ::rtl::OUString::valueOf(count) +
+ ::rtl::OUString::createFromAscii(")");
+ (*iter1)->setName(sName);
+ }
+ }
+}
+
diff --git a/connectivity/source/drivers/macab/MacabAddressBook.hxx b/connectivity/source/drivers/macab/MacabAddressBook.hxx
new file mode 100755
index 000000000000..d4454ec5ffa8
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabAddressBook.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_ADDRESSBOOK_HXX_
+#define _CONNECTIVITY_MACAB_ADDRESSBOOK_HXX_
+
+#include "MacabRecords.hxx"
+#include "MacabGroup.hxx"
+
+#include <vector>
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabAddressBook
+ {
+ protected:
+ ABAddressBookRef m_aAddressBook;
+ MacabRecords *m_xMacabRecords;
+ ::std::vector<MacabGroup *> m_xMacabGroups;
+ sal_Bool m_bRetrievedGroups;
+ private:
+ void manageDuplicateGroups(::std::vector<MacabGroup *> _xGroups) const;
+ public:
+ MacabAddressBook();
+ ~MacabAddressBook();
+ static const ::rtl::OUString & getDefaultTableName();
+
+ MacabRecords *getMacabRecords();
+ ::std::vector<MacabGroup *> getMacabGroups();
+
+ MacabGroup *getMacabGroup(::rtl::OUString _groupName);
+ MacabRecords *getMacabRecords(const ::rtl::OUString _tableName);
+
+ MacabGroup *getMacabGroupMatch(::rtl::OUString _groupName);
+ MacabRecords *getMacabRecordsMatch(const ::rtl::OUString _tableName);
+ };
+
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_ADDRESSBOOK_HXX_
diff --git a/connectivity/source/drivers/macab/MacabCatalog.cxx b/connectivity/source/drivers/macab/MacabCatalog.cxx
new file mode 100755
index 000000000000..7268058b0c3b
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabCatalog.cxx
@@ -0,0 +1,124 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabCatalog.hxx"
+#include "MacabConnection.hxx"
+#include "MacabTables.hxx"
+
+using namespace connectivity::macab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+
+// -------------------------------------------------------------------------
+MacabCatalog::MacabCatalog(MacabConnection* _pCon)
+ : connectivity::sdbcx::OCatalog(_pCon),
+ m_pConnection(_pCon),
+ m_xMetaData(m_pConnection->getMetaData())
+{
+}
+// -------------------------------------------------------------------------
+void MacabCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(
+ Any(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),
+ aTypes);
+
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+ // const ::rtl::OUString& sDot = MacabCatalog::getDot();
+
+ while (xResult->next())
+ {
+ // aName = xRow->getString(2);
+ // aName += sDot;
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if (m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new MacabTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void MacabCatalog::refreshViews()
+{
+}
+// -------------------------------------------------------------------------
+void MacabCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void MacabCatalog::refreshUsers()
+{
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString& MacabCatalog::getDot()
+{
+ static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("."));
+ return sDot;
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL MacabCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ try
+ {
+ if (!m_pTables)
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return m_pTables;
+}
diff --git a/connectivity/source/drivers/macab/MacabCatalog.hxx b/connectivity/source/drivers/macab/MacabCatalog.hxx
new file mode 100755
index 000000000000..52bb6e8ab62c
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabCatalog.hxx
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_CATALOG_HXX_
+#define _CONNECTIVITY_MACAB_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabConnection;
+
+ class MacabCatalog : public connectivity::sdbcx::OCatalog
+ {
+ MacabConnection* m_pConnection; // used to get the metadata
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
+
+ public:
+ MacabCatalog(MacabConnection* _pCon);
+
+ inline MacabConnection* getConnection() const { return m_pConnection; }
+
+ static const ::rtl::OUString& getDot();
+
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews();
+ virtual void refreshGroups();
+ virtual void refreshUsers();
+
+ // XTablesSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables(
+ ) throw(::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_CATALOG_HXX_
diff --git a/connectivity/source/drivers/macab/MacabColumns.cxx b/connectivity/source/drivers/macab/MacabColumns.cxx
new file mode 100755
index 000000000000..c1ba3f1fe6d0
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabColumns.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabColumns.hxx"
+#include "MacabTable.hxx"
+#include "MacabTables.hxx"
+#include "MacabCatalog.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+
+using namespace connectivity::macab;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+sdbcx::ObjectType MacabColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(
+ Any(),
+ m_pTable->getSchema(),
+ m_pTable->getTableName(),
+ _rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+
+ while (xResult->next())
+ {
+ if (xRow->getString(4) == _rName)
+ {
+ OColumn* pRet = new OColumn(
+ _rName,
+ xRow->getString(6),
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ xRow->getInt(7),
+ xRow->getInt(9),
+ xRow->getInt(5),
+ sal_False,
+ sal_False,
+ sal_False,
+ sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void MacabColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -------------------------------------------------------------------------
+MacabColumns::MacabColumns( MacabTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(*_pTable, sal_True, _rMutex, _rVector),
+ m_pTable(_pTable)
+{
+}
diff --git a/connectivity/source/drivers/macab/MacabColumns.hxx b/connectivity/source/drivers/macab/MacabColumns.hxx
new file mode 100755
index 000000000000..200ccfb3d7dd
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabColumns.hxx
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_COLUMNS_HXX_
+#define _CONNECTIVITY_MACAB_COLUMNS_HXX_
+
+#include "MacabTable.hxx"
+#include "connectivity/sdbcx/VCollection.hxx"
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabColumns : public sdbcx::OCollection
+ {
+ protected:
+ MacabTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ MacabColumns( MacabTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_COLUMNS_HXX_
diff --git a/connectivity/source/drivers/macab/MacabConnection.cxx b/connectivity/source/drivers/macab/MacabConnection.cxx
new file mode 100755
index 000000000000..31b2bbfd6b1e
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabConnection.cxx
@@ -0,0 +1,324 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabConnection.hxx"
+#include "MacabAddressBook.hxx"
+#include "MacabDatabaseMetaData.hxx"
+#include "MacabStatement.hxx"
+#include "MacabPreparedStatement.hxx"
+#include "MacabDriver.hxx"
+#include "MacabCatalog.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+IMPLEMENT_SERVICE_INFO(MacabConnection, "com.sun.star.sdbc.drivers.MacabConnection", "com.sun.star.sdbc.Connection")
+//-----------------------------------------------------------------------------
+MacabConnection::MacabConnection(MacabDriver* _pDriver)
+ : OSubComponent<MacabConnection, MacabConnection_BASE>((::cppu::OWeakObject*)_pDriver, this),
+ m_pAddressBook(NULL),
+ m_pDriver(_pDriver)
+{
+ m_pDriver->acquire();
+}
+//-----------------------------------------------------------------------------
+MacabConnection::~MacabConnection()
+{
+ if (!isClosed())
+ close();
+
+ m_pDriver->release();
+ m_pDriver = NULL;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL MacabConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+void MacabConnection::construct(const ::rtl::OUString&, const Sequence< PropertyValue >&) throw(SQLException)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+
+ // get the Mac OS X shared address book
+ m_pAddressBook = new MacabAddressBook();
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL MacabConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed once
+ Reference< XStatement > xReturn = new MacabStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL MacabConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed more than once
+ Reference< XPreparedStatement > xReturn = new MacabPreparedStatement(this, _sSql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL MacabConnection::prepareCall( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // not implemented yet :-) a task to do
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // when you need to transform SQL92 to you driver specific you can do it here
+
+ return _sSql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::setAutoCommit( sal_Bool ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+ // here you have to set your commit mode please have a look at the jdbc documentation to get a clear explanation
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+ // you have to distinguish which if you are in autocommit mode or not
+ // at normal case true should be fine here
+
+ return sal_True;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // when you database does support transactions you should commit here
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // same as commit but for the other case
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // just simple -> we are closed when we are disposed, that means someone called dispose(); (XComponent)
+ return MacabConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL MacabConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // here we have to create the class with biggest interface
+ // The answer is 42 :-)
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if (!xMetaData.is())
+ {
+ xMetaData = new MacabDatabaseMetaData(this); // need the connection because it can return it
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::setReadOnly( sal_Bool ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // set you connection to readonly
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // return if your connection to readonly
+ return sal_False;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::setCatalog( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // if your database doesn't work with catalogs you go to next method otherwise you kjnow what to do
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+
+ // return your current catalog
+ return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::setTransactionIsolation( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // set your isolation level
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+ return TransactionIsolation::NONE;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL MacabConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+
+ // if your driver has special database types you can return it here
+
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& ) throw(SQLException, RuntimeException)
+{
+ // the other way around
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL MacabConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabConnection_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL MacabConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ // when you collected some warnings -> return it
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ // you should clear your collected warnings here
+}
+//------------------------------------------------------------------------------
+void MacabConnection::disposing()
+{
+ // we noticed that we should be destroied in near future so we have to dispose our statements
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ for (OWeakRefArray::iterator i = m_aStatements.begin(); m_aStatements.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_aStatements.clear();
+
+ if (m_pAddressBook != NULL)
+ {
+ delete m_pAddressBook;
+ m_pAddressBook = NULL;
+ }
+
+ m_xMetaData = ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XDatabaseMetaData>();
+
+ dispose_ChildImpl();
+ MacabConnection_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+Reference< XTablesSupplier > SAL_CALL MacabConnection::createCatalog()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if (!m_xCatalog.is())
+ {
+ MacabCatalog *pCat = new MacabCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+MacabAddressBook* MacabConnection::getAddressBook() const
+{
+ return m_pAddressBook;
+}
+// -----------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL createMacabConnection( void* _pDriver )
+{
+ MacabConnection* pConnection = new MacabConnection( static_cast< MacabDriver* >( _pDriver ) );
+ // by definition, the pointer crossing library boundaries as void ptr is acquired once
+ pConnection->acquire();
+ return pConnection;
+}
+
diff --git a/connectivity/source/drivers/macab/MacabConnection.hxx b/connectivity/source/drivers/macab/MacabConnection.hxx
new file mode 100755
index 000000000000..4daba81de77b
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabConnection.hxx
@@ -0,0 +1,131 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_CONNECTION_HXX_
+#define _CONNECTIVITY_MACAB_CONNECTION_HXX_
+
+#include <map>
+#include "OSubComponent.hxx"
+#include "connectivity/CommonTools.hxx"
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XConnection.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include "TConnection.hxx"
+
+namespace connectivity
+{
+ namespace macab
+ {
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XConnection,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::lang::XServiceInfo
+ > OMetaConnection_BASE;
+
+ class MacabStatement_Base;
+ class MacabDriver;
+ class MacabDatabaseMetaData;
+ class MacabAddressBook;
+
+ //typedef OMetaConnection_BASE MacabConnection_BASE; // implements basics and text encoding
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+
+ typedef connectivity::OMetaConnection MacabConnection_BASE;
+
+ class MacabConnection : public MacabConnection_BASE,
+ public OSubComponent<MacabConnection, MacabConnection_BASE>
+ {
+ friend class OSubComponent<MacabConnection, MacabConnection_BASE>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ MacabAddressBook* m_pAddressBook; // the address book
+ MacabDriver* m_pDriver; // pointer to the owning driver object
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier>
+ m_xCatalog; // needed for the SQL interpreter
+
+ public:
+ virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+
+ MacabConnection(MacabDriver* _pDriver);
+ virtual ~MacabConnection();
+
+ void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // needed for the SQL interpreter
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
+
+ // accessors
+ inline MacabDriver* getDriver() const { return m_pDriver;}
+ MacabAddressBook* getAddressBook() const;
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_CONNECTION_HXX_
diff --git a/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx b/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx
new file mode 100755
index 000000000000..2794eafc5462
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabDatabaseMetaData.cxx
@@ -0,0 +1,1126 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabDatabaseMetaData.hxx"
+#include "MacabAddressBook.hxx"
+#include "MacabHeader.hxx"
+#include "MacabGroup.hxx"
+#include "macabutilities.hxx"
+
+#ifndef CONNECTIVITY_MACAB_DRIVER_HXX_
+#include "MacabDriver.hxx"
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "OTypeInfo.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+#include <vector>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+MacabDatabaseMetaData::MacabDatabaseMetaData(MacabConnection* _pCon)
+ : m_xConnection(_pCon),
+ m_bUseCatalog(sal_True)
+{
+ OSL_ENSURE(_pCon,"MacabDatabaseMetaData::MacabDatabaseMetaData: No connection set!");
+
+ osl_incrementInterlockedCount( &m_refCount );
+ m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+MacabDatabaseMetaData::~MacabDatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getCatalogSeparator( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if (m_bUseCatalog)
+ { // do some special here for you database
+ }
+
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxTablesInSelect( ) throw(SQLException, RuntimeException)
+{
+ // MaxTablesInSelect describes how many tables can participate in the FROM part of a given SELECT statement,
+ // currently, the resultset/statement implementations can cope with one table only
+ sal_Int32 nValue = 1;
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithAddColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsAlterTableWithDropColumn( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if (m_bUseCatalog)
+ {
+ }
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getIdentifierQuoteString( ) throw(SQLException, RuntimeException)
+{
+ // normally this is "
+ ::rtl::OUString aVal = ::rtl::OUString::createFromAscii("\"");
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::isCatalogAtStart( ) throw(SQLException, RuntimeException)
+{
+ sal_Bool bValue = sal_False;
+ if (m_bUseCatalog)
+ {
+ }
+ return bValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInTableDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInDataManipulation( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxStatements( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ // for the moment, we have read-only addresses, but this might change in the future
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsConvert( sal_Int32, sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMixedCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ // if someday we support more than the default address book,
+ // this method should return the URL which was used to create it
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("sdbc:address:macab:");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii("macab");
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::createFromAscii(MACAB_DRIVER_VERSION);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return MACAB_DRIVER_VERSION_MAJOR;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return MACAB_DRIVER_VERSION_MINOR;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ switch (setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ case ResultSetType::SCROLL_INSENSITIVE:
+ return sal_True;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ switch (setType)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ case ResultSetType::SCROLL_INSENSITIVE:
+ return sal_True;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::ownUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::ownDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::ownInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::othersUpdatesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::othersDeletesAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::othersInsertsAreVisible( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::updatesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::deletesAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::insertsAreDetected( sal_Int32 ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL MacabDatabaseMetaData::getConnection( ) throw(SQLException, RuntimeException)
+{
+ return (Reference< XConnection >) m_xConnection.get();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(2);
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = new ORowSetValueDecorator(aTable);
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTypeInfo( ) throw(SQLException, RuntimeException)
+{
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xRef = pResult;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ // We support four types: char, timestamp, integer, float
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
+ aRow[2] = new ORowSetValueDecorator(DataType::CHAR);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32) 254);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) ColumnValue::NULLABLE);
+ aRow[8] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[9] = new ORowSetValueDecorator((sal_Int32) ColumnSearch::CHAR);
+ aRow[10] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[11] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[12] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[14] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[15] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[16] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[17] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[18] = new ORowSetValueDecorator((sal_Int32) 10);
+
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRow[2] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)19);
+ aRow[4] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRow[5] = ODatabaseMetaDataResultSet::getQuoteValue();
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER"));
+ aRow[2] = new ORowSetValueDecorator(DataType::INTEGER);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)20);
+ aRows.push_back(aRow);
+
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("FLOAT"));
+ aRow[2] = new ORowSetValueDecorator(DataType::FLOAT);
+ aRow[3] = new ORowSetValueDecorator((sal_Int32)20);
+ aRow[15] = new ORowSetValueDecorator((sal_Int32)15);
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCatalogs );
+}
+// -----------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eSchemas );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumnPrivileges(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
+ const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eColumnPrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getColumns(
+ const Any&,
+ const ::rtl::OUString&,
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xRef = pResult;
+ MacabRecords *aRecords;
+ ::rtl::OUString sTableName;
+
+ aRecords = m_xConnection->getAddressBook()->getMacabRecordsMatch(tableNamePattern);
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+ if(aRecords != NULL)
+ {
+ MacabHeader *aHeader = aRecords->getHeader();
+ sTableName = aRecords->getName();
+
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = new ORowSetValueDecorator(sTableName);
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[9] = ODatabaseMetaDataResultSet::get0Value();
+ aRow[10] = new ORowSetValueDecorator((sal_Int32) 10);
+ aRow[11] = ODatabaseMetaDataResultSet::get1Value();
+ aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[16] = new ORowSetValueDecorator((sal_Int32) 254);
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("YES"));
+
+ sal_Int32 nPosition = 1;
+ ::rtl::OUString sName;
+
+ MacabHeader::iterator aField;
+
+ for ( aField = aHeader->begin();
+ aField != aHeader->end();
+ ++aField, ++nPosition)
+ {
+
+ sName = CFStringToOUString((CFStringRef) (*aField)->value);
+ if (match(columnNamePattern, sName, '\0'))
+ {
+ aRow[4] = new ORowSetValueDecorator(sName);
+ aRow[17] = new ORowSetValueDecorator(nPosition);
+ switch((*aField)->type)
+ {
+ case kABStringProperty:
+ aRow[5] = new ORowSetValueDecorator(DataType::CHAR);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("CHAR"));
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) 256);
+ aRows.push_back(aRow);
+ break;
+ case kABDateProperty:
+ aRow[5] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+ aRows.push_back(aRow);
+ break;
+ case kABIntegerProperty:
+ aRow[5] = new ORowSetValueDecorator(DataType::INTEGER);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("INTEGER"));
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) 20);
+ aRows.push_back(aRow);
+ break;
+ case kABRealProperty:
+ aRow[5] = new ORowSetValueDecorator(DataType::FLOAT);
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("FLOAT"));
+ aRow[7] = new ORowSetValueDecorator((sal_Int32) 15);
+ aRows.push_back(aRow);
+ break;
+ default:
+ ;
+ // shouldn't happen -- throw an error...?
+ }
+ }
+ }
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTables(
+ const Any&,
+ const ::rtl::OUString&,
+ const ::rtl::OUString&,
+ const Sequence< ::rtl::OUString >& types) throw(SQLException, RuntimeException)
+{
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xRef = pResult;
+
+ // check whether we have tables in the requested types
+ // for the moment, we answer only the "TABLE" table type
+ // when no types are given at all, we return all the tables
+ static const ::rtl::OUString aTable(::rtl::OUString::createFromAscii("TABLE"));
+ sal_Bool bTableFound = sal_False;
+ const ::rtl::OUString* p = types.getConstArray(),
+ * pEnd = p + types.getLength();
+
+ if (p == pEnd)
+ {
+ bTableFound = sal_True;
+ }
+ else while (p < pEnd)
+ {
+ if (match(*p, aTable, '\0'))
+ {
+ bTableFound = sal_True;
+ break;
+ }
+ p++;
+ }
+ if (!bTableFound)
+ return xRef;
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ if (aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow(6);
+
+ MacabRecords *xRecords = m_xConnection->getAddressBook()->getMacabRecords();
+ ::std::vector<MacabGroup *> xGroups = m_xConnection->getAddressBook()->getMacabGroups();
+ sal_Int32 i, nGroups;
+ nGroups = xGroups.size();
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = new ORowSetValueDecorator(xRecords->getName());
+ aRow[4] = new ORowSetValueDecorator(aTable);
+ aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRows.push_back(aRow);
+
+ for(i = 0; i < nGroups; i++)
+ {
+ aRow[3] = new ORowSetValueDecorator(xGroups[i]->getName());
+ aRows.push_back(aRow);
+ }
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedureColumns(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedureColumns );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getProcedures(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eProcedures );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getVersionColumns(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eVersionColumns );
+
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
+ Reference< XResultSet > xRef = pResult;
+
+ ODatabaseMetaDataResultSet::ORows aRows;
+
+ if (m_xConnection->getAddressBook()->getMacabRecords(table) != NULL)
+ {
+ ODatabaseMetaDataResultSet::ORow aRow( 9 );
+
+ ::rtl::OUString sName = CFStringToOUString(kABModificationDateProperty);
+
+ aRow[0] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[2] = new ORowSetValueDecorator(sName);
+ aRow[3] = new ORowSetValueDecorator(DataType::TIMESTAMP);
+ aRow[4] = new ORowSetValueDecorator(::rtl::OUString::createFromAscii("TIMESTAMP"));
+
+ aRow[5] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[6] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[7] = ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getExportedKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eExportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getImportedKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eImportedKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getPrimaryKeys(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::ePrimaryKeys );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getIndexInfo(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&,
+ sal_Bool, sal_Bool ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eIndexInfo );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getBestRowIdentifier(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString&, sal_Int32,
+ sal_Bool ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eBestRowIdentifier );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getTablePrivileges(
+ const Any&, const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eTablePrivileges );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getCrossReference(
+ const Any&, const ::rtl::OUString&,
+ const ::rtl::OUString&, const Any&,
+ const ::rtl::OUString&, const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ return new ODatabaseMetaDataResultSet( ODatabaseMetaDataResultSet::eCrossReference );
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabDatabaseMetaData::getUDTs( const Any&, const ::rtl::OUString&, const ::rtl::OUString&, const Sequence< sal_Int32 >& ) throw(SQLException, RuntimeException)
+{
+ OSL_ENSURE(0,"Not implemented yet!");
+ throw SQLException();
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx b/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx
new file mode 100755
index 000000000000..af24f886f56f
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabDatabaseMetaData.hxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_DATABASEMETADATA_HXX_
+#define _CONNECTIVITY_MACAB_DATABASEMETADATA_HXX_
+
+#include "MacabConnection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ //**************************************************************
+ //************ Class: MacabDatabaseMetaData
+ //**************************************************************
+
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XDatabaseMetaData> MacabDatabaseMetaData_BASE;
+
+ class MacabDatabaseMetaData : public MacabDatabaseMetaData_BASE
+ {
+ ::com::sun::star::uno::Reference< MacabConnection > m_xConnection;
+ sal_Bool m_bUseCatalog;
+
+ public:
+
+ inline MacabConnection* getOwnConnection() const { return m_xConnection.get(); }
+
+ MacabDatabaseMetaData(MacabConnection* _pCon);
+ virtual ~MacabDatabaseMetaData();
+
+ // this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getIdentifierQuoteString( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithAddColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsAlterTableWithDropColumn( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCatalogAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogSeparator( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInDataManipulation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInTableDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatements( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTablesInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedures( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getProcedureColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getSchemas( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCatalogs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumnPrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getBestRowIdentifier( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope, sal_Bool nullable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getVersionColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getPrimaryKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getImportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getExportedKeys( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getCrossReference( const ::com::sun::star::uno::Any& primaryCatalog, const ::rtl::OUString& primarySchema, const ::rtl::OUString& primaryTable, const ::com::sun::star::uno::Any& foreignCatalog, const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTypeInfo( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getIndexInfo( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Bool unique, sal_Bool approximate ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_DATABASEMETADATA_HXX_
diff --git a/connectivity/source/drivers/macab/MacabDriver.cxx b/connectivity/source/drivers/macab/MacabDriver.cxx
new file mode 100755
index 000000000000..77823da25a66
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabDriver.cxx
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabDriver.hxx"
+#include "MacabConnection.hxx"
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdb/SQLContext.hpp>
+#include <com/sun/star/lang/NullPointerException.hpp>
+#include <com/sun/star/frame/XDesktop.hpp>
+/** === end UNO includes === **/
+#include <rtl/ustrbuf.hxx>
+#include <tools/diagnose_ex.h>
+#include "resource/macab_res.hrc"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdb;
+using namespace com::sun::star::frame;
+using namespace connectivity::macab;
+
+// =======================================================================
+// = MacabImplModule
+// =======================================================================
+// --------------------------------------------------------------------------------
+MacabImplModule::MacabImplModule( const Reference< XMultiServiceFactory >& _rxFactory )
+ :m_xORB(_rxFactory)
+ ,m_bAttemptedLoadModule(false)
+ ,m_hConnectorModule(NULL)
+ ,m_pConnectionFactoryFunc(NULL)
+{
+ if ( !m_xORB.is() )
+ throw NullPointerException();
+}
+
+// --------------------------------------------------------------------------------
+bool MacabImplModule::isMacOSPresent()
+{
+ return impl_loadModule();
+}
+
+// --------------------------------------------------------------------------------
+namespace
+{
+ template< typename FUNCTION >
+ void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction )
+ {
+ _rFunction = NULL;
+ if ( _rModule )
+ {
+ //
+ const ::rtl::OUString sSymbolName = ::rtl::OUString::createFromAscii( _pAsciiSymbolName );
+ _rFunction = (FUNCTION)( osl_getSymbol( _rModule, sSymbolName.pData ) );
+
+ if ( !_rFunction )
+ { // did not find the symbol
+ OSL_ENSURE( false, ::rtl::OString( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ) + ::rtl::OString( _pAsciiSymbolName ) );
+ osl_unloadModule( _rModule );
+ _rModule = NULL;
+ }
+ }
+ }
+}
+
+// --------------------------------------------------------------------------------
+extern "C" { static void SAL_CALL thisModule() {} }
+
+bool MacabImplModule::impl_loadModule()
+{
+ if ( m_bAttemptedLoadModule )
+ return ( m_hConnectorModule != NULL );
+ m_bAttemptedLoadModule = true;
+
+ OSL_ENSURE( !m_hConnectorModule && !m_pConnectionFactoryFunc,
+ "MacabImplModule::impl_loadModule: inconsistence: inconsistency (never attempted load before, but some values already set)!");
+
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii( SAL_MODULENAME( "macabdrv1" ) );
+ m_hConnectorModule = osl_loadModuleRelative( &thisModule, sModuleName.pData, SAL_LOADMODULE_NOW ); // LAZY! #i61335#
+ OSL_ENSURE( m_hConnectorModule, "MacabImplModule::impl_loadModule: could not load the implementation library!" );
+ if ( !m_hConnectorModule )
+ return false;
+
+ lcl_getFunctionFromModuleOrUnload( m_hConnectorModule, "createMacabConnection", m_pConnectionFactoryFunc );
+
+ if ( !m_hConnectorModule )
+ // one of the symbols did not exist
+ throw RuntimeException();
+
+ return true;
+}
+
+// --------------------------------------------------------------------------------
+void MacabImplModule::impl_unloadModule()
+{
+ OSL_PRECOND( m_hConnectorModule != NULL, "MacabImplModule::impl_unloadModule: no module!" );
+
+ osl_unloadModule( m_hConnectorModule );
+ m_hConnectorModule = NULL;
+
+ m_pConnectionFactoryFunc = NULL;
+
+ m_bAttemptedLoadModule = false;
+}
+
+// --------------------------------------------------------------------------------
+void MacabImplModule::init()
+{
+ if ( !impl_loadModule() )
+ impl_throwNoMacOSException();
+
+}
+
+// --------------------------------------------------------------------------------
+void MacabImplModule::impl_throwNoMacOSException()
+{
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_NO_MAC_OS_FOUND
+ ) );
+ impl_throwGenericSQLException( sError );
+}
+
+// --------------------------------------------------------------------------------
+void MacabImplModule::impl_throwGenericSQLException( const ::rtl::OUString& _rMessage )
+{
+ SQLException aError;
+ aError.Message = _rMessage;
+ aError.SQLState = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "S1000" ) );
+ aError.ErrorCode = 0;
+ throw aError;
+}
+
+// --------------------------------------------------------------------------------
+MacabConnection* MacabImplModule::createConnection( MacabDriver* _pDriver ) const
+{
+ OSL_PRECOND( m_hConnectorModule, "MacabImplModule::createConnection: not initialized!" );
+
+ void* pUntypedConnection = (*m_pConnectionFactoryFunc)( _pDriver );
+ if ( !pUntypedConnection )
+ throw RuntimeException();
+
+ return static_cast< MacabConnection* >( pUntypedConnection );
+}
+
+// --------------------------------------------------------------------------------
+void MacabImplModule::shutdown()
+{
+ if ( !m_hConnectorModule )
+ return;
+
+ impl_unloadModule();
+}
+
+// =======================================================================
+// = MacabDriver
+// =======================================================================
+MacabDriver::MacabDriver(
+ const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : MacabDriver_BASE(m_aMutex),
+ m_xMSFactory(_rxFactory),
+ m_aImplModule(_rxFactory)
+{
+ if ( !m_xMSFactory.is() )
+ throw NullPointerException();
+
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ Reference< XDesktop > xDesktop(
+ m_xMSFactory->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.Desktop" ) ) ),
+ UNO_QUERY_THROW );
+ xDesktop->addTerminateListener( this );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// --------------------------------------------------------------------------------
+void MacabDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroied so all our connections have to be destroied as well
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ WeakComponentImplHelperBase::disposing();
+}
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString MacabDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii( impl_getAsciiImplementationName() );
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > MacabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+
+ return aSNS;
+}
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+//------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+
+ while (pSupported != pEnd && !pSupported->equals(_rServiceName))
+ ++pSupported;
+ return pSupported != pEnd;
+}
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL MacabDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL MacabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aImplModule.init();
+
+ // create a new connection with the given properties and append it to our vector
+ MacabConnection* pConnection = m_aImplModule.createConnection( this );
+ OSL_POSTCOND( pConnection, "MacabDriver::connect: no connection has been created by the factory!" );
+
+ // by definition, the factory function returned an object which was acquired once
+ Reference< XConnection > xConnection = pConnection;
+ pConnection->release();
+
+ // late constructor call which can throw exception and allows a correct dtor call when so
+ pConnection->construct( url, info );
+
+ // remember it
+ m_xConnections.push_back( WeakReferenceHelper( *pConnection ) );
+
+ return xConnection;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ if ( !m_aImplModule.isMacOSPresent() )
+ return sal_False;
+
+ // here we have to look whether we support this URL format
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:address:macab:"), 18));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL MacabDriver::getPropertyInfo( const ::rtl::OUString&, const Sequence< PropertyValue >& ) throw(SQLException, RuntimeException)
+{
+ // if you have something special to say, return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return MACAB_DRIVER_VERSION_MAJOR;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return MACAB_DRIVER_VERSION_MINOR;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabDriver::queryTermination( const EventObject& ) throw (TerminationVetoException, RuntimeException)
+{
+ // nothing to do, nothing to veto
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabDriver::notifyTermination( const EventObject& ) throw (RuntimeException)
+{
+ m_aImplModule.shutdown();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL MacabDriver::disposing( const EventObject& ) throw (RuntimeException)
+{
+ // not interested in (this is the disposing of the desktop, if any)
+}
+// --------------------------------------------------------------------------------
+const sal_Char* MacabDriver::impl_getAsciiImplementationName()
+{
+ return "com.sun.star.comp.sdbc.macab.Driver";
+ // this name is referenced in the configuration and in the macab.xml
+ // Please be careful when changing it.
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString MacabDriver::impl_getConfigurationSettingsPath()
+{
+ ::rtl::OUStringBuffer aPath;
+ aPath.appendAscii( "/org.openoffice.Office.DataAccess/DriverSettings/" );
+ aPath.appendAscii( "com.sun.star.comp.sdbc.macab.Driver" );
+ return aPath.makeStringAndClear();
+}
+// --------------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL MacabDriver::Create( const Reference< XMultiServiceFactory >& _rxFactory ) throw( Exception )
+{
+ return *(new MacabDriver(_rxFactory));
+}
+
diff --git a/connectivity/source/drivers/macab/MacabDriver.hxx b/connectivity/source/drivers/macab/MacabDriver.hxx
new file mode 100755
index 000000000000..1e12a3c2ae55
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabDriver.hxx
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_DRIVER_HXX_
+#define _CONNECTIVITY_MACAB_DRIVER_HXX_
+
+/** === begin UNO includes === **/
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+/** === end UNO includes === **/
+#include <cppuhelper/compbase3.hxx>
+#include <osl/module.h>
+
+// the address book driver's version
+#define MACAB_DRIVER_VERSION "0.1"
+#define MACAB_DRIVER_VERSION_MAJOR 0
+#define MACAB_DRIVER_VERSION_MINOR 1
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabConnection;
+ class MacabDriver;
+
+ typedef void* (SAL_CALL * ConnectionFactoryFunction)( void* _pDriver );
+
+ typedef std::vector< ::com::sun::star::uno::WeakReferenceHelper > OWeakRefArray;
+
+ // ===============================================================
+ // = MacabImplModule
+ // ===============================================================
+ class MacabImplModule
+ {
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xORB;
+
+ /// Did we already attempt to load the module and to retrieve the symbols?
+ bool m_bAttemptedLoadModule;
+ oslModule m_hConnectorModule;
+ ConnectionFactoryFunction m_pConnectionFactoryFunc;
+
+ public:
+ MacabImplModule( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory );
+
+ /** determines whether there is a mac OS present in the environment
+ */
+ bool isMacOSPresent();
+
+ /** initializes the implementation module.
+
+ @raises ::com::sun::star::uno::RuntimeException
+ if the module could be loaded, but required symbols are missing
+ @raises ::com::sun::star::sdbc::SQLException
+ if no Mac OS was found at all
+ */
+ void init();
+
+ /** shuts down the impl module
+ */
+ void shutdown();
+
+ /** creates a new connection
+ @precond
+ <member>init</member> has been called before
+ @raises ::com::sun::star::uno::RuntimeException
+ if no connection object could be created (which is a severe error, normally impossible)
+ */
+ MacabConnection* createConnection( MacabDriver* _pDriver ) const;
+
+ private:
+ /** loads the implementation module and retrieves the needed symbols
+
+ Save against being called multiple times.
+
+ @return <TRUE/> if the module could be loaded successfully.
+
+ @raises ::com::sun::star::uno::RuntimeException
+ if the module could be loaded, but required symbols are missing
+ */
+ bool impl_loadModule();
+
+ /** unloads the implementation module, and resets all function pointers to <NULL/>
+ @precond m_hConnectorModule is not <NULL/>
+ */
+ void impl_unloadModule();
+
+ /** throws an SQLException saying than no Mac OS installation was found
+ */
+ void impl_throwNoMacOSException();
+
+ /** throws a generic SQL exception with SQLState S1000 and error code 0
+ */
+ void impl_throwGenericSQLException( const ::rtl::OUString& _rMessage );
+
+ };
+
+ // ===============================================================
+ // = MacabDriver
+ // ===============================================================
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo,
+ ::com::sun::star::frame::XTerminateListener > MacabDriver_BASE;
+ class MacabDriver : public MacabDriver_BASE
+ {
+ protected:
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ OWeakRefArray m_xConnections; // vector containing a list of all the
+ // MacabConnection objects for this Driver
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ m_xMSFactory; // the multi-service factory
+ MacabImplModule m_aImplModule;
+
+ public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ // XServiceInfo - static versions
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >&
+ getMSFactory() const { return m_xMSFactory; }
+
+ /** returns the driver's implementation name (being pure ASCII) for reference in various places
+ */
+ static const sal_Char* impl_getAsciiImplementationName();
+
+ /** returns the path of our configuration settings
+ */
+ static ::rtl::OUString impl_getConfigurationSettingsPath();
+
+ protected:
+ MacabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMajorVersion() throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinorVersion() throw(::com::sun::star::uno::RuntimeException);
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException);
+
+ private:
+ /** shuts down the library which contains the real implementations
+
+ This method is safe against being called multiple times
+
+ @precond our mutex is locked
+ */
+ void impl_shutdownImplementationModule();
+ };
+ }
+
+}
+
+#endif // _CONNECTIVITY_MACAB_DRIVER_HXX_
diff --git a/connectivity/source/drivers/macab/MacabGroup.cxx b/connectivity/source/drivers/macab/MacabGroup.cxx
new file mode 100644
index 000000000000..e39034df3f10
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabGroup.cxx
@@ -0,0 +1,102 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabGroup.hxx"
+#include "MacabRecords.hxx"
+#include "macabutilities.hxx"
+
+using namespace connectivity::macab;
+
+// -------------------------------------------------------------------------
+/* A MacabGroup is basically a MacabRecords with a different constructor.
+ * It only exists as a different entity for clarification purposes (a group
+ * is its own entity in the Mac OS X Address Book) and because its
+ * construction is so unique (it is based on an already existent
+ * MacabRecords of the entire address book).
+ */
+MacabGroup::MacabGroup(const ABAddressBookRef _addressBook, const MacabRecords *_allRecords, const ABGroupRef _xGroup)
+ : MacabRecords(_addressBook)
+{
+ sal_Int32 i, j, nAllRecordsSize;
+ CFArrayRef xGroupMembers = ABGroupCopyArrayOfAllMembers(_xGroup);
+ ABPersonRef xPerson;
+ CFStringRef sGroupMemberUID;
+ sal_Bool bFound;
+ macabfield *xRecordField;
+
+ // Set the group's name (stored in MacabRecords as m_sName)
+ CFStringRef sGroupName;
+ sGroupName = (CFStringRef) ABRecordCopyValue(_xGroup, kABGroupNameProperty);
+ m_sName = CFStringToOUString(sGroupName);
+ CFRelease(sGroupName);
+
+ // The _group's_ records (remember MacabGroup inherits from MacabRecords)
+ recordsSize = (sal_Int32) CFArrayGetCount(xGroupMembers);
+ records = new MacabRecord *[recordsSize];
+ setHeader(_allRecords->getHeader());
+
+ /* Go through each record in the group and try to find that record's UID
+ * in the MacabRecords that was passed in. If it is found, add that
+ * record to the group. Otherwise, report an error. (All records should
+ * exist in the MacabRecords that was passed in.)
+ */
+ nAllRecordsSize = _allRecords->size();
+ for(i = 0; i < recordsSize; i++)
+ {
+ xPerson = (ABPersonRef) CFArrayGetValueAtIndex(xGroupMembers,i);
+ if(xPerson != NULL)
+ {
+ sGroupMemberUID = (CFStringRef) ABRecordCopyValue(xPerson, kABUIDProperty);
+ if(sGroupMemberUID != NULL)
+ {
+ bFound = sal_False;
+ for(j = 0; j < nAllRecordsSize; j++)
+ {
+ xRecordField = _allRecords->getField(j,CFStringToOUString(kABUIDProperty));
+ if(xRecordField != NULL && xRecordField->value != NULL)
+ {
+ if(CFEqual(xRecordField->value, sGroupMemberUID))
+ {
+ /* Found the matching UID! Insert into the group... */
+ insertRecord(_allRecords->getRecord(j));
+ bFound = sal_True;
+ break;
+ }
+ }
+ }
+ OSL_ENSURE(bFound, "MacabGroup::MacabGroup : Could not find group member based on UID!\n");
+ CFRelease(sGroupMemberUID);
+ }
+ }
+ }
+
+ CFRelease(xGroupMembers);
+}
+
diff --git a/connectivity/source/drivers/macab/MacabGroup.hxx b/connectivity/source/drivers/macab/MacabGroup.hxx
new file mode 100644
index 000000000000..5ce522dffcab
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabGroup.hxx
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_GROUP_HXX_
+#define _CONNECTIVITY_MACAB_GROUP_HXX_
+
+#include "MacabRecords.hxx"
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabGroup: public MacabRecords {
+ public:
+ MacabGroup(const ABAddressBookRef _addressBook, const MacabRecords *_allRecords, const ABGroupRef _xGroup);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_GROUP_HXX_
+
diff --git a/connectivity/source/drivers/macab/MacabHeader.cxx b/connectivity/source/drivers/macab/MacabHeader.cxx
new file mode 100644
index 000000000000..5ecccb5fdd3c
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabHeader.cxx
@@ -0,0 +1,343 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabHeader.hxx"
+#include "MacabRecord.hxx"
+#include "macabutilities.hxx"
+
+#include <math.h>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <connectivity/dbconversion.hxx>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+using namespace ::dbtools;
+
+// -------------------------------------------------------------------------
+MacabHeader::MacabHeader(const sal_Int32 _size, macabfield **_fields)
+{
+ sal_Int32 i;
+ size = _size;
+ fields = new macabfield *[size];
+ for(i = 0; i < size; i++)
+ {
+ if(_fields[i] == NULL)
+ {
+ fields[i] = NULL;
+ }
+ else
+ {
+ /* The constructor duplicates the macabfields it gets because they
+ * are either deleted later or used for other purposes.
+ */
+ fields[i] = new macabfield;
+ fields[i]->type = _fields[i]->type;
+ fields[i]->value = _fields[i]->value;
+ if (fields[i]->value)
+ CFRetain(fields[i]->value);
+ }
+ }
+
+}
+
+// -------------------------------------------------------------------------
+MacabHeader::MacabHeader()
+{
+ size = 0;
+ fields = NULL;
+}
+
+// -------------------------------------------------------------------------
+MacabHeader::~MacabHeader()
+{
+}
+
+// -------------------------------------------------------------------------
+void MacabHeader::operator+= (const MacabHeader *r)
+{
+ /* Add one MacabHeader to another. Anything not already in the header is
+ * added to the end of it.
+ */
+ sal_Int32 rSize = r->getSize();
+ if(rSize != 0) // If the new header does actually have fields
+ {
+ /* If our header is currently empty, just copy all of the fields from
+ * the new header to this one.
+ */
+ if(size == 0)
+ {
+ sal_Int32 i;
+ size = rSize;
+ fields = new macabfield *[size];
+ for(i = 0; i < size; i++)
+ {
+ fields[i] = r->copy(i);
+ }
+ }
+
+ /* Otherwise, only add the duplicates. We do this with a two-pass
+ * approach. First, find out how many fields to add, then reallocate
+ * the size of the fields array and add the old ones at the end.
+ * (More precisely, we create a _new_ fields array with the new length
+ * allocated to it, then get all of the fields from the current
+ * fields array to it, then copy the non-duplicates from the new
+ * header to the end.)
+ */
+ else
+ {
+ sal_Int32 i;
+ sal_Int32 numToAdd = 0, numAdded = 0;
+ macabfield **newFields;
+ for( i = 0; i < rSize; i++)
+ {
+ if(!contains(r->get(i)))
+ {
+ numToAdd++;
+ }
+ }
+
+ newFields = new macabfield *[size+numToAdd];
+ for(i = 0; i < size; i++)
+ {
+ newFields[i] = copy(i);
+ }
+
+ for( i = 0; i < rSize; i++)
+ {
+ if(!contains(r->get(i)))
+ {
+ newFields[size+numAdded] = r->copy(i);
+ numAdded++;
+ if(numAdded == numToAdd)
+ break;
+ }
+ }
+
+ releaseFields();
+ delete [] fields;
+ size += numAdded;
+ fields = newFields;
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString MacabHeader::getString(const sal_Int32 i) const
+{
+ ::rtl::OUString nRet;
+
+ if(i < size)
+ {
+ if(fields[i] == NULL || fields[i]->value == NULL || CFGetTypeID(fields[i]->value) != CFStringGetTypeID())
+ return ::rtl::OUString();
+ try
+ {
+ nRet = CFStringToOUString( (CFStringRef) fields[i]->value);
+ }
+ catch(...){ }
+ }
+
+ return nRet;
+}
+
+// -------------------------------------------------------------------------
+void MacabHeader::sortRecord()
+{
+ sortRecord(0,size);
+}
+
+// -------------------------------------------------------------------------
+macabfield **MacabHeader::sortRecord(const sal_Int32 _start, const sal_Int32 _length)
+{
+ /* Sort using mergesort. Because it uses mergesort, it is recursive and
+ * not in place (so it creates a new array at every step of the
+ * recursion), so if you prefer to use a different sort, please feel
+ * free to implement it.
+ */
+ macabfield** sorted = new macabfield *[_length];
+ if(_length <= 2)
+ {
+ if(_length == 2)
+ {
+ if(compareFields(fields[_start], fields[_start+1]) > 0)
+ {
+ sorted[0] = get(_start+1);
+ sorted[1] = get(_start);
+ }
+ else
+ {
+ sorted[0] = get(_start);
+ sorted[1] = get(_start+1);
+ }
+ }
+ else if(_length == 1)
+ {
+ sorted[0] = get(_start);
+ }
+ }
+ else
+ {
+ sal_Int32 halfLength = floor(_length/2);
+ sal_Int32 fp = 0, lp = 0;
+ sal_Int32 i;
+ macabfield **firstHalf = new macabfield *[halfLength];
+ macabfield **lastHalf = new macabfield *[_length - halfLength];
+
+ firstHalf = sortRecord(_start, halfLength);
+ lastHalf = sortRecord(_start+halfLength, _length-halfLength);
+ for(i = 0; i < _length; i++)
+ {
+ if(compareFields(firstHalf[fp],lastHalf[lp]) < 0)
+ {
+ sorted[i] = firstHalf[fp++];
+ if(fp == halfLength)
+ {
+ for( i++; i < _length; i++)
+ {
+ sorted[i] = lastHalf[lp++];
+ }
+ break;
+ }
+ }
+ else
+ {
+ sorted[i] = lastHalf[lp++];
+ if(lp == _length - halfLength)
+ {
+ for( i++; i < _length; i++)
+ {
+ sorted[i] = firstHalf[fp++];
+ }
+ break;
+ }
+ }
+ }
+ if(_length == size)
+ {
+ fields = sorted;
+ }
+ }
+ return sorted;
+}
+
+sal_Int32 MacabHeader::compareFields(const macabfield *_field1, const macabfield *_field2)
+{
+ /* Comparing two fields in a MacabHeader is different than comparing two
+ * fields in a MacabRecord. It starts in the same way (if one of the two
+ * fields is NULL, it belongs after the other, so it is considered
+ * "greater"). But, then, all headers are CFStrings, no matter what
+ * type they claim to be (since they actually hold the expected type for
+ * the records with that header). That being said, all we have to do is
+ * the built-in CFStringCompare.
+ */
+ if(_field1 == _field2)
+ return 0;
+ if(_field1 == NULL)
+ return 1;
+ if(_field2 == NULL)
+ return -1;
+
+ CFComparisonResult result = CFStringCompare(
+ (CFStringRef) _field1->value,
+ (CFStringRef) _field2->value,
+ 0); // 0 = no options (like ignore case)
+
+ return (sal_Int32) result;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabHeader::getColumnNumber(const ::rtl::OUString s) const
+{
+ sal_Int32 i;
+ for(i = 0; i < size; i++)
+ {
+ if(getString(i) == s)
+ break;
+ }
+
+ if(i == size)
+ i = -1;
+
+ return i;
+}
+
+// -------------------------------------------------------------------------
+MacabHeader *MacabHeader::begin()
+{
+ return this;
+}
+
+// -------------------------------------------------------------------------
+MacabHeader::iterator::iterator ()
+{
+}
+
+// -------------------------------------------------------------------------
+MacabHeader::iterator::~iterator ()
+{
+}
+
+void MacabHeader::iterator::operator= (MacabHeader *_record)
+{
+ id = 0;
+ record = _record;
+}
+
+// -------------------------------------------------------------------------
+void MacabHeader::iterator::operator++ ()
+{
+ id++;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabHeader::iterator::operator!= (const sal_Int32 i) const
+{
+ return(id != i);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabHeader::iterator::operator== (const sal_Int32 i) const
+{
+ return(id == i);
+}
+
+// -------------------------------------------------------------------------
+macabfield *MacabHeader::iterator::operator* () const
+{
+ return record->get(id);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabHeader::end() const
+{
+ return size;
+}
+
diff --git a/connectivity/source/drivers/macab/MacabHeader.hxx b/connectivity/source/drivers/macab/MacabHeader.hxx
new file mode 100644
index 000000000000..ae7de481ab92
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabHeader.hxx
@@ -0,0 +1,71 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_HEADER_HXX_
+#define _CONNECTIVITY_MACAB_HEADER_HXX_
+
+#include "MacabRecord.hxx"
+#include <cppuhelper/compbase3.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabHeader: public MacabRecord{
+ protected:
+ macabfield **sortRecord(sal_Int32 _start, sal_Int32 _length);
+ public:
+ MacabHeader();
+ MacabHeader(const sal_Int32 _size, macabfield **_fields);
+ virtual ~MacabHeader();
+ void operator+= (const MacabHeader *r);
+ ::rtl::OUString getString(const sal_Int32 i) const;
+ void sortRecord();
+ sal_Int32 getColumnNumber(const ::rtl::OUString s) const;
+
+ static sal_Int32 compareFields(const macabfield *_field1, const macabfield *_field2);
+
+ MacabHeader *begin();
+ sal_Int32 end() const;
+ class iterator{
+ protected:
+ sal_Int32 id;
+ MacabHeader *record;
+ public:
+ void operator= (MacabHeader *_record);
+ iterator();
+ ~iterator();
+ void operator++ ();
+ sal_Bool operator!= (const sal_Int32 i) const;
+ sal_Bool operator== (const sal_Int32 i) const;
+ macabfield *operator* () const;
+ };
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_HEADER_HXX_
diff --git a/connectivity/source/drivers/macab/MacabPreparedStatement.cxx b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx
new file mode 100755
index 000000000000..dc8943a46789
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabPreparedStatement.cxx
@@ -0,0 +1,407 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabPreparedStatement.hxx"
+#include "MacabAddressBook.hxx"
+#include "propertyids.hxx"
+#include <connectivity/dbexception.hxx>
+#include "connectivity/dbtools.hxx"
+#include "resource/macab_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(MacabPreparedStatement, "com.sun.star.sdbc.drivers.MacabPreparedStatement", "com.sun.star.sdbc.PreparedStatement");
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::checkAndResizeParameters(sal_Int32 nParams) throw(SQLException)
+{
+ if ( !m_aParameterRow.isValid() )
+ m_aParameterRow = new OValueVector();
+
+ if (nParams < 1)
+ ::dbtools::throwInvalidIndexException(*(MacabPreparedStatement *) this,Any());
+
+ if (nParams >= (sal_Int32) (m_aParameterRow->get()).size())
+ (m_aParameterRow->get()).resize(nParams);
+}
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::setMacabFields() const throw(SQLException)
+{
+ ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns
+
+ xColumns = m_aSQLIterator.getSelectColumns();
+ if (!xColumns.isValid())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_INVALID_COLUMN_SELECTION
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+ m_xMetaData->setMacabFields(xColumns);
+}
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::resetParameters() const throw(SQLException)
+{
+ m_nParameterIndex = 0;
+}
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::getNextParameter(::rtl::OUString &rParameter) const throw(SQLException)
+{
+ if (m_nParameterIndex >= (sal_Int32) (m_aParameterRow->get()).size())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_INVALID_PARA_COUNT
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*(MacabPreparedStatement *) this);
+ }
+
+ rParameter = (m_aParameterRow->get())[m_nParameterIndex];
+
+ m_nParameterIndex++;
+}
+// -------------------------------------------------------------------------
+MacabPreparedStatement::MacabPreparedStatement(
+ MacabConnection* _pConnection,
+ const ::rtl::OUString& sql)
+ : MacabPreparedStatement_BASE(_pConnection),
+ m_sSqlStatement(sql),
+ m_bPrepared(sal_False),
+ m_nParameterIndex(0),
+ m_aParameterRow()
+{
+
+}
+// -------------------------------------------------------------------------
+MacabPreparedStatement::~MacabPreparedStatement()
+{
+}
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::disposing()
+{
+ MacabPreparedStatement_BASE::disposing();
+
+ if (m_aParameterRow.isValid())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+}
+// -------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL MacabPreparedStatement::getMetaData() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ if (!m_xMetaData.is())
+ {
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+ ::rtl::OUString sTableName = MacabAddressBook::getDefaultTableName();
+
+ if(! xTabs.empty() )
+ {
+
+ // can only deal with one table at a time
+ if(xTabs.size() == 1 && !m_aSQLIterator.hasErrors() )
+ sTableName = xTabs.begin()->first;
+
+ }
+ m_xMetaData = new MacabResultSetMetaData(getOwnConnection(),sTableName);
+ setMacabFields();
+ }
+ Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
+ return xMetaData;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::close() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // Reset last warning message
+ try {
+ clearWarnings ();
+ MacabCommonStatement::close();
+ }
+ catch (SQLException &) {
+ // If we get an error, ignore
+ }
+
+ // Remove this Statement object from the Connection object's
+ // list
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabPreparedStatement::execute() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet> xRS = MacabCommonStatement::executeQuery(m_sSqlStatement);
+
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabPreparedStatement::executeUpdate() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // same as in statement with the difference that this statement also can contain parameter
+ return 0;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL MacabPreparedStatement::getConnection() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >) m_pConnection;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabPreparedStatement::executeQuery() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > rs = MacabCommonStatement::executeQuery(m_sSqlStatement);
+
+ return rs;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setNull(sal_Int32 parameterIndex, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex - 1].setNull();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setObjectNull(sal_Int32, sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setObjectNull", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBoolean", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setByte", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setShort", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setInt", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setLong", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setFloat(sal_Int32, float) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setFloat", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setDouble(sal_Int32, double) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setDouble", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setString(sal_Int32 parameterIndex, const ::rtl::OUString &x) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex - 1] = x;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBytes", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setDate(sal_Int32, const Date&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setDate", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setTime(sal_Int32, const Time&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setTime", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setTimestamp", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setBinaryStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBinaryStream", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setCharacterStream(sal_Int32, const Reference< ::com::sun::star::io::XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setCharacterStream", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setObject(sal_Int32 parameterIndex, const Any& x) throw(SQLException, RuntimeException)
+{
+ if(!::dbtools::implSetObject(this,parameterIndex,x))
+ {
+ const ::rtl::OUString sError( m_pConnection->getResources().getResourceStringWithSubstitution(
+ STR_UNKNOWN_PARA_TYPE,
+ "$position$", ::rtl::OUString::valueOf(parameterIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setObjectWithInfo(sal_Int32, const Any&, sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setObjectWithInfo", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setRef(sal_Int32, const Reference< XRef >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setRef", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setBlob(sal_Int32, const Reference< XBlob >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setBlob", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setClob(sal_Int32, const Reference< XClob >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setClob", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::setArray(sal_Int32, const Reference< XArray >&) throw(SQLException, RuntimeException)
+{
+
+
+
+::dbtools::throwFunctionNotSupportedException("setArray", NULL);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabPreparedStatement::clearParameters() throw(SQLException, RuntimeException)
+{
+::dbtools::throwFunctionNotSupportedException("clearParameters", NULL);
+}
+// -------------------------------------------------------------------------
+void MacabPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ break;
+ default:
+ MacabCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+}
diff --git a/connectivity/source/drivers/macab/MacabPreparedStatement.hxx b/connectivity/source/drivers/macab/MacabPreparedStatement.hxx
new file mode 100755
index 000000000000..641eba360a4e
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabPreparedStatement.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_PREPAREDSTATEMENT_HXX_
+#define _CONNECTIVITY_MACAB_PREPAREDSTATEMENT_HXX_
+
+#include "MacabStatement.hxx"
+#include "MacabResultSetMetaData.hxx"
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <cppuhelper/implbase4.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplInheritanceHelper4< MacabCommonStatement,
+ ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::lang::XServiceInfo> MacabPreparedStatement_BASE;
+
+ class MacabPreparedStatement : public MacabPreparedStatement_BASE
+ {
+ protected:
+ ::rtl::OUString m_sSqlStatement;
+ ::rtl::Reference< MacabResultSetMetaData >
+ m_xMetaData;
+ sal_Bool m_bPrepared;
+ mutable sal_Int32 m_nParameterIndex;
+ OValueRow m_aParameterRow;
+
+ void checkAndResizeParameters(sal_Int32 nParams) throw(::com::sun::star::sdbc::SQLException);
+ void setMacabFields() const throw(::com::sun::star::sdbc::SQLException);
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+
+ virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
+ virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
+ virtual ~MacabPreparedStatement();
+
+ public:
+ DECLARE_SERVICE_INFO();
+ MacabPreparedStatement(MacabConnection* _pConnection, const ::rtl::OUString& sql);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_PREPAREDSTATEMENT_HXX_
diff --git a/connectivity/source/drivers/macab/MacabRecord.cxx b/connectivity/source/drivers/macab/MacabRecord.cxx
new file mode 100755
index 000000000000..35817526ff17
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabRecord.cxx
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabRecord.hxx"
+#include "macabutilities.hxx"
+#include <com/sun/star/util/DateTime.hpp>
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+#include <connectivity/dbconversion.hxx>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::util;
+using namespace ::dbtools;
+
+// -------------------------------------------------------------------------
+MacabRecord::MacabRecord()
+{
+ size = 0;
+ fields = NULL;
+}
+
+// -------------------------------------------------------------------------
+MacabRecord::MacabRecord(const sal_Int32 _size)
+{
+ size = _size;
+ fields = new macabfield *[size];
+ sal_Int32 i;
+ for(i = 0; i < size; i++)
+ fields[i] = NULL;
+}
+
+// -------------------------------------------------------------------------
+MacabRecord::~MacabRecord()
+{
+ if(size > 0)
+ {
+ int i;
+ for(i = 0; i < size; i++)
+ {
+ delete fields[i];
+ fields[i] = NULL;
+ }
+ }
+ delete [] fields;
+ fields = NULL;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecord::insertAtColumn (CFTypeRef _value, ABPropertyType _type, const sal_Int32 _column)
+{
+ if(_column < size)
+ {
+ if(fields[_column] == NULL)
+ fields[_column] = new macabfield;
+
+ fields[_column]->value = _value;
+ if (fields[_column]->value)
+ CFRetain(fields[_column]->value);
+ fields[_column]->type = _type;
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabRecord::contains (const macabfield *_field) const
+{
+ if(_field == NULL)
+ return sal_False;
+ else
+ return contains(_field->value);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabRecord::contains (const CFTypeRef _value) const
+{
+ sal_Int32 i;
+ for(i = 0; i < size; i++)
+ {
+ if(fields[i] != NULL)
+ {
+ if(CFEqual(fields[i]->value, _value))
+ {
+ return sal_True;
+ }
+ }
+ }
+
+ return sal_False;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabRecord::getSize() const
+{
+ return size;
+}
+
+// -------------------------------------------------------------------------
+macabfield *MacabRecord::copy(const sal_Int32 i) const
+{
+ /* Note: copy(i) creates a new macabfield identical to that at
+ * location i, whereas get(i) returns a pointer to the macabfield
+ * at location i.
+ */
+ if(i < size)
+ {
+ macabfield *_copy = new macabfield;
+ _copy->type = fields[i]->type;
+ _copy->value = fields[i]->value;
+ if (_copy->value)
+ CFRetain(_copy->value);
+ return _copy;
+ }
+
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+macabfield *MacabRecord::get(const sal_Int32 i) const
+{
+ /* Note: copy(i) creates a new macabfield identical to that at
+ * location i, whereas get(i) returns a pointer to the macabfield
+ * at location i.
+ */
+ if(i < size)
+ {
+ return fields[i];
+ }
+
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecord::releaseFields()
+{
+ /* This method is, at the moment, only used in MacabHeader.cxx, but
+ * the idea is simple: if you are not destroying this object but want
+ * to clear it of its macabfields, you should release each field's
+ * value.
+ */
+ sal_Int32 i;
+ for(i = 0; i < size; i++)
+ CFRelease(fields[i]->value);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabRecord::compareFields(const macabfield *_field1, const macabfield *_field2)
+{
+
+ /* When comparing records, if either field is NULL (and the other is
+ * not), that field is considered "greater than" the other, so that it
+ * shows up later in the list when fields are ordered.
+ */
+ if(_field1 == _field2)
+ return 0;
+ if(_field1 == NULL)
+ return 1;
+ if(_field2 == NULL)
+ return -1;
+
+ /* If they aren't the same type, for now, return the one with
+ * the smaller type ID... I don't know of a better way to compare
+ * two different data types.
+ */
+ if(_field1->type != _field2->type)
+ return(_field1->type - _field2->type);
+
+ CFComparisonResult result;
+
+ /* Carbon has a unique compare function for each data type: */
+ switch(_field1->type)
+ {
+ case kABStringProperty:
+ result = CFStringCompare(
+ (CFStringRef) _field1->value,
+ (CFStringRef) _field2->value,
+ 0); // 0 = no options (like ignore case)
+ break;
+
+ case kABDateProperty:
+ result = CFDateCompare(
+ (CFDateRef) _field1->value,
+ (CFDateRef) _field2->value,
+ NULL); // NULL = unused variable
+ break;
+
+ case kABIntegerProperty:
+ case kABRealProperty:
+ result = CFNumberCompare(
+ (CFNumberRef) _field1->value,
+ (CFNumberRef) _field2->value,
+ NULL); // NULL = unused variable
+ break;
+
+ default:
+ result = kCFCompareEqualTo; // can't compare
+ }
+
+ return (sal_Int32) result;
+}
+
+// -------------------------------------------------------------------------
+/* Create a macabfield out of an OUString and type. Together with the
+ * method fieldToString() (below), it is possible to switch conveniently
+ * between an OUString and a macabfield (for use when creating and handling
+ * SQL statement).
+ */
+macabfield *MacabRecord::createMacabField(const ::rtl::OUString _newFieldString, const ABPropertyType _abType)
+{
+ macabfield *newField = NULL;
+ switch(_abType)
+ {
+ case kABStringProperty:
+ newField = new macabfield;
+ newField->value = OUStringToCFString(_newFieldString);
+ newField->type = _abType;
+ break;
+ case kABDateProperty:
+ {
+ DateTime aDateTime = DBTypeConversion::toDateTime(_newFieldString);
+
+ // bad format...
+ if(aDateTime.Year == 0 && aDateTime.Month == 0 && aDateTime.Day == 0)
+ {
+ }
+ else
+ {
+ double nTime = DBTypeConversion::toDouble(aDateTime, DBTypeConversion::getStandardDate());
+ nTime -= kCFAbsoluteTimeIntervalSince1970;
+ newField = new macabfield;
+ newField->value = CFDateCreate(NULL, (CFAbsoluteTime) nTime);
+ newField->type = _abType;
+ }
+ }
+ break;
+ case kABIntegerProperty:
+ try
+ {
+ sal_Int64 nVal = _newFieldString.toInt64();
+
+ newField = new macabfield;
+ newField->value = CFNumberCreate(NULL,kCFNumberLongType, &nVal);
+ newField->type = _abType;
+ }
+ // bad format...
+ catch(...)
+ {
+ }
+ break;
+ case kABRealProperty:
+ try
+ {
+ double nVal = _newFieldString.toDouble();
+
+ newField = new macabfield;
+ newField->value = CFNumberCreate(NULL,kCFNumberDoubleType, &nVal);
+ newField->type = _abType;
+ }
+ // bad format...
+ catch(...)
+ {
+ }
+ break;
+ default:
+ ;
+ }
+ return newField;
+}
+
+// -------------------------------------------------------------------------
+/* Create an OUString out of a macabfield. Together with the method
+ * createMacabField() (above), it is possible to switch conveniently
+ * between an OUString and a macabfield (for use when creating and handling
+ * SQL statement).
+ */
+::rtl::OUString MacabRecord::fieldToString(const macabfield *_aField)
+{
+ if(_aField == NULL)
+ return ::rtl::OUString();
+
+ ::rtl::OUString fieldString;
+
+ switch(_aField->type)
+ {
+ case kABStringProperty:
+ fieldString = CFStringToOUString((CFStringRef) _aField->value);
+ break;
+ case kABDateProperty:
+ {
+ DateTime aTime = CFDateToDateTime((CFDateRef) _aField->value);
+ fieldString = DBTypeConversion::toDateTimeString(aTime);
+ }
+ break;
+ case kABIntegerProperty:
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) _aField->value );
+ sal_Int64 nVal;
+ // Should we check for the wrong type here, e.g., a float?
+ sal_Bool m_bSuccess = !CFNumberGetValue((CFNumberRef) _aField->value, numberType, &nVal);
+ if(m_bSuccess != sal_False)
+ fieldString = ::rtl::OUString::valueOf(nVal);
+ }
+ break;
+ case kABRealProperty:
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) _aField->value );
+ double nVal;
+ // Should we check for the wrong type here, e.g., an int?
+ sal_Bool m_bSuccess = !CFNumberGetValue((CFNumberRef) _aField->value, numberType, &nVal);
+ if(m_bSuccess != sal_False)
+ fieldString = ::rtl::OUString::valueOf(nVal);
+ }
+ break;
+ default:
+ ;
+ }
+ return fieldString;
+
+}
diff --git a/connectivity/source/drivers/macab/MacabRecord.hxx b/connectivity/source/drivers/macab/MacabRecord.hxx
new file mode 100755
index 000000000000..c1327e823bea
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabRecord.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_RECORD_HXX_
+#define _CONNECTIVITY_MACAB_RECORD_HXX_
+
+#include <cppuhelper/compbase3.hxx>
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ /* a MacabRecord is at root a list of macabfields (which is just
+ * something to hold both a CFTypeRef (a CoreFoundation object) and
+ * its Address Book type.
+ */
+ struct macabfield
+ {
+ CFTypeRef value;
+ ABPropertyType type;
+ };
+
+ class MacabRecord{
+ protected:
+ sal_Int32 size;
+ macabfield **fields;
+ protected:
+ void releaseFields();
+ public:
+ MacabRecord();
+ MacabRecord(const sal_Int32 _size);
+ virtual ~MacabRecord();
+ void insertAtColumn (CFTypeRef _value, ABPropertyType _type, const sal_Int32 _column);
+ sal_Bool contains(const macabfield *_field) const;
+ sal_Bool contains(const CFTypeRef _value) const;
+ sal_Int32 getSize() const;
+ macabfield *copy(const sal_Int32 i) const;
+ macabfield *get(const sal_Int32 i) const;
+
+ static sal_Int32 compareFields(const macabfield *_field1, const macabfield *_field2);
+ static macabfield *createMacabField(const ::rtl::OUString _newFieldString, const ABPropertyType _abtype);
+ static ::rtl::OUString fieldToString(const macabfield *_aField);
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_RECORD_HXX_
diff --git a/connectivity/source/drivers/macab/MacabRecords.cxx b/connectivity/source/drivers/macab/MacabRecords.cxx
new file mode 100755
index 000000000000..173ffa9627d8
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabRecords.cxx
@@ -0,0 +1,1212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabRecords.hxx"
+#include "MacabRecord.hxx"
+#include "MacabHeader.hxx"
+#include "macabutilities.hxx"
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+#include <com/sun/star/util/DateTime.hpp>
+
+using namespace connectivity::macab;
+using namespace com::sun::star::util;
+
+// -------------------------------------------------------------------------
+MacabRecords::MacabRecords(const ABAddressBookRef _addressBook, MacabHeader *_header, MacabRecord **_records, sal_Int32 _numRecords)
+{
+ /* Variables passed in... */
+ header = _header;
+ recordsSize = _numRecords;
+ currentRecord = _numRecords;
+ records = _records;
+ addressBook = _addressBook;
+
+ /* Default variables... */
+ recordType = kABPersonRecordType;
+
+ /* Variables constructed... */
+ bootstrap_CF_types();
+ bootstrap_requiredProperties();
+}
+
+// -------------------------------------------------------------------------
+/* Creates a MacabRecords from another: copies the length, name, and
+ * address book of the original, but the header or the records themselves.
+ * The idea is that the only reason to copy a MacabRecords is to create
+ * a filtered version of it, which can have the same length (to avoid
+ * resizing) and will work from the same base addressbook, but might have
+ * entirey different values and even (possibly in the future) a different
+ * header.
+ */
+MacabRecords::MacabRecords(const MacabRecords *_copy)
+{
+ /* Variables passed in... */
+ recordsSize = _copy->recordsSize;
+ addressBook = _copy->addressBook;
+ m_sName = _copy->m_sName;
+
+ /* Default variables... */
+ currentRecord = 0;
+ header = NULL;
+ records = new MacabRecord *[recordsSize];
+ recordType = kABPersonRecordType;
+
+ /* Variables constructed... */
+ bootstrap_CF_types();
+ bootstrap_requiredProperties();
+}
+
+// -------------------------------------------------------------------------
+MacabRecords::MacabRecords(const ABAddressBookRef _addressBook)
+{
+ /* Variables passed in... */
+ addressBook = _addressBook;
+
+ /* Default variables... */
+ recordsSize = 0;
+ currentRecord = 0;
+ records = NULL;
+ header = NULL;
+ recordType = kABPersonRecordType;
+
+ /* Variables constructed... */
+ bootstrap_CF_types();
+ bootstrap_requiredProperties();
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::initialize()
+{
+
+ /* Make sure everything is NULL before initializing. (We usually just
+ * initialize after we use the constructor that takes only a
+ * MacabAddressBook, so these variables will most likely already be
+ * NULL.
+ */
+ if(records != NULL)
+ {
+ sal_Int32 i;
+
+ for(i = 0; i < recordsSize; i++)
+ delete records[i];
+
+ delete [] records;
+ }
+
+ if(header != NULL)
+ delete header;
+
+ /* We can handle both default record Address Book record types in
+ * this method, though only kABPersonRecordType is ever used.
+ */
+ CFArrayRef allRecords;
+ if(CFStringCompare(recordType, kABPersonRecordType, 0) == kCFCompareEqualTo)
+ allRecords = ABCopyArrayOfAllPeople(addressBook);
+ else
+ allRecords = ABCopyArrayOfAllGroups(addressBook);
+
+ ABRecordRef record;
+ sal_Int32 i;
+ recordsSize = (sal_Int32) CFArrayGetCount(allRecords);
+ records = new MacabRecord *[recordsSize];
+
+ /* First, we create the header... */
+ header = createHeaderForRecordType(allRecords, recordType);
+
+ /* Then, we create each of the records... */
+ for(i = 0; i < recordsSize; i++)
+ {
+ record = (ABRecordRef) CFArrayGetValueAtIndex(allRecords, i);
+ records[i] = createMacabRecord(record, header, recordType);
+ }
+ currentRecord = recordsSize;
+
+ CFRelease(allRecords);
+}
+
+// -------------------------------------------------------------------------
+MacabRecords::~MacabRecords()
+{
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::setHeader(MacabHeader *_header)
+{
+ if(header != NULL)
+ delete header;
+ header = _header;
+}
+
+// -------------------------------------------------------------------------
+MacabHeader *MacabRecords::getHeader() const
+{
+ return header;
+}
+
+// -------------------------------------------------------------------------
+/* Inserts a MacabRecord at a given location. If there is already a
+ * MacabRecord at that location, return it.
+ */
+MacabRecord *MacabRecords::insertRecord(MacabRecord *_newRecord, const sal_Int32 _location)
+{
+ MacabRecord *oldRecord;
+
+ /* If the location is greater than the current allocated size of this
+ * MacabRecords, allocate more space.
+ */
+ if(_location >= recordsSize)
+ {
+ sal_Int32 i;
+ MacabRecord **newRecordsArray = new MacabRecord *[_location+1];
+ for(i = 0; i < recordsSize; i++)
+ {
+ newRecordsArray[i] = records[i];
+ }
+ delete [] records;
+ records = newRecordsArray;
+ }
+
+ /* Remember: currentRecord refers to one above the highest existing
+ * record (i.e., it refers to where to place the next record if a
+ * location is not given).
+ */
+ if(_location >= currentRecord)
+ currentRecord = _location+1;
+
+ oldRecord = records[_location];
+ records[_location] = _newRecord;
+ return oldRecord;
+}
+
+// -------------------------------------------------------------------------
+/* Insert a record at the next available place. */
+void MacabRecords::insertRecord(MacabRecord *_newRecord)
+{
+ insertRecord(_newRecord, currentRecord);
+}
+
+// -------------------------------------------------------------------------
+MacabRecord *MacabRecords::getRecord(const sal_Int32 _location) const
+{
+ if(_location >= recordsSize)
+ return NULL;
+ return records[_location];
+}
+
+// -------------------------------------------------------------------------
+macabfield *MacabRecords::getField(const sal_Int32 _recordNumber, const sal_Int32 _columnNumber) const
+{
+ if(_recordNumber >= recordsSize)
+ return NULL;
+
+ MacabRecord *record = records[_recordNumber];
+
+ if(_columnNumber < 0 || _columnNumber >= record->getSize())
+ return NULL;
+
+ return record->get(_columnNumber);
+}
+
+// -------------------------------------------------------------------------
+macabfield *MacabRecords::getField(const sal_Int32 _recordNumber, const ::rtl::OUString _columnName) const
+{
+ if(header != NULL)
+ {
+ sal_Int32 columnNumber = header->getColumnNumber(_columnName);
+ if(columnNumber == -1)
+ return NULL;
+
+ return getField(_recordNumber, columnNumber);
+ }
+ else
+ {
+ // error: shouldn't access field with null header!
+ return NULL;
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabRecords::getFieldNumber(const ::rtl::OUString _columnName) const
+{
+ if(header != NULL)
+ return header->getColumnNumber(_columnName);
+ else
+ // error: shouldn't access field with null header!
+ return -1;
+}
+
+// -------------------------------------------------------------------------
+/* Create the lcl_CFTypes array -- we need this because there is no
+ * way to get the ABType of an object from the object itself, and the
+ * function ABTypeOfProperty can't handle multiple levels of data
+ * (e.g., it can tell us that "address" is of type
+ * kABDictionaryProperty, but it cannot tell us that all of the keys
+ * and values in the dictionary have type kABStringProperty. On the
+ * other hand, we _can_ get the CFType out of any object.
+ * Unfortunately, all information about CFTypeIDs comes with the
+ * warning that they change between releases, so we build them
+ * ourselves here. (The one that we can't build is for multivalues,
+ * e.g., kABMultiStringProperty. All of these appear to have the
+ * same type: 1, but there is no function that I've found to give
+ * us that dynamically in case that number ever changes.
+ */
+void MacabRecords::bootstrap_CF_types()
+{
+ lcl_CFTypesLength = 6;
+ lcl_CFTypes = new lcl_CFType[lcl_CFTypesLength];
+
+ lcl_CFTypes[0].cf = CFNumberGetTypeID();
+ lcl_CFTypes[0].ab = kABIntegerProperty;
+
+ lcl_CFTypes[1].cf = CFStringGetTypeID();
+ lcl_CFTypes[1].ab = kABStringProperty;
+
+ lcl_CFTypes[2].cf = CFDateGetTypeID();
+ lcl_CFTypes[2].ab = kABDateProperty;
+
+ lcl_CFTypes[3].cf = CFArrayGetTypeID();
+ lcl_CFTypes[3].ab = kABArrayProperty;
+
+ lcl_CFTypes[4].cf = CFDictionaryGetTypeID();
+ lcl_CFTypes[4].ab = kABDictionaryProperty;
+
+ lcl_CFTypes[5].cf = CFDataGetTypeID();
+ lcl_CFTypes[5].ab = kABDataProperty;
+}
+
+// -------------------------------------------------------------------------
+/* This is based on the possible fields required in the mail merge template
+ * in sw. If the fields possible there change, it would be optimal to
+ * change these fields as well.
+ */
+void MacabRecords::bootstrap_requiredProperties()
+{
+ numRequiredProperties = 7;
+ requiredProperties = new CFStringRef[numRequiredProperties];
+ requiredProperties[0] = kABTitleProperty;
+ requiredProperties[1] = kABFirstNameProperty;
+ requiredProperties[2] = kABLastNameProperty;
+ requiredProperties[3] = kABOrganizationProperty;
+ requiredProperties[4] = kABAddressProperty;
+ requiredProperties[5] = kABPhoneProperty;
+ requiredProperties[6] = kABEmailProperty;
+}
+
+// -------------------------------------------------------------------------
+/* Create the header for a given record type and a given array of records.
+ * Because the array of records and the record type are given, if you want
+ * to, you can run this method on the members of a group, or on any other
+ * filtered list of people and get a header relevant to them (e.g., if
+ * they only have home addresses, the work address fields won't show up).
+ */
+MacabHeader *MacabRecords::createHeaderForRecordType(const CFArrayRef _records, const CFStringRef _recordType) const
+{
+ /* We have two types of properties for a given record type, nonrequired
+ * and required. Required properties are ones that will show up whether
+ * or not they are empty. Nonrequired properties will only show up if
+ * at least one record in the set has that property filled. The reason
+ * is that some properties, like the kABTitleProperty are required by
+ * the mail merge wizard (in module sw) but are by default not shown in
+ * the Mac OS X address book, so they would be weeded out at this stage
+ * and not shown if they were not required.
+ *
+ * Note: with the addition of required properties, I am not sure that
+ * this method still works for kABGroupRecordType (since the required
+ * properites are all for kABPersonRecordType).
+ *
+ * Note: required properties are constructed in the method
+ * bootstrap_requiredProperties() (above).
+ */
+ CFArrayRef allProperties = ABCopyArrayOfPropertiesForRecordType(addressBook, _recordType);
+ CFStringRef *nonRequiredProperties;
+ sal_Int32 numRecords = (sal_Int32) CFArrayGetCount(_records);
+ sal_Int32 numProperties = (sal_Int32) CFArrayGetCount(allProperties);
+ sal_Int32 numNonRequiredProperties = numProperties - numRequiredProperties;
+
+ /* While searching through the properties for required properties, these
+ * sal_Bools will keep track of what we have found.
+ */
+ sal_Bool bFoundProperty;
+ sal_Bool bFoundRequiredProperties[numRequiredProperties];
+
+
+ /* We have three MacabHeaders: headerDataForProperty is where we
+ * store the result of createHeaderForProperty(), which return a
+ * MacabHeader for a single property. lcl_header is where we store
+ * the MacabHeader that we are constructing. And, nonRequiredHeader
+ * is where we construct the MacabHeader for non-required properties,
+ * so that we can sort them before adding them to lcl_header.
+ */
+ MacabHeader *headerDataForProperty;
+ MacabHeader *lcl_header = new MacabHeader();
+ MacabHeader *nonRequiredHeader = new MacabHeader();
+
+ /* Other variables... */
+ sal_Int32 i, j, k;
+ ABRecordRef record;
+ CFStringRef property;
+
+
+ /* Allocate and initialize... */
+ nonRequiredProperties = new CFStringRef[numNonRequiredProperties];
+ k = 0;
+ for(i = 0; i < numRequiredProperties; i++)
+ bFoundRequiredProperties[i] = sal_False;
+
+ /* Determine the non-required properties... */
+ for(i = 0; i < numProperties; i++)
+ {
+ property = (CFStringRef) CFArrayGetValueAtIndex(allProperties, i);
+ bFoundProperty = sal_False;
+ for(j = 0; j < numRequiredProperties; j++)
+ {
+ if(CFEqual(property, requiredProperties[j]))
+ {
+ bFoundProperty = sal_True;
+ bFoundRequiredProperties[j] = sal_True;
+ break;
+ }
+ }
+
+ if(bFoundProperty == sal_False)
+ {
+ /* If we have found too many non-required properties */
+ if(k == numNonRequiredProperties)
+ {
+ k++; // so that the OSL_ENSURE below fails
+ break;
+ }
+ nonRequiredProperties[k] = property;
+ k++;
+ }
+ }
+
+ // Somehow, we got too many or too few non-requird properties...
+ // Most likely, one of the required properties no longer exists, which
+ // we also test later.
+ OSL_ENSURE(k == numNonRequiredProperties, "MacabRecords::createHeaderForRecordType: Found an unexpected number of non-required properties");
+
+ /* Fill the header with required properties first... */
+ for(i = 0; i < numRequiredProperties; i++)
+ {
+ if(bFoundRequiredProperties[i] == sal_True)
+ {
+ /* The order of these matters (we want all address properties
+ * before any phone properties, or else things will look weird),
+ * so we get all possibilitities for each property, going through
+ * each record, and then go onto the next property.
+ * (Note: the reason that we have to go through all records
+ * in the first place is that properties like address, phone, and
+ * e-mail are multi-value properties with an unknown number of
+ * values. A user could specify thirteen different kinds of
+ * e-mail addresses for one of her or his contacts, and we need to
+ * get all of them.
+ */
+ for(j = 0; j < numRecords; j++)
+ {
+ record = (ABRecordRef) CFArrayGetValueAtIndex(_records, j);
+ headerDataForProperty = createHeaderForProperty(record,requiredProperties[i],_recordType,sal_True);
+ if(headerDataForProperty != NULL)
+ {
+ (*lcl_header) += headerDataForProperty;
+ delete headerDataForProperty;
+ }
+ }
+ }
+ else
+ {
+ // Couldn't find a required property...
+ OSL_ENSURE(false, ::rtl::OString("MacabRecords::createHeaderForRecordType: could not find required property: ") +
+ ::rtl::OUStringToOString(CFStringToOUString(requiredProperties[i]), RTL_TEXTENCODING_ASCII_US));
+ }
+ }
+
+ /* And now, non-required properties... */
+ for(i = 0; i < numRecords; i++)
+ {
+ record = (ABRecordRef) CFArrayGetValueAtIndex(_records, i);
+
+ for(j = 0; j < numNonRequiredProperties; j++)
+ {
+ property = nonRequiredProperties[j];
+ headerDataForProperty = createHeaderForProperty(record,property,_recordType,sal_False);
+ if(headerDataForProperty != NULL)
+ {
+ (*nonRequiredHeader) += headerDataForProperty;
+ delete headerDataForProperty;
+ }
+ }
+
+ }
+ nonRequiredHeader->sortRecord();
+
+ (*lcl_header) += nonRequiredHeader;
+ delete nonRequiredHeader;
+
+ CFRelease(allProperties);
+ delete [] nonRequiredProperties;
+
+ return lcl_header;
+}
+
+// -------------------------------------------------------------------------
+/* Create a header for a single property. Basically, this method gets
+ * the property's value and type and then calls another method of
+ * the same name to do the dirty work.
+ */
+MacabHeader *MacabRecords::createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const sal_Bool _isPropertyRequired) const
+{
+ // local variables
+ CFStringRef localizedPropertyName;
+ CFTypeRef propertyValue;
+ ABPropertyType propertyType;
+ MacabHeader *result;
+
+ /* Get the property's value */
+ propertyValue = ABRecordCopyValue(_record,_propertyName);
+ if(propertyValue == NULL && _isPropertyRequired == sal_False)
+ return NULL;
+
+ propertyType = ABTypeOfProperty(addressBook, _recordType, _propertyName);
+ localizedPropertyName = ABCopyLocalizedPropertyOrLabel(_propertyName);
+
+ result = createHeaderForProperty(propertyType, propertyValue, localizedPropertyName);
+
+ if(propertyValue != NULL)
+ CFRelease(propertyValue);
+
+ return result;
+}
+
+// -------------------------------------------------------------------------
+/* Create a header for a single property. This method is recursive
+ * because a single property might contain several sub-properties that
+ * we also want to treat singly.
+ */
+MacabHeader *MacabRecords::createHeaderForProperty(const ABPropertyType _propertyType, const CFTypeRef _propertyValue, const CFStringRef _propertyName) const
+{
+ macabfield **headerNames = NULL;
+ sal_Int32 length = 0;
+
+ switch(_propertyType)
+ {
+ /* Scalars */
+ case kABStringProperty:
+ case kABRealProperty:
+ case kABIntegerProperty:
+ case kABDateProperty:
+ length = 1;
+ headerNames = new macabfield *[1];
+ headerNames[0] = new macabfield;
+ headerNames[0]->value = _propertyName;
+ headerNames[0]->type = _propertyType;
+ break;
+
+ /* Multi-scalars */
+ case kABMultiIntegerProperty:
+ case kABMultiDateProperty:
+ case kABMultiStringProperty:
+ case kABMultiRealProperty:
+ case kABMultiDataProperty:
+ /* For non-scalars, we can only get more information if the property
+ * actually exists.
+ */
+ if(_propertyValue != NULL)
+ {
+ sal_Int32 i;
+
+ sal_Int32 multiLength = ABMultiValueCount((ABMutableMultiValueRef) _propertyValue);
+ CFStringRef multiLabel, localizedMultiLabel;
+ ::rtl::OUString multiLabelString;
+ ::rtl::OUString multiPropertyString;
+ ::rtl::OUString headerNameString;
+ ABPropertyType multiType = (ABPropertyType) (ABMultiValuePropertyType((ABMutableMultiValueRef) _propertyValue) - 0x100);
+
+ length = multiLength;
+ headerNames = new macabfield *[multiLength];
+ multiPropertyString = CFStringToOUString(_propertyName);
+
+ /* Go through each element, and - since each element is a scalar -
+ * just create a new macabfield for it.
+ */
+ for(i = 0; i < multiLength; i++)
+ {
+ multiLabel = ABMultiValueCopyLabelAtIndex((ABMutableMultiValueRef) _propertyValue, i);
+ localizedMultiLabel = ABCopyLocalizedPropertyOrLabel(multiLabel);
+ multiLabelString = CFStringToOUString(localizedMultiLabel);
+ CFRelease(multiLabel);
+ CFRelease(localizedMultiLabel);
+ headerNameString = multiPropertyString + ::rtl::OUString::createFromAscii(": ") + fixLabel(multiLabelString);
+ headerNames[i] = new macabfield;
+ headerNames[i]->value = OUStringToCFString(headerNameString);
+ headerNames[i]->type = multiType;
+ }
+ }
+ break;
+
+ /* Multi-array or dictionary */
+ case kABMultiArrayProperty:
+ case kABMultiDictionaryProperty:
+ /* For non-scalars, we can only get more information if the property
+ * actually exists.
+ */
+ if(_propertyValue != NULL)
+ {
+ sal_Int32 i,j,k;
+
+ // Total number of multi-array or multi-dictionary elements.
+ sal_Int32 multiLengthFirstLevel = ABMultiValueCount((ABMutableMultiValueRef) _propertyValue);
+
+ /* Total length, including the length of each element (e.g., if
+ * this multi-dictionary contains three dictionaries, and each
+ * dictionary has four elements, this variable will be twelve,
+ * whereas multiLengthFirstLevel will be three.
+ */
+ sal_Int32 multiLengthSecondLevel = 0;
+
+ CFStringRef multiLabel, localizedMultiLabel;
+ CFTypeRef multiValue;
+ ::rtl::OUString multiLabelString;
+ ::rtl::OUString multiPropertyString;
+ MacabHeader **multiHeaders = new MacabHeader *[multiLengthFirstLevel];
+ ABPropertyType multiType = (ABPropertyType) (ABMultiValuePropertyType((ABMutableMultiValueRef) _propertyValue) - 0x100);
+
+ multiPropertyString = CFStringToOUString(_propertyName);
+
+ /* Go through each element - since each element can really
+ * contain anything, we run this method again on each element
+ * and store the resulting MacabHeader (in the multiHeaders
+ * array). Then, all we'll have to do is combine the MacabHeaders
+ * into a single one.
+ */
+ for(i = 0; i < multiLengthFirstLevel; i++)
+ {
+ /* label */
+ multiLabel = ABMultiValueCopyLabelAtIndex((ABMutableMultiValueRef) _propertyValue, i);
+ multiValue = ABMultiValueCopyValueAtIndex((ABMutableMultiValueRef) _propertyValue, i);
+ if(multiValue && multiLabel)
+ {
+ localizedMultiLabel = ABCopyLocalizedPropertyOrLabel(multiLabel);
+ multiLabelString = multiPropertyString + ::rtl::OUString::createFromAscii(": ") + fixLabel(CFStringToOUString(localizedMultiLabel));
+ CFRelease(multiLabel);
+ CFRelease(localizedMultiLabel);
+ multiLabel = OUStringToCFString(multiLabelString);
+ multiHeaders[i] = createHeaderForProperty(multiType, multiValue, multiLabel);
+ if (!multiHeaders[i])
+ multiHeaders[i] = new MacabHeader();
+ multiLengthSecondLevel += multiHeaders[i]->getSize();
+ }
+ else
+ {
+ multiHeaders[i] = new MacabHeader();
+ }
+ if(multiValue)
+ CFRelease(multiValue);
+ }
+
+ /* We now have enough information to create our final MacabHeader.
+ * We go through each field of each header and add it to the
+ * headerNames array (which is what is used below to construct
+ * the MacabHeader we return).
+ */
+ length = multiLengthSecondLevel;
+ headerNames = new macabfield *[multiLengthSecondLevel];
+
+ for(i = 0, j = 0, k = 0; i < multiLengthSecondLevel; i++,k++)
+ {
+ while(multiHeaders[j]->getSize() == k)
+ {
+ j++;
+ k = 0;
+ }
+
+ headerNames[i] = multiHeaders[j]->copy(k);
+ }
+ for(i = 0; i < multiLengthFirstLevel; i++)
+ delete multiHeaders[i];
+
+ delete [] multiHeaders;
+ }
+ break;
+
+ /* Dictionary */
+ case kABDictionaryProperty:
+ /* For non-scalars, we can only get more information if the property
+ * actually exists.
+ */
+ if(_propertyValue != NULL)
+ {
+ /* Assume all keys are strings */
+ sal_Int32 numRecords = (sal_Int32) CFDictionaryGetCount((CFDictionaryRef) _propertyValue);
+
+ /* The only method for getting info out of a CFDictionary, of both
+ * keys and values, is to all of them all at once, so these
+ * variables will hold them.
+ */
+ CFStringRef *dictKeys;
+ CFTypeRef *dictValues;
+
+ sal_Int32 i,j,k;
+ ::rtl::OUString dictKeyString, propertyNameString;
+ ABPropertyType dictType;
+ MacabHeader **dictHeaders = new MacabHeader *[numRecords];
+ ::rtl::OUString dictLabelString;
+ CFStringRef dictLabel, localizedDictKey;
+
+ /* Get the keys and values */
+ dictKeys = (CFStringRef *) malloc(sizeof(CFStringRef)*numRecords);
+ dictValues = (CFTypeRef *) malloc(sizeof(CFTypeRef)*numRecords);
+ CFDictionaryGetKeysAndValues((CFDictionaryRef) _propertyValue, (const void **) dictKeys, (const void **) dictValues);
+
+ propertyNameString = CFStringToOUString(_propertyName);
+
+ length = 0;
+ /* Go through each element - assuming that the key is a string but
+ * that the value could be anything. Since the value could be
+ * anything, we can't assume that it is scalar (it could even be
+ * another dictionary), so we attempt to get its type using
+ * the method getABTypeFromCFType and then run this method
+ * recursively on that element, storing the MacabHeader that
+ * results. Then, we just combine all of the MacabHeaders into
+ * one.
+ */
+ for(i = 0; i < numRecords; i++)
+ {
+ dictType = (ABPropertyType) getABTypeFromCFType( CFGetTypeID(dictValues[i]) );
+ localizedDictKey = ABCopyLocalizedPropertyOrLabel(dictKeys[i]);
+ dictKeyString = CFStringToOUString(localizedDictKey);
+ dictLabelString = propertyNameString + ::rtl::OUString::createFromAscii(": ") + fixLabel(dictKeyString);
+ dictLabel = OUStringToCFString(dictLabelString);
+ dictHeaders[i] = createHeaderForProperty(dictType, dictValues[i], dictLabel);
+ if (!dictHeaders[i])
+ dictHeaders[i] = new MacabHeader();
+ length += dictHeaders[i]->getSize();
+ CFRelease(dictLabel);
+ CFRelease(localizedDictKey);
+ }
+
+ /* Combine all of the macabfields in each MacabHeader into the
+ * headerNames array, which (at the end of this method) is used
+ * to create the MacabHeader that is returned.
+ */
+ headerNames = new macabfield *[length];
+ for(i = 0, j = 0, k = 0; i < length; i++,k++)
+ {
+ while(dictHeaders[j]->getSize() == k)
+ {
+ j++;
+ k = 0;
+ }
+
+ headerNames[i] = dictHeaders[j]->copy(k);
+ }
+
+ for(i = 0; i < numRecords; i++)
+ delete dictHeaders[i];
+
+ delete [] dictHeaders;
+ free(dictKeys);
+ free(dictValues);
+ }
+ break;
+
+ /* Array */
+ case kABArrayProperty:
+ /* For non-scalars, we can only get more information if the property
+ * actually exists.
+ */
+ if(_propertyValue != NULL)
+ {
+ sal_Int32 arrLength = (sal_Int32) CFArrayGetCount( (CFArrayRef) _propertyValue);
+ sal_Int32 i,j,k;
+ CFTypeRef arrValue;
+ ABPropertyType arrType;
+ MacabHeader **arrHeaders = new MacabHeader *[arrLength];
+ ::rtl::OUString propertyNameString = CFStringToOUString(_propertyName);
+ ::rtl::OUString arrLabelString;
+ CFStringRef arrLabel;
+
+ length = 0;
+ /* Go through each element - since the elements here do not have
+ * unique keys like the ones in dictionaries, we create a unique
+ * key out of the id of the element in the array (the first
+ * element gets a 0 plopped onto the end of it, the second a 1...
+ * As with dictionaries, the elements could be anything, including
+ * another array, so we have to run this method recursively on
+ * each element, storing the resulting MacabHeader into an array,
+ * which we then combine into one MacabHeader that is returned.
+ */
+ for(i = 0; i < arrLength; i++)
+ {
+ arrValue = (CFTypeRef) CFArrayGetValueAtIndex( (CFArrayRef) _propertyValue, i);
+ arrType = (ABPropertyType) getABTypeFromCFType( CFGetTypeID(arrValue) );
+ arrLabelString = propertyNameString + ::rtl::OUString::valueOf(i);
+ arrLabel = OUStringToCFString(arrLabelString);
+ arrHeaders[i] = createHeaderForProperty(arrType, arrValue, arrLabel);
+ if (!arrHeaders[i])
+ arrHeaders[i] = new MacabHeader();
+ length += arrHeaders[i]->getSize();
+ CFRelease(arrLabel);
+ }
+
+ headerNames = new macabfield *[length];
+ for(i = 0, j = 0, k = 0; i < length; i++,k++)
+ {
+ while(arrHeaders[j]->getSize() == k)
+ {
+ j++;
+ k = 0;
+ }
+
+ headerNames[i] = arrHeaders[j]->copy(k);
+ }
+ for(i = 0; i < arrLength; i++)
+ delete arrHeaders[i];
+
+ delete [] arrHeaders;
+ }
+ break;
+
+ default:
+ break;
+
+ }
+
+ /* If we succeeded at adding elements to the headerNames array, then
+ * length will no longer be 0. If it is, create a new MacabHeader
+ * out of the headerNames (after weeding out duplicate headers), and
+ * then return the result. If the length is still 0, return NULL: we
+ * failed to create a MacabHeader out of this property.
+ */
+ if(length != 0)
+ {
+ manageDuplicateHeaders(headerNames, length);
+ MacabHeader *headerResult = new MacabHeader(length, headerNames);
+ delete [] headerNames;
+ return headerResult;
+ }
+ else
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) const
+{
+ /* If we have two cases of, say, phone: home, this makes it:
+ * phone: home (1)
+ * phone: home (2)
+ */
+ sal_Int32 i, j;
+ sal_Int32 count;
+ for(i = _length-1; i >= 0; i--)
+ {
+ count = 1;
+ for( j = i-1; j >= 0; j--)
+ {
+ if(CFEqual(_headerNames[i]->value, _headerNames[j]->value))
+ {
+ count++;
+ }
+ }
+
+ // duplicate!
+ if(count != 1)
+ {
+ // There is probably a better way to do this...
+ ::rtl::OUString newName = CFStringToOUString((CFStringRef) _headerNames[i]->value);
+ CFRelease(_headerNames[i]->value);
+ newName += ::rtl::OUString::createFromAscii(" (") + ::rtl::OUString::valueOf(count) + ::rtl::OUString::createFromAscii(")");
+ _headerNames[i]->value = OUStringToCFString(newName);
+ }
+ }
+}
+
+// -------------------------------------------------------------------------
+/* Create a MacabRecord out of an ABRecord, using a given MacabHeader and
+ * the record's type. We go through each property for this record type
+ * then process it much like we processed the header (above), with two
+ * exceptions: if we come upon something not in the header, we ignore it
+ * (it's something we don't want to add), and once we find a corresponding
+ * location in the header, we store the property and the property type in
+ * a macabfield. (For the header, we stored the property type and the name
+ * of the property as a CFString.)
+ */
+MacabRecord *MacabRecords::createMacabRecord(const ABRecordRef _abrecord, const MacabHeader *_header, const CFStringRef _recordType) const
+{
+ /* The new record that we will create... */
+ MacabRecord *macabRecord = new MacabRecord(_header->getSize());
+
+ CFArrayRef recordProperties = ABCopyArrayOfPropertiesForRecordType(addressBook, _recordType);
+ sal_Int32 numProperties = (sal_Int32) CFArrayGetCount(recordProperties);
+
+ sal_Int32 i;
+
+ CFTypeRef propertyValue;
+ ABPropertyType propertyType;
+
+ CFStringRef propertyName, localizedPropertyName;
+ ::rtl::OUString propertyNameString;
+ for(i = 0; i < numProperties; i++)
+ {
+ propertyName = (CFStringRef) CFArrayGetValueAtIndex(recordProperties, i);
+ localizedPropertyName = ABCopyLocalizedPropertyOrLabel(propertyName);
+ propertyNameString = CFStringToOUString(localizedPropertyName);
+ CFRelease(localizedPropertyName);
+
+ /* Get the property's value */
+ propertyValue = ABRecordCopyValue(_abrecord,propertyName);
+ if(propertyValue != NULL)
+ {
+ propertyType = ABTypeOfProperty(addressBook, _recordType, propertyName);
+ if(propertyType != kABErrorInProperty)
+ insertPropertyIntoMacabRecord(propertyType, macabRecord, _header, propertyNameString, propertyValue);
+
+ CFRelease(propertyValue);
+ }
+ }
+ CFRelease(recordProperties);
+ return macabRecord;
+}
+
+// -------------------------------------------------------------------------
+/* Inserts a given property into a MacabRecord. This method calls another
+ * method by the same name after getting the property type (it only
+ * receives the property value). It is called when we aren't given the
+ * property's type already.
+ */
+void MacabRecords::insertPropertyIntoMacabRecord(MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const
+{
+ CFTypeID cf_type = CFGetTypeID(_propertyValue);
+ ABPropertyType ab_type = getABTypeFromCFType( cf_type );
+
+ if(ab_type != kABErrorInProperty)
+ insertPropertyIntoMacabRecord(ab_type, _abrecord, _header, _propertyName, _propertyValue);
+}
+
+// -------------------------------------------------------------------------
+/* Inserts a given property into a MacabRecord. This method is recursive
+ * because properties can contain many sub-properties.
+ */
+void MacabRecords::insertPropertyIntoMacabRecord(const ABPropertyType _propertyType, MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const
+{
+ /* If there is no value, return */
+ if(_propertyValue == NULL)
+ return;
+
+ /* The main switch statement */
+ switch(_propertyType)
+ {
+ /* Scalars */
+ case kABStringProperty:
+ case kABRealProperty:
+ case kABIntegerProperty:
+ case kABDateProperty:
+ {
+ /* Only scalars actually insert a property into the MacabRecord.
+ * In all other cases, this method is called recursively until a
+ * scalar type, an error, or an unknown type are found.
+ * Because of that, the following checks only occur for this type.
+ * We store whether we have successfully placed this property
+ * into the MacabRecord (or whether an unrecoverable error occured).
+ * Then, we try over and over again to place the property into the
+ * record. There are three possible results:
+ * 1) Success!
+ * 2) There is already a property stored at the column of this name,
+ * in which case we have a duplicate header (see the method
+ * manageDuplicateHeaders()). If that is the case, we add an ID
+ * to the end of the column name in the same format as we do in
+ * manageDuplicateHeaders() and try again.
+ * 3) No column of this name exists in the header. In this case,
+ * there is nothing we can do: we have failed to place this
+ * property into the record.
+ */
+ sal_Bool bPlaced = sal_False;
+ ::rtl::OUString columnName = ::rtl::OUString(_propertyName);
+ sal_Int32 i = 1;
+
+ // A big safeguard to prevent two fields from having the same name.
+ while(bPlaced != sal_True)
+ {
+ sal_Int32 columnNumber = _header->getColumnNumber(columnName);
+ bPlaced = sal_True;
+ if(columnNumber != -1)
+ {
+ // collision! A property already exists here!
+ if(_abrecord->get(columnNumber) != NULL)
+ {
+ bPlaced = sal_False;
+ i++;
+ columnName = ::rtl::OUString(_propertyName) + ::rtl::OUString::createFromAscii(" (") + ::rtl::OUString::valueOf(i) + ::rtl::OUString::createFromAscii(")");
+ }
+
+ // success!
+ else
+ {
+ _abrecord->insertAtColumn(_propertyValue, _propertyType, columnNumber);
+ }
+ }
+ }
+ }
+ break;
+
+ /* Array */
+ case kABArrayProperty:
+ {
+ /* An array is basically just a list of anything, so all we do
+ * is go through the array, and rerun this method recursively
+ * on each element.
+ */
+ sal_Int32 arrLength = (sal_Int32) CFArrayGetCount( (CFArrayRef) _propertyValue);
+ sal_Int32 i;
+ const void *arrValue;
+ ::rtl::OUString newPropertyName;
+
+ /* Going through each element... */
+ for(i = 0; i < arrLength; i++)
+ {
+ arrValue = CFArrayGetValueAtIndex( (CFArrayRef) _propertyValue, i);
+ newPropertyName = _propertyName + ::rtl::OUString::valueOf(i);
+ insertPropertyIntoMacabRecord(_abrecord, _header, newPropertyName, arrValue);
+ CFRelease(arrValue);
+ }
+
+ }
+ break;
+
+ /* Dictionary */
+ case kABDictionaryProperty:
+ {
+ /* A dictionary is basically a hashmap. Technically, it can
+ * hold any object as a key and any object as a value.
+ * For our case, we assume that the key is a string (so that
+ * we can use the key to get the column name and match it against
+ * the header), but we don't assume anything about the value, so
+ * we run this method recursively (or, rather, we run the version
+ * of this method for when we don't know the object's type) until
+ * we hit a scalar value.
+ */
+
+ sal_Int32 numRecords = (sal_Int32) CFDictionaryGetCount((CFDictionaryRef) _propertyValue);
+ ::rtl::OUString dictKeyString;
+ sal_Int32 i;
+ ::rtl::OUString newPropertyName;
+
+ /* Unfortunately, the only way to get both keys and values out
+ * of a dictionary in Carbon is to get them all at once, so we
+ * do that.
+ */
+ CFStringRef *dictKeys;
+ CFStringRef localizedDictKey;
+ CFTypeRef *dictValues;
+ dictKeys = (CFStringRef *) malloc(sizeof(CFStringRef)*numRecords);
+ dictValues = (CFTypeRef *) malloc(sizeof(CFTypeRef)*numRecords);
+ CFDictionaryGetKeysAndValues((CFDictionaryRef) _propertyValue, (const void **) dictKeys, (const void **) dictValues);
+
+ /* Going through each element... */
+ for(i = 0; i < numRecords; i++)
+ {
+ localizedDictKey = ABCopyLocalizedPropertyOrLabel(dictKeys[i]);
+ dictKeyString = CFStringToOUString(localizedDictKey);
+ CFRelease(localizedDictKey);
+ newPropertyName = _propertyName + ::rtl::OUString::createFromAscii(": ") + fixLabel(dictKeyString);
+ insertPropertyIntoMacabRecord(_abrecord, _header, newPropertyName, dictValues[i]);
+ }
+
+ free(dictKeys);
+ free(dictValues);
+ }
+ break;
+
+ /* Multivalue */
+ case kABMultiIntegerProperty:
+ case kABMultiDateProperty:
+ case kABMultiStringProperty:
+ case kABMultiRealProperty:
+ case kABMultiDataProperty:
+ case kABMultiDictionaryProperty:
+ case kABMultiArrayProperty:
+ {
+ /* All scalar multivalues are handled in the same way. Each element
+ * is a label and a value. All labels are strings
+ * (kABStringProperty), and all values have the same type
+ * (which is the type of the multivalue minus 255, or as
+ * Carbon's list of property types has it, minus 0x100.
+ * We just get the correct type, then go through each element
+ * and get the label and value and print them in a list.
+ */
+
+ sal_Int32 i;
+ sal_Int32 multiLength = ABMultiValueCount((ABMutableMultiValueRef) _propertyValue);
+ CFStringRef multiLabel, localizedMultiLabel;
+ CFTypeRef multiValue;
+ ::rtl::OUString multiLabelString, newPropertyName;
+ ABPropertyType multiType = (ABPropertyType) (ABMultiValuePropertyType((ABMutableMultiValueRef) _propertyValue) - 0x100);
+
+ /* Go through each element... */
+ for(i = 0; i < multiLength; i++)
+ {
+ /* Label and value */
+ multiLabel = ABMultiValueCopyLabelAtIndex((ABMutableMultiValueRef) _propertyValue, i);
+ multiValue = ABMultiValueCopyValueAtIndex((ABMutableMultiValueRef) _propertyValue, i);
+
+ localizedMultiLabel = ABCopyLocalizedPropertyOrLabel(multiLabel);
+ multiLabelString = CFStringToOUString(localizedMultiLabel);
+ newPropertyName = _propertyName + ::rtl::OUString::createFromAscii(": ") + fixLabel(multiLabelString);
+ insertPropertyIntoMacabRecord(multiType, _abrecord, _header, newPropertyName, multiValue);
+
+ /* free our variables */
+ CFRelease(multiLabel);
+ CFRelease(localizedMultiLabel);
+ CFRelease(multiValue);
+ }
+ }
+ break;
+
+ /* Unhandled types */
+ case kABErrorInProperty:
+ case kABDataProperty:
+ default:
+ /* An error, as far as I have seen, only shows up as a type
+ * returned by a function for dictionaries when the dictionary
+ * holds many types of values. Since we do not use that function,
+ * it shouldn't come up. I have yet to see the kABDataProperty,
+ * and I am not sure how to represent it as a string anyway,
+ * since it appears to just be a bunch of bytes. Assumably, if
+ * these bytes made up a string, the type would be
+ * kABStringProperty. I think that this is used when we are not
+ * sure what the type is (e.g., it could be a string or a number).
+ * That being the case, I still don't know how to represent it.
+ * And, default should never come up, since we've exhausted all
+ * of the possible types for ABPropertyType, but... just in case.
+ */
+ break;
+ }
+
+}
+
+// -------------------------------------------------------------------------
+ABPropertyType MacabRecords::getABTypeFromCFType(const CFTypeID cf_type ) const
+{
+ sal_Int32 i;
+ for(i = 0; i < lcl_CFTypesLength; i++)
+ {
+ /* A match! */
+ if(lcl_CFTypes[i].cf == (sal_Int32) cf_type)
+ {
+ return (ABPropertyType) lcl_CFTypes[i].ab;
+ }
+ }
+ return kABErrorInProperty;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabRecords::size() const
+{
+ return currentRecord;
+}
+
+// -------------------------------------------------------------------------
+MacabRecords *MacabRecords::begin()
+{
+ return this;
+}
+
+// -------------------------------------------------------------------------
+MacabRecords::iterator::iterator ()
+{
+}
+
+// -------------------------------------------------------------------------
+MacabRecords::iterator::~iterator ()
+{
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::iterator::operator= (MacabRecords *_records)
+{
+ id = 0;
+ records = _records;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::iterator::operator++ ()
+{
+ id++;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabRecords::iterator::operator!= (const sal_Int32 i) const
+{
+ return(id != i);
+}
+
+// -------------------------------------------------------------------------
+sal_Bool MacabRecords::iterator::operator== (const sal_Int32 i) const
+{
+ return(id == i);
+}
+
+// -------------------------------------------------------------------------
+MacabRecord *MacabRecords::iterator::operator* () const
+{
+ return records->getRecord(id);
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MacabRecords::end() const
+{
+ return currentRecord;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::swap(const sal_Int32 _id1, const sal_Int32 _id2)
+{
+ MacabRecord *swapRecord = records[_id1];
+
+ records[_id1] = records[_id2];
+ records[_id2] = swapRecord;
+}
+
+// -------------------------------------------------------------------------
+void MacabRecords::setName(const ::rtl::OUString _sName)
+{
+ m_sName = _sName;
+}
+
+// -------------------------------------------------------------------------
+::rtl::OUString MacabRecords::getName() const
+{
+ return m_sName;
+}
+
diff --git a/connectivity/source/drivers/macab/MacabRecords.hxx b/connectivity/source/drivers/macab/MacabRecords.hxx
new file mode 100755
index 000000000000..239a9c448c99
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabRecords.hxx
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_RECORDS_HXX_
+#define _CONNECTIVITY_MACAB_RECORDS_HXX_
+
+#include "MacabRecord.hxx"
+#include "MacabHeader.hxx"
+
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+#include <com/sun/star/util/DateTime.hpp>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ /* This struct is for converting CF types to AB types (Core Foundation
+ * types to Address Book types).
+ */
+ struct lcl_CFType {
+ sal_Int32 cf;
+ sal_Int32 ab;
+ };
+
+ class MacabRecords{
+ protected:
+ /* MacabRecords is, at its core, a table of macabfields, in the
+ * form of a header and a list of objects of type MacabRecord.
+ * It also has a unique name that refers to the name of the table.
+ */
+ sal_Int32 recordsSize;
+ sal_Int32 currentRecord;
+ CFStringRef recordType;
+ MacabHeader *header;
+ MacabRecord **records;
+ ABAddressBookRef addressBook;
+ ::rtl::OUString m_sName;
+
+ /* For converting CF types to AB types */
+ sal_Int32 lcl_CFTypesLength;
+ lcl_CFType *lcl_CFTypes;
+
+ /* For required properties */
+ CFStringRef *requiredProperties;
+ sal_Int32 numRequiredProperties;
+
+ private:
+ /* All of the private methods are for creating a MacabHeader or a
+ * MacabRecord. They are used by the initialize method that goes
+ * about filling a MacabRecords using all of the records in the
+ * Mac OS X Address Book.
+ */
+ void bootstrap_CF_types();
+ void bootstrap_requiredProperties();
+ MacabHeader *createHeaderForProperty(const ABRecordRef _record, const CFStringRef _propertyName, const CFStringRef _recordType, const sal_Bool _isPropertyRequired) const;
+ MacabHeader *createHeaderForProperty(const ABPropertyType _propertyType, const CFTypeRef _propertyValue, const CFStringRef _propertyName) const;
+ void manageDuplicateHeaders(macabfield **_headerNames, const sal_Int32 _length) const;
+ ABPropertyType getABTypeFromCFType(const CFTypeID cf_type ) const;
+ void insertPropertyIntoMacabRecord(MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const;
+ void insertPropertyIntoMacabRecord(const ABPropertyType _propertyType, MacabRecord *_abrecord, const MacabHeader *_header, const ::rtl::OUString _propertyName, const CFTypeRef _propertyValue) const;
+ public:
+ MacabRecords(const ABAddressBookRef _addressBook, MacabHeader *_header, MacabRecord **_records, sal_Int32 _numRecords);
+ MacabRecords(const MacabRecords *_copy);
+ MacabRecords(const ABAddressBookRef _addressBook);
+ ~MacabRecords();
+
+ void initialize();
+
+ void setHeader(MacabHeader *_header);
+ MacabHeader *getHeader() const;
+
+ void setName(const ::rtl::OUString _sName);
+ ::rtl::OUString getName() const;
+
+ MacabRecord *insertRecord(MacabRecord *_newRecord, const sal_Int32 _location);
+ void insertRecord(MacabRecord *_newRecord);
+ MacabRecord *getRecord(const sal_Int32 _location) const;
+ void swap(const sal_Int32 _id1, const sal_Int32 _id2);
+
+ macabfield *getField(const sal_Int32 _recordNumber, const sal_Int32 _columnNumber) const;
+ macabfield *getField(const sal_Int32 _recordNumber, const ::rtl::OUString _columnName) const;
+ sal_Int32 getFieldNumber(const ::rtl::OUString _columnName) const;
+
+ sal_Int32 size() const;
+
+ MacabHeader *createHeaderForRecordType(const CFArrayRef _records, const CFStringRef _recordType) const;
+ MacabRecord *createMacabRecord(const ABRecordRef _abrecord, const MacabHeader *_header, const CFStringRef _recordType) const;
+
+ MacabRecords *begin();
+ sal_Int32 end() const;
+ class iterator{
+ protected:
+ MacabRecords *records;
+ public:
+ sal_Int32 id;
+ void operator= (MacabRecords *_records);
+ iterator();
+ ~iterator();
+ void operator++ ();
+ sal_Bool operator!= (const sal_Int32 i) const;
+ sal_Bool operator== (const sal_Int32 i) const;
+ MacabRecord *operator* () const;
+ };
+
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_RECORDS_HXX_
diff --git a/connectivity/source/drivers/macab/MacabResultSet.cxx b/connectivity/source/drivers/macab/MacabResultSet.cxx
new file mode 100755
index 000000000000..f9492b5d4efc
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabResultSet.cxx
@@ -0,0 +1,1073 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabResultSet.hxx"
+#include "MacabAddressBook.hxx"
+#include "MacabRecords.hxx"
+#include "macabutilities.hxx"
+#include "MacabResultSetMetaData.hxx"
+#include "MacabConnection.hxx"
+#include "macabcondition.hxx"
+#include "macaborder.hxx"
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include "TConnection.hxx"
+#include <connectivity/dbexception.hxx>
+#include "resource/sharedresources.hxx"
+#include "resource/macab_res.hrc"
+
+using namespace connectivity::macab;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(MacabResultSet, "com.sun.star.sdbc.drivers.MacabResultSet", "com.sun.star.sdbc.ResultSet");
+// -------------------------------------------------------------------------
+MacabResultSet::MacabResultSet(MacabCommonStatement* pStmt)
+ : MacabResultSet_BASE(m_aMutex),
+ OPropertySetHelper(MacabResultSet_BASE::rBHelper),
+ m_xStatement(pStmt),
+ m_xMetaData(NULL),
+ m_aMacabRecords(),
+ m_nRowPos(-1),
+ m_bWasNull(sal_True)
+{
+ m_sTableName = MacabAddressBook::getDefaultTableName();
+}
+// -------------------------------------------------------------------------
+MacabResultSet::~MacabResultSet()
+{
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::allMacabRecords()
+{
+ MacabConnection* pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get());
+
+ m_aMacabRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::someMacabRecords(const MacabCondition *pCondition)
+{
+ MacabConnection* pConnection = static_cast< MacabConnection *>(m_xStatement->getConnection().get());
+ MacabRecords* allRecords;
+
+ allRecords = pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // Bad table!! Throw exception?
+ if(allRecords == NULL)
+ return;
+
+ if(m_aMacabRecords != NULL && m_aMacabRecords != allRecords)
+ delete m_aMacabRecords;
+
+ // The copy constructor copies everything but records (including the
+ // maximum alloted size, which means that we'll never have to resize)
+ m_aMacabRecords = new MacabRecords(allRecords);
+
+ MacabRecords::iterator iterator;
+
+ for (iterator = allRecords->begin();
+ iterator != allRecords->end();
+ ++iterator)
+ {
+ if (pCondition->eval(*iterator))
+ m_aMacabRecords->insertRecord(*iterator);
+ }
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::sortMacabRecords(const MacabOrder *pOrder)
+{
+ // I do this with ints rather than an iterator because the ids will
+ // be changing when we change the order and ints are easier to deal
+ // with (for me).
+ sal_Int32 i, j, size, smallest;
+ size = m_aMacabRecords->size();
+
+ for(i = 0; i < size; i++)
+ {
+ smallest = i;
+ for( j = i + 1; j < size; j++)
+ {
+ // if smallest > j
+ if(pOrder->compare(m_aMacabRecords->getRecord(smallest),
+ m_aMacabRecords->getRecord(j) ) > 0)
+ {
+ smallest = j;
+ }
+
+ }
+
+ if(smallest != i)
+ {
+ m_aMacabRecords->swap(i,smallest);
+ }
+ }
+
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::setTableName(::rtl::OUString _sTableName)
+{
+ m_sTableName = _sTableName;
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::disposing()
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+m_xStatement.clear();
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL MacabResultSet::queryInterface(const Type & rType) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if (!aRet.hasValue())
+ aRet = MacabResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::acquire() throw()
+{
+ MacabResultSet_BASE::acquire();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::release() throw()
+{
+ MacabResultSet_BASE::release();
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL MacabResultSet::getTypes() throw(RuntimeException)
+{
+ OTypeCollection aTypes(
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet >*) 0),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet >*) 0),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet >*) 0));
+
+ return comphelper::concatSequences(aTypes.getTypes(), MacabResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL MacabResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSet::findColumn(const ::rtl::OUString& columnName) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // find the first column with the name columnName
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+
+ for (sal_Int32 i = 1; i <= nLen; ++i)
+ if (xMeta->isCaseSensitive(i) ?
+ columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ return i;
+
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_NO_ELEMENT_NAME,
+ "$name$", columnName
+ ) );
+ ::dbtools::throwGenericSQLException(sError , *this);
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSet::getString(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString aRet;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABStringProperty)
+ {
+ aRet = CFStringToOUString( (CFStringRef) aField->value);
+ m_bWasNull = false;
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return aRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::getBoolean(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBoolean", NULL);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int8 SAL_CALL MacabResultSet::getByte(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getByte", NULL);
+
+ sal_Int8 nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int16 SAL_CALL MacabResultSet::getShort(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getShort", NULL);
+
+ sal_Int16 nRet = 0;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSet::getInt(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRet = 0;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABIntegerProperty)
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) aField->value );
+ // m_bWasNull now becomes whether getting the value was successful
+ // Should we check for the wrong type here, e.g., a float or a 64 bit int?
+ m_bWasNull = !CFNumberGetValue((CFNumberRef) aField->value, numberType, &nRet);
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return nRet;
+}
+// -------------------------------------------------------------------------
+sal_Int64 SAL_CALL MacabResultSet::getLong(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int64 nRet = 0;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABIntegerProperty)
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) aField->value );
+ // m_bWasNull now becomes whether getting the value was successful
+ // Should we check for the wrong type here, e.g., a float or a 32 bit int?
+ m_bWasNull = !CFNumberGetValue((CFNumberRef) aField->value, numberType, &nRet);
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return nRet;
+}
+// -------------------------------------------------------------------------
+float SAL_CALL MacabResultSet::getFloat(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ float nVal = 0;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABRealProperty)
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) aField->value );
+ // m_bWasNull now becomes whether getting the value was successful
+ // Should we check for the wrong type here, e.g., an int or a double?
+ m_bWasNull = !CFNumberGetValue((CFNumberRef) aField->value, numberType, &nVal);
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return nVal;
+}
+// -------------------------------------------------------------------------
+double SAL_CALL MacabResultSet::getDouble(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ double nVal = 0;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABRealProperty)
+ {
+ CFNumberType numberType = CFNumberGetType( (CFNumberRef) aField->value );
+ // m_bWasNull now becomes whether getting the value was successful
+ // Should we check for the wrong type here, e.g., an int or a float?
+ m_bWasNull = !CFNumberGetValue((CFNumberRef) aField->value, numberType, &nVal);
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return nVal;
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int8 > SAL_CALL MacabResultSet::getBytes(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBytes", NULL);
+
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+Date SAL_CALL MacabResultSet::getDate(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getDate", NULL);
+
+ Date aRet;
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Time SAL_CALL MacabResultSet::getTime(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getTime", NULL);
+
+ Time nRet;
+ return nRet;
+}
+// -------------------------------------------------------------------------
+DateTime SAL_CALL MacabResultSet::getTimestamp(sal_Int32 columnIndex) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ DateTime nRet;
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_bWasNull = true;
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords && m_xMetaData.is())
+ {
+ sal_Int32 nFieldNumber = m_xMetaData->fieldAtColumn(columnIndex);
+ macabfield *aField = m_aMacabRecords->getField(m_nRowPos,nFieldNumber);
+ if(aField != NULL)
+ {
+ if(aField->type == kABDateProperty)
+ {
+ nRet = CFDateToDateTime((CFDateRef) aField->value);
+ m_bWasNull = false;
+ }
+ }
+ }
+
+// Trigger an exception if m_bWasNull is true?
+ return nRet;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL MacabResultSet::getBinaryStream(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBinaryStream", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL MacabResultSet::getCharacterStream(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getCharacterStream", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL MacabResultSet::getObject(sal_Int32, const Reference< ::com::sun::star::container::XNameAccess >&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getObject", NULL);
+
+ return Any();
+}
+// -------------------------------------------------------------------------
+Reference< XRef > SAL_CALL MacabResultSet::getRef(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getRef", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL MacabResultSet::getBlob(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getBlob", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL MacabResultSet::getClob(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getClob", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL MacabResultSet::getArray(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+::dbtools::throwFunctionNotSupportedException("getArray", NULL);
+
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSetMetaData > SAL_CALL MacabResultSet::getMetaData() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ if (!m_xMetaData.is())
+ m_xMetaData = new MacabResultSetMetaData(m_xStatement->getOwnConnection(), m_sTableName);
+
+ Reference< XResultSetMetaData > xMetaData = m_xMetaData.get();
+ return xMetaData;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::isBeforeFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ if (m_nRowPos == -1)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::isAfterLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ if (m_nRowPos == nRecords)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::isFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ if (m_nRowPos == 0)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::isLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ if (m_nRowPos == nRecords - 1)
+ return sal_True;
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::beforeFirst() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // move before the first row
+ m_nRowPos = -1;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::afterLast() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // move after the last row
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ m_nRowPos = nRecords;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::close() throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::first() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ if (nRecords == 0)
+ return sal_False;
+
+ m_nRowPos = 0;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::last() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ if (nRecords == 0)
+ return sal_False;
+
+ m_nRowPos = nRecords - 1;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSet::getRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nRowPos;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::absolute(sal_Int32 row) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+ if (row <= -1 ||
+ row >= nRecords)
+ return sal_False;
+
+ m_nRowPos = row;
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos + row);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::next() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos + 1);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::previous() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return absolute(m_nRowPos - 1);
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL MacabResultSet::getStatement() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ Reference< XStatement > xStatement = m_xStatement.get();
+ return xStatement;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::rowDeleted() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::rowInserted() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::rowUpdated() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::wasNull() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::cancel() throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::clearWarnings() throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL MacabResultSet::getWarnings() throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::insertRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // you only have to implement this if you want to insert new rows
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // only when you allow updates
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::deleteRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::cancelRowUpdates() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::moveToInsertRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ // only when you allow inserts
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::moveToCurrentRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateNull(sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateBoolean(sal_Int32, sal_Bool) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateByte(sal_Int32, sal_Int8) throw(SQLException, RuntimeException)
+{
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateShort(sal_Int32, sal_Int16) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateInt(sal_Int32, sal_Int32) throw(SQLException, RuntimeException)
+{
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateLong(sal_Int32, sal_Int64) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -----------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateFloat(sal_Int32, float) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateDouble(sal_Int32, double) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateString(sal_Int32, const ::rtl::OUString&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateBytes(sal_Int32, const Sequence< sal_Int8 >&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateDate(sal_Int32, const Date&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateTime(sal_Int32, const Time&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateTimestamp(sal_Int32, const DateTime&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateBinaryStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateCharacterStream(sal_Int32, const Reference< XInputStream >&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::refreshRow() throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateObject(sal_Int32, const Any&) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabResultSet::updateNumericObject(sal_Int32, const Any&, sal_Int32) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+}
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL MacabResultSet::getBookmark() throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRecords = m_aMacabRecords->size();
+
+ if (m_nRowPos != -1 && m_nRowPos != nRecords)
+ {
+ macabfield *uidField = m_aMacabRecords->getField(m_nRowPos,::rtl::OUString::createFromAscii("UID"));
+ if(uidField != NULL)
+ {
+ if(uidField->type == kABStringProperty)
+ {
+ return makeAny(CFStringToOUString( (CFStringRef) uidField->value ));
+ }
+ }
+ }
+ return Any();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::moveToBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sBookmark = comphelper::getString(bookmark);
+ sal_Int32 nRecords = m_aMacabRecords->size();
+
+ for (sal_Int32 nRow = 0; nRow < nRecords; nRow++)
+ {
+ macabfield *uidField = m_aMacabRecords->getField(m_nRowPos,::rtl::OUString::createFromAscii("UID"));
+ if(uidField != NULL)
+ {
+ if(uidField->type == kABStringProperty)
+ {
+ ::rtl::OUString sUniqueIdentifier = CFStringToOUString( (CFStringRef) uidField->value );
+ if (sUniqueIdentifier == sBookmark)
+ {
+ m_nRowPos = nRow;
+ return sal_True;
+ }
+ }
+ }
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::moveRelativeToBookmark(const Any& bookmark, sal_Int32 rows) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Int32 nRowSave = m_nRowPos;
+
+ if (moveToBookmark(bookmark))
+ {
+ sal_Int32 nRecords = m_aMacabRecords->size();
+
+ m_nRowPos += rows;
+
+ if (-1 < m_nRowPos && m_nRowPos < nRecords)
+ return sal_True;
+ }
+
+ m_nRowPos = nRowSave;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSet::compareBookmarks(const Any& firstItem, const Any& secondItem) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sFirst = comphelper::getString(firstItem);
+ ::rtl::OUString sSecond = comphelper::getString(secondItem);
+
+ if (sFirst < sSecond)
+ return CompareBookmark::LESS;
+ if (sFirst > sSecond)
+ return CompareBookmark::GREATER;
+ return CompareBookmark::EQUAL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSet::hasOrderedBookmarks() throw( SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSet::hashBookmark(const Any& bookmark) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ ::rtl::OUString sBookmark = comphelper::getString(bookmark);
+
+ return sBookmark.hashCode();
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL MacabResultSet::deleteRows(const Sequence< Any >&) throw( SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabResultSet_BASE::rBHelper.bDisposed);
+
+ return Sequence< sal_Int32 >();
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* MacabResultSet::createArrayHelper() const
+{
+ Sequence< Property > aProps(6);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & MacabResultSet::getInfoHelper()
+{
+ return *static_cast<MacabResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool MacabResultSet::convertFastPropertyValue(
+ Any &,
+ Any &,
+ sal_Int32 nHandle,
+ const Any& )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& )
+ throw (Exception)
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void MacabResultSet::getFastPropertyValue(
+ Any& _rValue,
+ sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ _rValue <<= (sal_Bool)sal_False;
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ ;
+ }
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/macab/MacabResultSet.hxx b/connectivity/source/drivers/macab/MacabResultSet.hxx
new file mode 100755
index 000000000000..4daa66699998
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabResultSet.hxx
@@ -0,0 +1,226 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_RESULTSET_HXX_
+#define _CONNECTIVITY_MACAB_RESULTSET_HXX_
+
+#include "MacabStatement.hxx"
+#include "MacabResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <cppuhelper/compbase12.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ /*
+ ** MacabResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::lang::XServiceInfo> MacabResultSet_BASE;
+ class MacabRecords;
+
+ class MacabResultSet : public comphelper::OBaseMutex,
+ public MacabResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public comphelper::OPropertyArrayUsageHelper<MacabResultSet>
+ {
+ protected:
+ ::rtl::Reference< MacabCommonStatement > m_xStatement; // the statement that has created this result set
+ ::rtl::Reference< MacabResultSetMetaData > m_xMetaData; // the description of the columns in this result set
+ MacabRecords * m_aMacabRecords; // address book entries matching the query
+ sal_Int32 m_nRowPos; // the current row within the result set
+ sal_Bool m_bWasNull; // last entry retrieved from this result set was NULL
+ ::rtl::OUString m_sTableName;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+
+ // you can't delete objects of this type
+ virtual ~MacabResultSet();
+
+ public:
+ DECLARE_SERVICE_INFO();
+
+ MacabResultSet(MacabCommonStatement *pStmt);
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(MacabResultSet_BASE*) this);
+ }
+
+ void allMacabRecords();
+ void someMacabRecords(const class MacabCondition *pCondition);
+ void sortMacabRecords(const class MacabOrder *pOrder);
+ void setTableName(const ::rtl::OUString _sTableName);
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XResultSet
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& firstItem, const ::com::sun::star::uno::Any& secondItem ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_RESULTSET_HXX_
diff --git a/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
new file mode 100755
index 000000000000..8d50446f02a7
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabResultSetMetaData.cxx
@@ -0,0 +1,224 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabResultSetMetaData.hxx"
+#include "MacabHeader.hxx"
+#include "MacabRecords.hxx"
+#include "MacabAddressBook.hxx"
+#include "macabutilities.hxx"
+#include "resource/macab_res.hrc"
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+MacabResultSetMetaData::MacabResultSetMetaData(MacabConnection* _pConnection, ::rtl::OUString _sTableName)
+ : m_pConnection(_pConnection),
+ m_sTableName(_sTableName),
+ m_aMacabFields()
+{
+}
+// -------------------------------------------------------------------------
+MacabResultSetMetaData::~MacabResultSetMetaData()
+{
+}
+// -------------------------------------------------------------------------
+void MacabResultSetMetaData::setMacabFields(const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(SQLException)
+{
+ OSQLColumns::Vector::const_iterator aIter;
+ static const ::rtl::OUString aName(::rtl::OUString::createFromAscii("Name"));
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == NULL)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+
+ for (aIter = xColumns->get().begin(); aIter != xColumns->get().end(); ++aIter)
+ {
+ ::rtl::OUString aFieldName;
+ sal_uInt32 nFieldNumber;
+
+ (*aIter)->getPropertyValue(aName) >>= aFieldName;
+ nFieldNumber = aHeader->getColumnNumber(aFieldName);
+ m_aMacabFields.push_back(nFieldNumber);
+ }
+
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnDisplaySize(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ // For now, all columns are the same size.
+ return 50;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnType(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+ macabfield *aField;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == NULL)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+ aField = aHeader->get(column-1);
+
+ if(aField == NULL)
+ {
+ ::dbtools::throwInvalidIndexException(*this,Any());
+ return -1;
+ }
+
+ return ABTypeToDataType(aField->type);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::getColumnCount() throw(SQLException, RuntimeException)
+{
+ return m_aMacabFields.size();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isCaseSensitive(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getSchemaName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnName(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ sal_uInt32 nFieldNumber = m_aMacabFields[column - 1];
+ MacabRecords *aRecords;
+ MacabHeader *aHeader;
+
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(m_sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == NULL)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+
+ aHeader = aRecords->getHeader();
+ ::rtl::OUString aName = aHeader->getString(nFieldNumber);
+
+ return aName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getTableName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return m_sTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getCatalogName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnTypeName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnLabel(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL MacabResultSetMetaData::getColumnServiceName(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isCurrency(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isAutoIncrement(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isSigned(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::getPrecision(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::getScale(sal_Int32) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabResultSetMetaData::isNullable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return (sal_Int32) sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isSearchable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isReadOnly(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isDefinitelyWritable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabResultSetMetaData::isWritable(sal_Int32) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx b/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx
new file mode 100755
index 000000000000..b79fc93a8408
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabResultSetMetaData.hxx
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_RESULTSETMETADATA_HXX_
+#define _CONNECTIVITY_MACAB_RESULTSETMETADATA_HXX_
+
+#include "MacabConnection.hxx"
+#include <connectivity/CommonTools.hxx>
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <connectivity/dbexception.hxx>
+#include <vos/ref.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ /*
+ ** MacabResultSetMetaData
+ */
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> MacabResultSetMetaData_BASE;
+
+ class MacabResultSetMetaData : public MacabResultSetMetaData_BASE
+ {
+ MacabConnection* m_pConnection;
+ ::rtl::OUString m_sTableName;
+ ::std::vector<sal_Int32> m_aMacabFields; // for each selected column, contains the number
+ // of the corresponding AddressBook field
+
+ protected:
+ virtual ~MacabResultSetMetaData();
+
+ public:
+ MacabResultSetMetaData(MacabConnection* _pConnection, ::rtl::OUString _sTableName);
+
+ // avoid ambigous cast error from the compiler
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ void setMacabFields(
+ const ::vos::ORef<connectivity::OSQLColumns> &xColumns) throw(::com::sun::star::sdbc::SQLException);
+ inline sal_uInt32 fieldAtColumn(sal_Int32 columnIndex) const
+ { return m_aMacabFields[columnIndex - 1]; }
+
+ virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_RESULTSETMETADATA_HXX_
diff --git a/connectivity/source/drivers/macab/MacabServices.cxx b/connectivity/source/drivers/macab/MacabServices.cxx
new file mode 100755
index 000000000000..b3c303324302
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabServices.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::macab;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pTemp
+ );
+
+//***************************************************************************************
+//
+// The following C Api must be provided!
+// It consists in three functions that must be exported by the module
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "MACAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment **
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void*,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ MacabDriver::getImplementationName_Static(),
+ MacabDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "MACAB::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void*)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ MacabDriver::getImplementationName_Static(),
+ MacabDriver::getSupportedServiceNames_Static(),
+ &MacabDriver::Create,
+ ::cppu::createSingleFactory)
+ ;
+
+ if (aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/macab/MacabStatement.cxx b/connectivity/source/drivers/macab/MacabStatement.cxx
new file mode 100755
index 000000000000..9960ea7a4d97
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabStatement.cxx
@@ -0,0 +1,611 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabStatement.hxx"
+#include "MacabConnection.hxx"
+#include "MacabAddressBook.hxx"
+#include "MacabDriver.hxx"
+#include "MacabResultSet.hxx"
+#include "MacabResultSetMetaData.hxx"
+#include "macabcondition.hxx"
+#include "macaborder.hxx"
+#include "TConnection.hxx"
+#include <connectivity/dbexception.hxx>
+#include "resource/sharedresources.hxx"
+#include "resource/macab_res.hrc"
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace connectivity::macab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+namespace connectivity
+{
+ namespace macab
+ {
+ void impl_throwError(sal_uInt16 _nErrorId)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(_nErrorId) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+ }
+}
+
+IMPLEMENT_SERVICE_INFO(MacabStatement, "com.sun.star.sdbc.drivers.MacabStatement", "com.sun.star.sdbc.Statement");
+//------------------------------------------------------------------------------
+MacabCommonStatement::MacabCommonStatement(MacabConnection* _pConnection )
+ : MacabCommonStatement_BASE(m_aMutex),
+ OPropertySetHelper(MacabCommonStatement_BASE::rBHelper),
+ m_aParser(_pConnection->getDriver()->getMSFactory()),
+ m_aSQLIterator(_pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ),
+ m_pParseTree(NULL),
+ m_pConnection(_pConnection),
+ rBHelper(MacabCommonStatement_BASE::rBHelper)
+{
+ m_pConnection->acquire();
+}
+// -----------------------------------------------------------------------------
+MacabCommonStatement::~MacabCommonStatement()
+{
+}
+// -----------------------------------------------------------------------------
+void MacabCommonStatement::disposing()
+{
+ MacabCommonStatement_BASE::disposing();
+}
+// -----------------------------------------------------------------------------
+void MacabCommonStatement::resetParameters() const throw(::com::sun::star::sdbc::SQLException)
+{
+ impl_throwError(STR_PARA_ONLY_PREPARED);
+}
+// -----------------------------------------------------------------------------
+void MacabCommonStatement::getNextParameter(::rtl::OUString &) const throw(::com::sun::star::sdbc::SQLException)
+{
+ impl_throwError(STR_PARA_ONLY_PREPARED);
+}
+// -----------------------------------------------------------------------------
+MacabCondition *MacabCommonStatement::analyseWhereClause(const OSQLParseNode *pParseNode) const throw(SQLException)
+{
+ if (pParseNode->count() == 3)
+ {
+ const OSQLParseNode *pLeft = pParseNode->getChild(0),
+ *pMiddle = pParseNode->getChild(1),
+ *pRight = pParseNode->getChild(2);
+
+ // WHERE ( ... ) ?
+ if (SQL_ISPUNCTUATION(pLeft, "(") && SQL_ISPUNCTUATION(pRight, ")"))
+ {
+ return analyseWhereClause(pMiddle);
+ }
+ else if (SQL_ISRULE(pParseNode, comparison_predicate))
+ {
+ if (pLeft->isToken() && pRight->isToken())
+ {
+ switch (pMiddle->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // WHERE 0 = 1
+ return new MacabConditionConstant(pLeft->getTokenValue() == pRight->getTokenValue());
+
+ case SQL_NODE_NOTEQUAL:
+ // WHERE 0 <> 1
+ // (might not be correct SQL... don't care, handling anyway)
+ return new MacabConditionConstant(pLeft->getTokenValue() != pRight->getTokenValue());
+
+ default:
+ break;
+ }
+ }
+ else if (SQL_ISRULE(pLeft, column_ref))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (pRight->isToken() || SQL_ISRULE(pRight, parameter))
+ {
+ ::rtl::OUString sMatchString;
+
+ if (pRight->isToken()) // WHERE Name = 'Doe'
+ sMatchString = pRight->getTokenValue();
+ else if (SQL_ISRULE(pRight, parameter)) // WHERE Name = ?
+ getNextParameter(sMatchString);
+
+ switch (pMiddle->getNodeType())
+ {
+ case SQL_NODE_EQUAL:
+ // WHERE Name = 'Smith'
+ return new MacabConditionEqual(m_pHeader, sColumnName, sMatchString);
+
+ case SQL_NODE_NOTEQUAL:
+ // WHERE Name <> 'Jones'
+ return new MacabConditionDifferent(m_pHeader, sColumnName, sMatchString);
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, search_condition))
+ {
+ if (SQL_ISTOKEN(pMiddle, OR))
+ {
+ // WHERE Name = 'Smith' OR Name = 'Jones'
+ return new MacabConditionOr(
+ analyseWhereClause(pLeft),
+ analyseWhereClause(pRight));
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, boolean_term))
+ {
+ if (SQL_ISTOKEN(pMiddle, AND))
+ {
+ // WHERE Name = 'Smith' AND "Given Name" = 'Peter'
+ return new MacabConditionAnd(
+ analyseWhereClause(pLeft),
+ analyseWhereClause(pRight));
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, test_for_null) || SQL_ISRULE(pParseNode, like_predicate))
+ {
+ const OSQLParseNode *pLeft = pParseNode->getChild(0);
+ const OSQLParseNode* pPart2 = pParseNode->getChild(1);
+ const OSQLParseNode *pMiddleLeft = pPart2->getChild(0),
+ *pMiddleRight = pPart2->getChild(1),
+ *pRight = pPart2->getChild(2);
+
+ if (SQL_ISRULE(pParseNode, test_for_null))
+ {
+ if (SQL_ISRULE(pLeft, column_ref) &&
+ SQL_ISTOKEN(pMiddleLeft, IS) &&
+ SQL_ISTOKEN(pRight, NULL))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (SQL_ISTOKEN(pMiddleRight, NOT))
+ {
+ // WHERE "Mobile Phone" IS NOT NULL
+ return new MacabConditionNotNull(m_pHeader, sColumnName);
+ }
+ else
+ {
+ // WHERE "Mobile Phone" IS NULL
+ return new MacabConditionNull(m_pHeader, sColumnName);
+ }
+ }
+ }
+ else if (SQL_ISRULE(pParseNode, like_predicate))
+ {
+ if (SQL_ISRULE(pLeft, column_ref))
+ {
+ ::rtl::OUString sColumnName,
+ sTableRange;
+
+ m_aSQLIterator.getColumnRange(pLeft, sColumnName, sTableRange);
+
+ if (pMiddleRight->isToken() || SQL_ISRULE(pMiddleRight, parameter))
+ {
+ ::rtl::OUString sMatchString;
+
+ if (pMiddleRight->isToken()) // WHERE Name LIKE 'Sm%'
+ sMatchString = pMiddleRight->getTokenValue();
+ else if (SQL_ISRULE(pMiddleRight, parameter)) // WHERE Name LIKE ?
+ getNextParameter(sMatchString);
+
+ return new MacabConditionSimilar(m_pHeader, sColumnName, sMatchString);
+ }
+ }
+ }
+ }
+ impl_throwError(STR_QUERY_TOO_COMPLEX);
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+// -----------------------------------------------------------------------------
+MacabOrder *MacabCommonStatement::analyseOrderByClause(const OSQLParseNode *pParseNode) const throw(SQLException)
+{
+ if (SQL_ISRULE(pParseNode, ordering_spec_commalist))
+ {
+ MacabComplexOrder *list = new MacabComplexOrder();
+ sal_uInt32 n = pParseNode->count();
+
+ // Iterate through the ordering columns
+ for (sal_uInt32 i = 0; i < n; i++)
+ {
+ list->addOrder
+ (analyseOrderByClause(pParseNode->getChild(i)));
+ }
+
+ return list;
+ }
+ else if (SQL_ISRULE(pParseNode, ordering_spec))
+ {
+ if (pParseNode->count() == 2)
+ {
+ OSQLParseNode* pColumnRef = pParseNode->getChild(0);
+ OSQLParseNode* pAscendingDescending = pParseNode->getChild(1);
+
+ if (SQL_ISRULE(pColumnRef, column_ref))
+ {
+ if (pColumnRef->count() == 3)
+ pColumnRef = pColumnRef->getChild(2);
+
+ if (pColumnRef->count() == 1)
+ {
+ ::rtl::OUString sColumnName =
+ pColumnRef->getChild(0)->getTokenValue();
+ sal_Bool bAscending =
+ SQL_ISTOKEN(pAscendingDescending, DESC)?
+ sal_False:
+ sal_True;
+
+ return new MacabSimpleOrder(m_pHeader, sColumnName, bAscending);
+ }
+ }
+ }
+ }
+ impl_throwError(STR_QUERY_TOO_COMPLEX);
+ // Unreachable:
+ OSL_ASSERT(false);
+ return 0;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString MacabCommonStatement::getTableName() const
+{
+ const OSQLTables& xTabs = m_aSQLIterator.getTables();
+
+ if( xTabs.empty() )
+ return ::rtl::OUString();
+
+ // can only deal with one table at a time
+ if(xTabs.size() > 1 || m_aSQLIterator.hasErrors() )
+ return ::rtl::OUString();
+
+ return xTabs.begin()->first;
+}
+//------------------------------------------------------------------------------
+void MacabCommonStatement::setMacabFields(MacabResultSet *pResult) const throw(SQLException)
+{
+ ::vos::ORef<connectivity::OSQLColumns> xColumns; // selected columns
+ MacabResultSetMetaData *pMeta; // meta information - holds the list of AddressBook fields
+
+ xColumns = m_aSQLIterator.getSelectColumns();
+ if (!xColumns.isValid())
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(
+ STR_INVALID_COLUMN_SELECTION
+ ) );
+ ::dbtools::throwGenericSQLException(sError,NULL);
+ }
+ pMeta = static_cast<MacabResultSetMetaData *>(pResult->getMetaData().get());
+ pMeta->setMacabFields(xColumns);
+}
+// -------------------------------------------------------------------------
+void MacabCommonStatement::selectRecords(MacabResultSet *pResult) const throw(SQLException)
+{
+ const OSQLParseNode *pParseNode;
+ MacabCondition *pCondition;
+
+ pParseNode = m_aSQLIterator.getWhereTree();
+ if (pParseNode != NULL)
+ {
+ if (SQL_ISRULE(pParseNode, where_clause))
+ {
+ // Since we don't support parameters, don't reset them. If we ever
+ // support them, uncomment this line and fix resetParameters.
+ //resetParameters();
+ pParseNode = pParseNode->getChild(1);
+ pCondition = analyseWhereClause(pParseNode);
+ if (pCondition->isAlwaysTrue())
+ pResult->allMacabRecords();
+ else if (!pCondition->isAlwaysFalse())
+ pResult->someMacabRecords(pCondition);
+ delete pCondition;
+ return;
+ }
+ }
+
+ // no WHERE clause: get all rows
+ pResult->allMacabRecords();
+}
+// -------------------------------------------------------------------------
+void MacabCommonStatement::sortRecords(MacabResultSet *pResult) const throw(SQLException)
+{
+ const OSQLParseNode *pParseNode;
+ MacabOrder *pOrder;
+
+ pParseNode = m_aSQLIterator.getOrderTree();
+ if (pParseNode != NULL)
+ {
+ if (SQL_ISRULE(pParseNode, opt_order_by_clause))
+ {
+ pParseNode = pParseNode->getChild(2);
+ pOrder = analyseOrderByClause(pParseNode);
+ pResult->sortMacabRecords(pOrder);
+ delete pOrder;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL MacabCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = MacabCommonStatement_BASE::queryInterface(rType);
+ if (!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL MacabCommonStatement::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return comphelper::concatSequences(aTypes.getTypes(),MacabCommonStatement_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabCommonStatement::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+ // cancel the current sql statement
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabCommonStatement::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL MacabCommonStatement::execute(
+ const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > xRS = executeQuery(sql);
+
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL MacabCommonStatement::executeQuery(
+ const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+OSL_TRACE("Mac OS Address book - SQL Request: %s", OUtoCStr(sql));
+
+ MacabResultSet* pResult = new MacabResultSet(this);
+ Reference< XResultSet > xRS = pResult;
+ ::rtl::OUString aErr;
+
+ m_pParseTree = m_aParser.parseTree(aErr, sql);
+ if (m_pParseTree == NULL)
+ throw SQLException(aErr, *this, aErr, 0, Any());
+
+ m_aSQLIterator.setParseTree(m_pParseTree);
+ m_aSQLIterator.traverseAll();
+ switch (m_aSQLIterator.getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ ::rtl::OUString sTableName = getTableName(); // FROM which table ?
+ if (sTableName.getLength() != 0) // a match
+ {
+ MacabRecords *aRecords;
+ aRecords = m_pConnection->getAddressBook()->getMacabRecords(sTableName);
+
+ // In case, somehow, we don't have anything with the name m_sTableName
+ if(aRecords == NULL)
+ {
+ impl_throwError(STR_NO_TABLE);
+ }
+ else
+ {
+ m_pHeader = aRecords->getHeader();
+
+ pResult->setTableName(sTableName);
+
+ setMacabFields(pResult); // SELECT which columns ?
+ selectRecords(pResult); // WHERE which condition ?
+ sortRecords(pResult); // ORDER BY which columns ?
+ }
+// To be continued: DISTINCT
+// etc...
+ }
+ }
+ break;
+
+ default:
+// To be continued: UPDATE
+// DELETE
+// etc...
+ impl_throwError(STR_QUERY_TOO_COMPLEX);
+ }
+
+ m_xResultSet = Reference<XResultSet>(pResult);
+ return xRS;
+}
+// -------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL MacabCommonStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // just return our connection here
+ return (Reference< XConnection >) m_pConnection;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL MacabCommonStatement::executeUpdate( const ::rtl::OUString& ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ // the return values gives information about how many rows are affected by executing the sql statement
+ return 0;
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL MacabCommonStatement::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL MacabCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(MacabCommonStatement_BASE::rBHelper.bDisposed);
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* MacabCommonStatement::createArrayHelper( ) const
+{
+ // this properties are defined by the service statement
+ // they must be in alphabetic order
+ Sequence< Property > aProps(10);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & MacabCommonStatement::getInfoHelper()
+{
+ return *const_cast<MacabCommonStatement*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool MacabCommonStatement::convertFastPropertyValue(
+ Any &,
+ Any &,
+ sal_Int32,
+ const Any&) throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bConverted = sal_False;
+ // here we have to try to convert
+ return bConverted;
+}
+// -------------------------------------------------------------------------
+void MacabCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any&) throw (Exception)
+{
+ // set the value to whatever is nescessary
+ switch (nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void MacabCommonStatement::getFastPropertyValue(Any&,sal_Int32 nHandle) const
+{
+ switch (nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ case PROPERTY_ID_USEBOOKMARKS:
+ default:
+ ;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL MacabCommonStatement::acquire() throw()
+{
+ MacabCommonStatement_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL MacabCommonStatement::release() throw()
+{
+ MacabCommonStatement_BASE::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL MacabCommonStatement::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+MacabStatement::MacabStatement(MacabConnection* _pConnection)
+ : MacabStatement_BASE(_pConnection)
+{
+}
diff --git a/connectivity/source/drivers/macab/MacabStatement.hxx b/connectivity/source/drivers/macab/MacabStatement.hxx
new file mode 100755
index 000000000000..b9d1fd6193d4
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabStatement.hxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_STATEMENT_HXX_
+#define _CONNECTIVITY_MACAB_STATEMENT_HXX_
+
+#include "MacabConnection.hxx"
+#include "MacabHeader.hxx"
+#include <list>
+#include "connectivity/sqliterator.hxx"
+#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
+#include "connectivity/sqlparse.hxx"
+#endif
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <cppuhelper/compbase4.hxx>
+#include <cppuhelper/implbase1.hxx>
+#include <comphelper/proparrhlp.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ typedef ::cppu::WeakComponentImplHelper4< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XCloseable> MacabCommonStatement_BASE;
+
+ //**************************************************************
+ // Class MacabCommonStatement
+ // is a base class for the normal statement and for the prepared statement
+ //**************************************************************
+ class MacabCommonStatement : public comphelper::OBaseMutex,
+ public MacabCommonStatement_BASE,
+ public ::cppu::OPropertySetHelper,
+ public comphelper::OPropertyArrayUsageHelper<MacabCommonStatement>
+
+ {
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+
+ protected:
+ ::std::list< ::rtl::OUString> m_aBatchList;
+ connectivity::OSQLParser m_aParser;
+ connectivity::OSQLParseTreeIterator m_aSQLIterator;
+ connectivity::OSQLParseNode* m_pParseTree;
+ MacabConnection* m_pConnection; // The owning Connection object
+ MacabHeader* m_pHeader; // The header of the address book on which to run queries (provided by m_pConnection)
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet> m_xResultSet; // The last ResultSet created
+
+
+ protected:
+ class MacabCondition *analyseWhereClause(
+ const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
+ class MacabOrder *analyseOrderByClause(
+ const OSQLParseNode *pParseNode) const throw(::com::sun::star::sdbc::SQLException);
+ ::rtl::OUString getTableName( ) const;
+ void setMacabFields(class MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+ void selectRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+ void sortRecords(MacabResultSet *pResult) const throw(::com::sun::star::sdbc::SQLException);
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper() const;
+
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+
+ virtual void resetParameters() const throw(::com::sun::star::sdbc::SQLException);
+ virtual void getNextParameter(::rtl::OUString &rParameter) const throw(::com::sun::star::sdbc::SQLException);
+ virtual ~MacabCommonStatement();
+
+ public:
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ MacabCommonStatement(MacabConnection *_pConnection);
+ using MacabCommonStatement_BASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing();
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(
+ const ::com::sun::star::uno::Type & rType
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute(
+ const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XCancellable
+ virtual void SAL_CALL cancel(
+ ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XCloseable
+ virtual void SAL_CALL close(
+ ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // other methods
+ inline MacabConnection* getOwnConnection() const { return m_pConnection; }
+ };
+
+ //**************************************************************
+ // Class MacabStatement
+ //**************************************************************
+ typedef ::cppu::ImplInheritanceHelper1<
+ MacabCommonStatement, ::com::sun::star::lang::XServiceInfo > MacabStatement_BASE;
+
+ class MacabStatement : public MacabStatement_BASE
+ {
+ protected:
+ virtual ~MacabStatement() { }
+
+ public:
+ MacabStatement(MacabConnection* _pConnection);
+ DECLARE_SERVICE_INFO();
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_STATEMENT_HXX_
diff --git a/connectivity/source/drivers/macab/MacabTable.cxx b/connectivity/source/drivers/macab/MacabTable.cxx
new file mode 100755
index 000000000000..0bf6f1435075
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabTable.cxx
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabTable.hxx"
+#include "MacabTables.hxx"
+#include "MacabColumns.hxx"
+#include "MacabCatalog.hxx"
+
+using namespace connectivity::macab;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+// -------------------------------------------------------------------------
+MacabTable::MacabTable( sdbcx::OCollection* _pTables, MacabConnection* _pConnection)
+ : MacabTable_TYPEDEF(_pTables, sal_True),
+ m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+MacabTable::MacabTable( sdbcx::OCollection* _pTables,
+ MacabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName
+ ) : MacabTable_TYPEDEF(_pTables,sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName),
+ m_pConnection(_pConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void MacabTable::refreshColumns()
+{
+ TStringVector aVector;
+
+ if (!isNew())
+ {
+ Reference< XResultSet > xResult = m_pConnection->getMetaData()->getColumns(
+ Any(),
+ m_SchemaName,
+ m_Name,
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
+
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult, UNO_QUERY);
+ while (xResult->next())
+ aVector.push_back(xRow->getString(4));
+ }
+ }
+
+ if (m_pColumns)
+ m_pColumns->reFill(aVector);
+ else
+ m_pColumns = new MacabColumns(this,m_aMutex,aVector);
+}
diff --git a/connectivity/source/drivers/macab/MacabTable.hxx b/connectivity/source/drivers/macab/MacabTable.hxx
new file mode 100755
index 000000000000..0458c672e050
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabTable.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_TABLE_HXX_
+#define _CONNECTIVITY_MACAB_TABLE_HXX_
+
+#include "MacabConnection.hxx"
+#include "connectivity/sdbcx/VTable.hxx"
+
+namespace connectivity
+{
+ namespace macab
+ {
+ typedef connectivity::sdbcx::OTable MacabTable_TYPEDEF;
+
+ ::rtl::OUString getTypeString(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xColProp);
+
+ class MacabTable : public MacabTable_TYPEDEF
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ MacabConnection* m_pConnection;
+
+ public:
+ MacabTable( sdbcx::OCollection* _pTables, MacabConnection* _pConnection);
+ MacabTable( sdbcx::OCollection* _pTables,
+ MacabConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description = ::rtl::OUString(),
+ const ::rtl::OUString& _SchemaName = ::rtl::OUString(),
+ const ::rtl::OUString& _CatalogName = ::rtl::OUString()
+ );
+
+ MacabConnection* getConnection() { return m_pConnection;}
+
+ virtual void refreshColumns();
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_TABLE_HXX_
diff --git a/connectivity/source/drivers/macab/MacabTables.cxx b/connectivity/source/drivers/macab/MacabTables.cxx
new file mode 100755
index 000000000000..5f60109fcd21
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabTables.cxx
@@ -0,0 +1,90 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MacabTables.hxx"
+#include "MacabTable.hxx"
+#include "MacabCatalog.hxx"
+#include "MacabConnection.hxx"
+#include <comphelper/types.hxx>
+
+using namespace connectivity::macab;
+using namespace connectivity;
+using namespace ::comphelper;
+using namespace ::cppu;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+sdbcx::ObjectType MacabTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ aName = _rName;
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ ::rtl::OUString sEmpty;
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(), aSchema, aName, aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if (xResult.is())
+ {
+ Reference< XRow > xRow(xResult, UNO_QUERY);
+ if (xResult->next()) // there can be only one table with this name
+ {
+ MacabTable* pRet = new MacabTable(
+ this,
+ static_cast<MacabCatalog&>(m_rParent).getConnection(),
+ aName,
+ xRow->getString(4),
+ xRow->getString(5),
+ sEmpty);
+ xRet = pRet;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void MacabTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<MacabCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void MacabTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
diff --git a/connectivity/source/drivers/macab/MacabTables.hxx b/connectivity/source/drivers/macab/MacabTables.hxx
new file mode 100755
index 000000000000..5f2f1af29405
--- /dev/null
+++ b/connectivity/source/drivers/macab/MacabTables.hxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_TABLES_HXX_
+#define _CONNECTIVITY_MACAB_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+
+ public:
+ MacabTables(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,
+ ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector)
+ : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector),
+ m_xMetaData(_rMetaData)
+ { }
+
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_TABLES_HXX_
diff --git a/connectivity/source/drivers/macab/exports.dxp b/connectivity/source/drivers/macab/exports.dxp
new file mode 100755
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/macab/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/macab/macab.xcu b/connectivity/source/drivers/macab/macab.xcu
new file mode 100755
index 000000000000..0845bc9a2ce2
--- /dev/null
+++ b/connectivity/source/drivers/macab/macab.xcu
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:macab" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.macab.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Mac OS X Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/macab/macab.xml b/connectivity/source/drivers/macab/macab.xml
new file mode 100755
index 000000000000..d0d9ce01235b
--- /dev/null
+++ b/connectivity/source/drivers/macab/macab.xml
@@ -0,0 +1,79 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> macab1 </module-name>
+ <component-description>
+ <Author>Omer bar-or</Author>
+ <Name>com.sun.star.comp.sdbc.macab.Driver</Name>
+ <description>This library implements the database driver for Mac OS address book formats.</description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="alpha"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <project-build-dependency> vos </project-build-dependency>
+
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu1 </runtime-module-dependency>
+ <runtime-module-dependency> sal1 </runtime-module-dependency>
+ <runtime-module-dependency> vos </runtime-module-dependency>
+
+ <type> com.sun.star.registry.XRegistryKey </type>
+ <type> com.sun.star.util.XCancellable </type>
+ <type> com.sun.star.util.XNumberFormatter </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.uno.XComponentContext </type>
+ <type> com.sun.star.beans.PropertyAttribute </type>
+ <type> com.sun.star.beans.XPropertyState </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XMultiPropertySet </type>
+ <type> com.sun.star.beans.XFastPropertySet </type>
+ <type> com.sun.star.lang.XSingleServiceFactory </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.XSingleComponentFactory </type>
+ <type> com.sun.star.lang.EventObject </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.DisposedException </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.lang.XServiceInfo </type>
+ <type> com.sun.star.lang.XUnoTunnel </type>
+ <type> com.sun.star.java.XJavaThreadRegister_11 </type>
+ <type> com.sun.star.java.XJavaVM </type>
+ <type> com.sun.star.sdbc.FetchDirection </type>
+ <type> com.sun.star.sdbc.XConnection </type>
+ <type> com.sun.star.sdbc.XStatement </type>
+ <type> com.sun.star.sdbc.XResultSet </type>
+ <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type>
+ <type> com.sun.star.sdbc.XColumnLocate </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XWarningsSupplier </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbc.XMultipleResults </type>
+ <type> com.sun.star.sdbc.XBatchExecution </type>
+ <type> com.sun.star.sdbc.XPreparedBatchExecution </type>
+ <type> com.sun.star.sdbc.XParameters </type>
+ <type> com.sun.star.sdbc.XOutParameters </type>
+ <type> com.sun.star.sdbc.DriverPropertyInfo </type>
+ <type> com.sun.star.sdbc.SQLWarning </type>
+ <type> com.sun.star.sdbc.XRow </type>
+ <type> com.sun.star.sdbc.ColumnSearch </type>
+ <type> com.sun.star.sdbc.ColumnValue </type>
+ <type> com.sun.star.sdbc.DataType </type>
+ <type> com.sun.star.sdbc.XDriver </type>
+ <type> com.sun.star.sdbc.TransactionIsolation </type>
+ <type> com.sun.star.sdbc.ResultSetType </type>
+ <type> com.sun.star.sdbc.ResultSetConcurrency </type>
+ <type> com.sun.star.sdbcx.XRowLocate </type>
+ <type> com.sun.star.sdbcx.XDeleteRows </type>
+ <type> com.sun.star.sdbcx.CompareBookmark </type>
+ <type> com.sun.star.sdb.XColumnUpdate </type>
+ <type> com.sun.star.sdb.XColumn </type>
+</module-description>
diff --git a/connectivity/source/drivers/macab/macabcondition.cxx b/connectivity/source/drivers/macab/macabcondition.cxx
new file mode 100755
index 000000000000..ec3ff2eb9ff1
--- /dev/null
+++ b/connectivity/source/drivers/macab/macabcondition.cxx
@@ -0,0 +1,250 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "macabcondition.hxx"
+#include "MacabHeader.hxx"
+#include "MacabRecord.hxx"
+#include "connectivity/CommonTools.hxx"
+
+using namespace ::connectivity::macab;
+using namespace ::com::sun::star::sdbc;
+// -----------------------------------------------------------------------------
+MacabCondition::~MacabCondition()
+{
+}
+// -----------------------------------------------------------------------------
+MacabConditionConstant::MacabConditionConstant(const sal_Bool bValue)
+ : MacabCondition(),
+ m_bValue(bValue)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionConstant::isAlwaysTrue() const
+{
+ return m_bValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionConstant::isAlwaysFalse() const
+{
+ return !m_bValue;
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionConstant::eval(const MacabRecord *) const
+{
+ return m_bValue;
+}
+// -----------------------------------------------------------------------------
+MacabConditionColumn::MacabConditionColumn(const MacabHeader *header, const ::rtl::OUString &sColumnName) throw(SQLException)
+ : MacabCondition(),
+ m_nFieldNumber(header->getColumnNumber(sColumnName))
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionColumn::isAlwaysTrue() const
+{
+ // Sometimes true, sometimes false
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionColumn::isAlwaysFalse() const
+{
+ // Sometimes true, sometimes false
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+MacabConditionNull::MacabConditionNull(const MacabHeader *header, const ::rtl::OUString &sColumnName) throw(SQLException)
+ : MacabConditionColumn(header, sColumnName)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionNull::eval(const MacabRecord *aRecord) const
+{
+ macabfield *aValue = aRecord->get(m_nFieldNumber);
+
+ if(aValue == NULL)
+ return sal_True;
+ else if(aValue->value == NULL)
+ return sal_True;
+ else
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+MacabConditionNotNull::MacabConditionNotNull(const MacabHeader *header, const ::rtl::OUString &sColumnName) throw(SQLException)
+ : MacabConditionColumn(header, sColumnName)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionNotNull::eval(const MacabRecord *aRecord) const
+{
+ macabfield *aValue = aRecord->get(m_nFieldNumber);
+
+ if(aValue == NULL)
+ return sal_False;
+ else if(aValue->value == NULL)
+ return sal_False;
+ else
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+MacabConditionCompare::MacabConditionCompare(const MacabHeader *header, const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : MacabConditionColumn(header, sColumnName),
+ m_sMatchString(sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+MacabConditionEqual::MacabConditionEqual(const MacabHeader *header, const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : MacabConditionCompare(header, sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionEqual::eval(const MacabRecord *aRecord) const
+{
+ macabfield *aValue = aRecord->get(m_nFieldNumber);
+
+ if(aValue == NULL)
+ return sal_False;
+
+ macabfield *aValue2 = MacabRecord::createMacabField(m_sMatchString,aValue->type);
+
+ if(aValue2 == NULL)
+ return sal_False;
+
+ sal_Int32 nReturn = MacabRecord::compareFields(aValue, aValue2);
+
+ delete aValue2;
+ return nReturn == 0;
+}
+// -----------------------------------------------------------------------------
+MacabConditionDifferent::MacabConditionDifferent(const MacabHeader *header, const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : MacabConditionCompare(header, sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionDifferent::eval(const MacabRecord *aRecord) const
+{
+ macabfield *aValue = aRecord->get(m_nFieldNumber);
+
+ if(aValue == NULL)
+ return sal_False;
+
+ macabfield *aValue2 = MacabRecord::createMacabField(m_sMatchString,aValue->type);
+
+ if(aValue2 == NULL)
+ return sal_False;
+
+ sal_Int32 nReturn = MacabRecord::compareFields(aValue, aValue2);
+
+ delete aValue2;
+ return nReturn != 0;
+}
+// -----------------------------------------------------------------------------
+MacabConditionSimilar::MacabConditionSimilar(const MacabHeader *header, const ::rtl::OUString &sColumnName, const ::rtl::OUString &sMatchString) throw(SQLException)
+ : MacabConditionCompare(header, sColumnName, sMatchString)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionSimilar::eval(const MacabRecord *aRecord) const
+{
+ macabfield *aValue = aRecord->get(m_nFieldNumber);
+
+ if(aValue == NULL)
+ return sal_False;
+
+ ::rtl::OUString sName = MacabRecord::fieldToString(aValue);
+
+ return match(m_sMatchString, sName, '\0');
+}
+// -----------------------------------------------------------------------------
+MacabConditionBoolean::MacabConditionBoolean(MacabCondition *pLeft, MacabCondition *pRight)
+ : MacabCondition(),
+ m_pLeft(pLeft),
+ m_pRight(pRight)
+{
+}
+// -----------------------------------------------------------------------------
+MacabConditionBoolean::~MacabConditionBoolean()
+{
+ delete m_pLeft;
+ delete m_pRight;
+}
+// -----------------------------------------------------------------------------
+MacabConditionOr::MacabConditionOr(MacabCondition *pLeft, MacabCondition *pRight)
+ : MacabConditionBoolean(pLeft, pRight)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionOr::isAlwaysTrue() const
+{
+ return m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionOr::isAlwaysFalse() const
+{
+ return m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse();
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionOr::eval(const MacabRecord *aRecord) const
+{
+ // We avoid evaluating terms as much as we can
+ if (m_pLeft->isAlwaysTrue() || m_pRight->isAlwaysTrue()) return sal_True;
+ if (m_pLeft->isAlwaysFalse() && m_pRight->isAlwaysFalse()) return sal_False;
+
+ if (m_pLeft->eval(aRecord)) return sal_True;
+ if (m_pRight->eval(aRecord)) return sal_True;
+
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+MacabConditionAnd::MacabConditionAnd(MacabCondition *pLeft, MacabCondition *pRight)
+ : MacabConditionBoolean(pLeft, pRight)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionAnd::isAlwaysTrue() const
+{
+ return m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue();
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionAnd::isAlwaysFalse() const
+{
+ return m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse();
+}
+// -----------------------------------------------------------------------------
+sal_Bool MacabConditionAnd::eval(const MacabRecord *aRecord) const
+{
+ // We avoid evaluating terms as much as we can
+ if (m_pLeft->isAlwaysFalse() || m_pRight->isAlwaysFalse()) return sal_False;
+ if (m_pLeft->isAlwaysTrue() && m_pRight->isAlwaysTrue()) return sal_True;
+
+ if (!m_pLeft->eval(aRecord)) return sal_False;
+ if (!m_pRight->eval(aRecord)) return sal_False;
+
+ return sal_True;
+}
diff --git a/connectivity/source/drivers/macab/macabcondition.hxx b/connectivity/source/drivers/macab/macabcondition.hxx
new file mode 100755
index 000000000000..1e0f322aba55
--- /dev/null
+++ b/connectivity/source/drivers/macab/macabcondition.hxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_CONDITION_HXX_
+#define _CONNECTIVITY_MACAB_CONDITION_HXX_
+
+#include "MacabHeader.hxx"
+#include "MacabRecord.hxx"
+
+#ifndef _COMPHELPER_TYPES_H_
+#include <comphelper/types.hxx>
+#endif
+#include <connectivity/dbexception.hxx>
+
+namespace connectivity
+{
+ namespace macab
+ {
+// -----------------------------------------------------------------------------
+class MacabCondition
+{
+ public:
+ virtual ~MacabCondition();
+ virtual sal_Bool isAlwaysTrue() const = 0;
+ virtual sal_Bool isAlwaysFalse() const = 0;
+ virtual sal_Bool eval(const MacabRecord *aRecord) const = 0;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionConstant : public MacabCondition
+{
+ protected:
+ sal_Bool m_bValue;
+
+ public:
+ MacabConditionConstant(const sal_Bool bValue);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionColumn : public MacabCondition
+{
+ protected:
+ sal_Int32 m_nFieldNumber;
+
+ public:
+ MacabConditionColumn(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionNull : public MacabConditionColumn
+{
+ public:
+ MacabConditionNull(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionNotNull : public MacabConditionColumn
+{
+ public:
+ MacabConditionNotNull(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionCompare : public MacabConditionColumn
+{
+ protected:
+ const ::rtl::OUString m_sMatchString;
+
+ public:
+ MacabConditionCompare(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+};
+// -----------------------------------------------------------------------------
+class MacabConditionEqual : public MacabConditionCompare
+{
+ public:
+ MacabConditionEqual(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionDifferent : public MacabConditionCompare
+{
+ public:
+ MacabConditionDifferent(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionSimilar : public MacabConditionCompare
+{
+ public:
+ MacabConditionSimilar(
+ const MacabHeader *header,
+ const ::rtl::OUString &sColumnName,
+ const ::rtl::OUString &sMatchString) throw(::com::sun::star::sdbc::SQLException);
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionBoolean : public MacabCondition
+{
+ protected:
+ MacabCondition *m_pLeft, *m_pRight;
+
+ public:
+ MacabConditionBoolean(MacabCondition *pLeft, MacabCondition *pRight);
+ virtual ~MacabConditionBoolean();
+};
+// -----------------------------------------------------------------------------
+class MacabConditionOr : public MacabConditionBoolean
+{
+ public:
+ MacabConditionOr(MacabCondition *pLeft, MacabCondition *pRight);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+class MacabConditionAnd : public MacabConditionBoolean
+{
+ public:
+ MacabConditionAnd(MacabCondition *pLeft, MacabCondition *pRight);
+ virtual sal_Bool isAlwaysTrue() const;
+ virtual sal_Bool isAlwaysFalse() const;
+ virtual sal_Bool eval(const MacabRecord *aRecord) const;
+};
+// -----------------------------------------------------------------------------
+ }
+}
+
+#endif // _CONNECTIVITY_MACAB_CONDITION_HXX_
diff --git a/connectivity/source/drivers/macab/macaborder.cxx b/connectivity/source/drivers/macab/macaborder.cxx
new file mode 100755
index 000000000000..bd14c007c5b4
--- /dev/null
+++ b/connectivity/source/drivers/macab/macaborder.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "macaborder.hxx"
+#include "MacabHeader.hxx"
+#include "MacabRecord.hxx"
+
+using namespace ::connectivity::macab;
+
+MacabOrder::~MacabOrder()
+{
+}
+// -----------------------------------------------------------------------------
+MacabSimpleOrder::MacabSimpleOrder(MacabHeader *header, ::rtl::OUString &sColumnName, sal_Bool bAscending)
+ : MacabOrder(),
+ m_nFieldNumber(header->getColumnNumber(sColumnName)),
+ m_bAscending(bAscending)
+{
+}
+// -----------------------------------------------------------------------------
+sal_Int32 MacabSimpleOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
+{
+ sal_Int32 result;
+
+ result = MacabRecord::compareFields(record1->get(m_nFieldNumber), record2->get(m_nFieldNumber));
+
+ if (!m_bAscending) result = -result;
+
+ return result;
+}
+// -----------------------------------------------------------------------------
+MacabComplexOrder::MacabComplexOrder()
+ : MacabOrder(),
+ m_aOrders()
+{
+}
+// -----------------------------------------------------------------------------
+MacabComplexOrder::~MacabComplexOrder()
+{
+ for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
+ delete m_aOrders[i];
+}
+// -----------------------------------------------------------------------------
+void MacabComplexOrder::addOrder(MacabOrder *pOrder)
+{
+ m_aOrders.push_back(pOrder);
+}
+// -----------------------------------------------------------------------------
+sal_Int32 MacabComplexOrder::compare(const MacabRecord *record1, const MacabRecord *record2) const
+{
+ for (sal_uInt32 i = 0; i < m_aOrders.size(); i++)
+ {
+ const MacabOrder *pOrder = m_aOrders[i];
+ sal_Int32 result = pOrder->compare(record1, record2);
+
+ if (result) return result;
+ }
+ return 0;
+}
diff --git a/connectivity/source/drivers/macab/macaborder.hxx b/connectivity/source/drivers/macab/macaborder.hxx
new file mode 100755
index 000000000000..df91d641ee8f
--- /dev/null
+++ b/connectivity/source/drivers/macab/macaborder.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_ORDER_HXX_
+#define _CONNECTIVITY_MACAB_ORDER_HXX_
+
+#include "rtl/ustring.hxx"
+#include "MacabHeader.hxx"
+#include "MacabRecord.hxx"
+
+#include <vector>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ class MacabOrder
+ {
+ public:
+ virtual ~MacabOrder();
+
+ virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const = 0;
+ };
+
+ class MacabSimpleOrder : public MacabOrder
+ {
+ sal_Int32 m_nFieldNumber;
+ sal_Bool m_bAscending;
+
+ public:
+ MacabSimpleOrder(MacabHeader *header, ::rtl::OUString &sColumnName, sal_Bool bAscending);
+
+ virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const;
+ };
+
+ class MacabComplexOrder : public MacabOrder
+ {
+ ::std::vector<MacabOrder *> m_aOrders;
+
+ public:
+ MacabComplexOrder();
+ virtual ~MacabComplexOrder();
+
+ void addOrder(MacabOrder *pOrder);
+ virtual sal_Int32 compare(const MacabRecord *record1, const MacabRecord *record2) const;
+ };
+ }
+}
+
+#endif
diff --git a/connectivity/source/drivers/macab/macabutilities.hxx b/connectivity/source/drivers/macab/macabutilities.hxx
new file mode 100644
index 000000000000..0865cb5b2127
--- /dev/null
+++ b/connectivity/source/drivers/macab/macabutilities.hxx
@@ -0,0 +1,149 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MACAB_UTILITIES_HXX_
+#define _CONNECTIVITY_MACAB_UTILITIES_HXX_
+
+#include <com/sun/star/util/DateTime.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+
+#include <time.h>
+#include <premac.h>
+#include <Carbon/Carbon.h>
+#include <AddressBook/ABAddressBookC.h>
+#include <postmac.h>
+
+namespace connectivity
+{
+ namespace macab
+ {
+ // -------------------------------------------------------------------------
+ inline ::rtl::OUString CFStringToOUString(const CFStringRef sOrig)
+ {
+ /* Copied all-but directly from code by Florian Heckl in
+ * cws_src680_aquafilepicker01
+ * File was: fpicker/source/aqua/CFStringUtilities
+ * I only removed commented debugging lines and changed variable
+ * names.
+ */
+ if (NULL == sOrig) {
+ return rtl::OUString();
+ }
+
+ CFRetain(sOrig);
+ CFIndex nStringLength = CFStringGetLength(sOrig);
+
+ UniChar unichars[nStringLength+1];
+
+ //'close' the string buffer correctly
+ unichars[nStringLength] = '\0';
+
+ CFStringGetCharacters (sOrig, CFRangeMake(0,nStringLength), unichars);
+ CFRelease(sOrig);
+
+ return rtl::OUString(unichars);
+ }
+
+ // -------------------------------------------------------------------------
+ inline CFStringRef OUStringToCFString(const ::rtl::OUString& aString)
+ {
+ /* Copied directly from code by Florian Heckl in
+ * cws_src680_aquafilepicker01
+ * File was: fpicker/source/aqua/CFStringUtilities
+ */
+
+ CFStringRef ref = CFStringCreateWithCharacters(kCFAllocatorDefault, aString.getStr(), aString.getLength());
+
+ return ref;
+ }
+
+ // -------------------------------------------------------------------------
+ inline com::sun::star::util::DateTime CFDateToDateTime(const CFDateRef _cfDate)
+ {
+ /* Carbon can give us the time since 2001 of any CFDateRef,
+ * and it also stores the time since 1970 as a constant,
+ * basically allowing us to get the unixtime of any
+ * CFDateRef. From there, it is just a matter of choosing what
+ * we want to do with it.
+ */
+ com::sun::star::util::DateTime nRet;
+ double timeSince2001 = CFDateGetAbsoluteTime(_cfDate);
+ time_t unixtime = timeSince2001+kCFAbsoluteTimeIntervalSince1970;
+ struct tm *ptm = localtime(&unixtime);
+ nRet.Year = ptm->tm_year+1900;
+ nRet.Month = ptm->tm_mon+1;
+ nRet.Day = ptm->tm_mday;
+ nRet.Hours = ptm->tm_hour;
+ nRet.Minutes = ptm->tm_min;
+ nRet.Seconds = ptm->tm_sec;
+ nRet.HundredthSeconds = 0;
+ return nRet;
+ }
+
+ // -------------------------------------------------------------------------
+ inline ::rtl::OUString fixLabel(const ::rtl::OUString _originalLabel)
+ {
+ /* Get the length, and make sure that there is actually a string
+ * here.
+ */
+ if(_originalLabel.indexOf(::rtl::OUString::createFromAscii("_$!<")) == 0)
+ {
+ return _originalLabel.copy(4,_originalLabel.getLength()-8);
+ }
+
+ return _originalLabel;
+ }
+
+ // -------------------------------------------------------------------------
+ inline sal_Int32 ABTypeToDataType(const ABPropertyType _abType)
+ {
+ sal_Int32 dataType;
+ switch(_abType)
+ {
+ case kABStringProperty:
+ dataType = ::com::sun::star::sdbc::DataType::CHAR;
+ break;
+ case kABDateProperty:
+ dataType = ::com::sun::star::sdbc::DataType::TIMESTAMP;
+ break;
+ case kABIntegerProperty:
+ dataType = ::com::sun::star::sdbc::DataType::INTEGER;
+ break;
+ case kABRealProperty:
+ dataType = ::com::sun::star::sdbc::DataType::FLOAT;
+ break;
+ default:
+ dataType = -1;
+ }
+ return dataType;
+ }
+
+ void impl_throwError(sal_uInt16 _nErrorId);
+ }
+}
+
+#endif // _ CONNECTIVITY_MACAB_UTILITIES_HXX_
diff --git a/connectivity/source/drivers/macab/makefile.mk b/connectivity/source/drivers/macab/makefile.mk
new file mode 100755
index 000000000000..35532b15ec2d
--- /dev/null
+++ b/connectivity/source/drivers/macab/makefile.mk
@@ -0,0 +1,129 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=macab
+TARGET2=$(TARGET)drv
+VISIBILITY_HIDDEN=TRUE
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(GUI)" == "UNX"
+.IF "$(OS)" == "MACOSX"
+
+# === MACAB base library ==========================
+
+# --- Files -------------------------------------
+
+SLOFILES= \
+ $(SLO)$/MacabDriver.obj \
+ $(SLO)$/MacabServices.obj
+
+DEPOBJFILES= \
+ $(SLO2FILES)
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(TARGET)$(MACAB_MAJOR)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(DBTOOLSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+
+# === MACAB impl library ==========================
+
+# --- Files -------------------------------------
+
+SLO2FILES=\
+ $(SLO)$/MacabColumns.obj \
+ $(SLO)$/MacabTable.obj \
+ $(SLO)$/MacabTables.obj \
+ $(SLO)$/MacabCatalog.obj \
+ $(SLO)$/MacabResultSet.obj \
+ $(SLO)$/MacabStatement.obj \
+ $(SLO)$/MacabPreparedStatement.obj \
+ $(SLO)$/MacabDatabaseMetaData.obj \
+ $(SLO)$/MacabConnection.obj \
+ $(SLO)$/MacabResultSetMetaData.obj \
+ $(SLO)$/macabcondition.obj \
+ $(SLO)$/macaborder.obj \
+ $(SLO)$/MacabRecord.obj \
+ $(SLO)$/MacabRecords.obj \
+ $(SLO)$/MacabHeader.obj \
+ $(SLO)$/MacabGroup.obj \
+ $(SLO)$/MacabAddressBook.obj
+
+MACAB_LIB=-framework Carbon -framework AddressBook
+
+# --- Library -----------------------------------
+
+SHL2TARGET= $(TARGET2)$(MACAB_MAJOR)
+SHL2OBJS=$(SLO2FILES)
+SHL2STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(MACAB_LIB)
+
+SHL2DEPN=
+SHL2IMPLIB= i$(TARGET2)
+
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+
+DEF2NAME= $(SHL2TARGET)
+
+# --- Targets -----------------------------------
+.ELSE # "$(OS)" == "MACOSX"
+dummy:
+ @echo Not using Mac OS X - nothing to build
+.ENDIF
+
+.ELSE # "$(GUI)" == "UNX"
+dummy:
+ @echo "Nothing to build for GUI $(GUI)"
+.ENDIF
+
+.INCLUDE : $(PRJ)$/target.pmk
+
diff --git a/connectivity/source/drivers/mozab/MCatalog.cxx b/connectivity/source/drivers/mozab/MCatalog.cxx
new file mode 100644
index 000000000000..c7ca7d37d325
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MCatalog.cxx
@@ -0,0 +1,127 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MCatalog.hxx"
+#ifndef _CONNECTIVITY_MOZAB_BCONNECTION_HXX_
+#include "MConnection.hxx"
+#endif
+#include "MTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <cppuhelper/interfacecontainer.h>
+
+// -------------------------------------------------------------------------
+using namespace connectivity::mozab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace ::cppu;
+
+// -------------------------------------------------------------------------
+OCatalog::OCatalog(OConnection* _pCon) : connectivity::sdbcx::OCatalog(_pCon)
+ ,m_pConnection(_pCon)
+ ,m_xMetaData(m_pConnection->getMetaData( ))
+{
+// osl_incrementInterlockedCount( &m_refCount );
+// refreshTables();
+// refreshViews();
+// refreshGroups();
+// refreshUsers();
+// osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshTables()
+{
+ TStringVector aVector;
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%")),aTypes);
+
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ ::rtl::OUString aName;
+ while(xResult->next())
+ {
+ aName = xRow->getString(3);
+ aVector.push_back(aName);
+ }
+ }
+ if(m_pTables)
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshViews()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void OCatalog::refreshUsers()
+{
+}
+// -------------------------------------------------------------------------
+const ::rtl::OUString& OCatalog::getDot()
+{
+ static const ::rtl::OUString sDot = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("."));
+ return sDot;
+}
+// -----------------------------------------------------------------------------
+
+// XTablesSupplier
+Reference< XNameAccess > SAL_CALL OCatalog::getTables( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(rBHelper.bDisposed);
+
+ try
+ {
+ if(!m_pTables || m_pConnection->getForceLoadTables())
+ refreshTables();
+ }
+ catch( const RuntimeException& )
+ {
+ // allowed to leave this method
+ throw;
+ }
+ catch( const Exception& )
+ {
+ // allowed
+ }
+
+ return const_cast<OCatalog*>(this)->m_pTables;
+}
diff --git a/connectivity/source/drivers/mozab/MCatalog.hxx b/connectivity/source/drivers/mozab/MCatalog.hxx
new file mode 100644
index 000000000000..e11b74cf4750
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MCatalog.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_MOZAB_CATALOG_HXX_
+#define _CONNECTIVITY_MOZAB_CATALOG_HXX_
+
+#include "connectivity/sdbcx/VCatalog.hxx"
+// #ifndef _CONNECTIVITY_OFUNCTIONDEFS_HXX_
+// #include "odbc/OFunctiondefs.hxx"
+// #endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ // please don't name the class the same name as in an other namespaces
+ // some compilers have problems with this task as I noticed on windows
+ class OConnection;
+ class OCatalog : public connectivity::sdbcx::OCatalog
+ {
+ OConnection* m_pConnection; // used to get the metadata
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData; // just to make things easier
+
+ public:
+ // implementation of the pure virtual methods
+ virtual void refreshTables();
+ virtual void refreshViews() ;
+ virtual void refreshGroups();
+ virtual void refreshUsers() ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTables( ) throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OCatalog(OConnection* _pCon);
+
+ OConnection* getConnection() const { return m_pConnection; }
+ sdbcx::OCollection* getPrivateTables() const { return m_pTables;}
+ sdbcx::OCollection* getPrivateViews() const { return m_pViews; }
+
+ static const ::rtl::OUString& getDot();
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_CATALOG_HXX_
+
diff --git a/connectivity/source/drivers/mozab/MColumnAlias.cxx b/connectivity/source/drivers/mozab/MColumnAlias.cxx
new file mode 100644
index 000000000000..f1b04f9251c0
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MColumnAlias.cxx
@@ -0,0 +1,191 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MColumnAlias.hxx"
+#include "MConnection.hxx"
+#include "MExtConfigAccess.hxx"
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/container/XNameAccess.hpp>
+
+#include <tools/diagnose_ex.h>
+
+#include <algorithm>
+#include <functional>
+
+using namespace ::connectivity;
+using namespace ::connectivity::mozab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+
+//------------------------------------------------------------------------------
+OColumnAlias::OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
+{
+ static const sal_Char* s_pProgrammaticNames[] =
+ {
+ "FirstName",
+ "LastName",
+ "DisplayName",
+ "NickName",
+ "PrimaryEmail",
+ "SecondEmail",
+ "PreferMailFormat",
+ "WorkPhone",
+ "HomePhone",
+ "FaxNumber",
+ "PagerNumber",
+ "CellularNumber",
+ "HomeAddress",
+ "HomeAddress2",
+ "HomeCity",
+ "HomeState",
+ "HomeZipCode",
+ "HomeCountry",
+ "WorkAddress",
+ "WorkAddress2",
+ "WorkCity",
+ "WorkState",
+ "WorkZipCode",
+ "WorkCountry",
+ "JobTitle",
+ "Department",
+ "Company",
+ "WebPage1",
+ "WebPage2",
+ "BirthYear",
+ "BirthMonth",
+ "BirthDay",
+ "Custom1",
+ "Custom2",
+ "Custom3",
+ "Custom4",
+ "Notes",
+ };
+
+ for ( size_t i = 0; i < sizeof( s_pProgrammaticNames ) / sizeof( s_pProgrammaticNames[0] ); ++i )
+ m_aAliasMap[ ::rtl::OUString::createFromAscii( s_pProgrammaticNames[i] ) ] = AliasEntry( s_pProgrammaticNames[i], i );
+
+ initialize( _rxORB );
+}
+
+//------------------------------------------------------------------------------
+void OColumnAlias::initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB )
+{
+ // open our driver settings config node
+
+ // the config path for our own driver's settings
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( _rxORB );
+ if ( xDriverNode.is() )
+ {
+ try
+ {
+ //.............................................................
+ Reference< XNameAccess > xAliasesNode;
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ColumnAliases")) ) >>= xAliasesNode;
+ OSL_ENSURE( xAliasesNode.is(), "OColumnAlias::setAlias: missing the aliases node!" );
+
+ // this is a set of string nodes
+ Sequence< ::rtl::OUString > aProgrammaticNames;
+ if ( xAliasesNode.is() )
+ aProgrammaticNames = xAliasesNode->getElementNames();
+
+ //.............................................................
+ // travel through all the set elements
+ const ::rtl::OUString* pProgrammaticNames = aProgrammaticNames.getConstArray();
+ const ::rtl::OUString* pProgrammaticNamesEnd = pProgrammaticNames + aProgrammaticNames.getLength();
+ ::rtl::OUString sAssignedAlias;
+
+ for ( ; pProgrammaticNames < pProgrammaticNamesEnd; ++pProgrammaticNames )
+ {
+ OSL_VERIFY( xAliasesNode->getByName( *pProgrammaticNames ) >>= sAssignedAlias );
+
+ // normalize in case the config data is corrupted
+ // (what we really don't need is an empty alias ...)
+ if ( 0 == sAssignedAlias.getLength() )
+ sAssignedAlias = *pProgrammaticNames;
+
+ ::rtl::OString sAsciiProgrammaticName( ::rtl::OUStringToOString( *pProgrammaticNames, RTL_TEXTENCODING_ASCII_US ) );
+ //.............................................................
+ #if OSL_DEBUG_LEVEL > 0
+ bool bFound = false;
+ #endif
+ for ( AliasMap::iterator search = m_aAliasMap.begin();
+ ( search != m_aAliasMap.end() );
+ ++search
+ )
+ {
+ if ( search->second.programmaticAsciiName.equals( sAsciiProgrammaticName ) )
+ {
+ AliasEntry entry( search->second );
+ m_aAliasMap.erase( search );
+ m_aAliasMap[ sAssignedAlias ] = entry;
+
+ #if OSL_DEBUG_LEVEL > 0
+ bFound = true;
+ #endif
+
+ break;
+ }
+ }
+
+ OSL_ENSURE( bFound, "OColumnAlias::setAlias: did not find a programmatic name which exists in the configuration!" );
+ }
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+//------------------------------------------------------------------
+::rtl::OString OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::OUString& _rAlias ) const
+{
+ AliasMap::const_iterator pos = m_aAliasMap.find( _rAlias );
+ if ( pos == m_aAliasMap.end() )
+ {
+ OSL_ENSURE( false, "OColumnAlias::getProgrammaticNameOrFallbackToUTF8Alias: no programmatic name for this alias!" );
+ return ::rtl::OUStringToOString( _rAlias, RTL_TEXTENCODING_UTF8 );
+ }
+ return pos->second.programmaticAsciiName;
+}
+
+//------------------------------------------------------------------
+bool OColumnAlias::isColumnSearchable( const ::rtl::OUString _alias ) const
+{
+ ::rtl::OString sProgrammatic = getProgrammaticNameOrFallbackToUTF8Alias( _alias );
+
+ return ( !sProgrammatic.equals( "HomeCountry" )
+ && !sProgrammatic.equals( "WorkCountry" )
+ );
+ // for those, we know that they're not searchable in the Mozilla/LDAP implementation.
+ // There might be more ...
+}
diff --git a/connectivity/source/drivers/mozab/MColumnAlias.hxx b/connectivity/source/drivers/mozab/MColumnAlias.hxx
new file mode 100644
index 000000000000..6653f386044c
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MColumnAlias.hxx
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _CONNECTIVITY_MAB_COLUMNALIAS_HXX_
+#define _CONNECTIVITY_MAB_COLUMNALIAS_HXX_
+
+#include <unotools/confignode.hxx>
+
+#include <osl/mutex.hxx>
+#include <vector>
+#include <hash_map>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class OColumnAlias
+ {
+ public:
+ struct AliasEntry
+ {
+ ::rtl::OString programmaticAsciiName;
+ sal_Int32 columnPosition;
+
+ AliasEntry()
+ :programmaticAsciiName()
+ ,columnPosition( 0 )
+ {
+ }
+ AliasEntry( const sal_Char* _programmaticAsciiName, sal_Int32 _columnPosition )
+ :programmaticAsciiName( _programmaticAsciiName )
+ ,columnPosition( _columnPosition )
+ {
+ }
+ };
+ typedef ::std::hash_map< ::rtl::OUString, AliasEntry, ::rtl::OUStringHash > AliasMap;
+
+ private:
+ AliasMap m_aAliasMap;
+
+ public:
+ OColumnAlias( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & );
+
+ inline bool hasAlias( const ::rtl::OUString& _rAlias ) const
+ {
+ return m_aAliasMap.find( _rAlias ) != m_aAliasMap.end();
+ }
+ ::rtl::OString getProgrammaticNameOrFallbackToUTF8Alias( const ::rtl::OUString& _rAlias ) const;
+
+ inline AliasMap::const_iterator begin() const { return m_aAliasMap.begin(); }
+ inline AliasMap::const_iterator end() const { return m_aAliasMap.end(); }
+
+ bool isColumnSearchable( const ::rtl::OUString _alias ) const;
+
+ private:
+ void initialize( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB );
+ };
+ }
+}
+#endif // _CONNECTIVITY_MAB_COLUMNALIAS_HXX_
diff --git a/connectivity/source/drivers/mozab/MColumns.cxx b/connectivity/source/drivers/mozab/MColumns.cxx
new file mode 100644
index 000000000000..42a33bbc2a98
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MColumns.cxx
@@ -0,0 +1,100 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MColumns.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "MTable.hxx"
+#include "MTables.hxx"
+#include "MCatalog.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+
+using namespace ::comphelper;
+
+
+using namespace connectivity::mozab;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OColumns::createObject(const ::rtl::OUString& _rName)
+{
+ Reference< XResultSet > xResult = m_pTable->getConnection()->getMetaData()->getColumns(Any(),
+ m_pTable->getSchema(),m_pTable->getTableName(),_rName);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ while(xResult->next())
+ {
+ if(xRow->getString(4) == _rName)
+ {
+ sal_Int32 nType = xRow->getInt(5);
+ ::rtl::OUString sTypeName = xRow->getString(6);
+ sal_Int32 nPrec = xRow->getInt(7);
+
+ OColumn* pRet = new OColumn(_rName,
+ sTypeName,
+ xRow->getString(13),
+ xRow->getString(12),
+ xRow->getInt(11),
+ nPrec,
+ xRow->getInt(9),
+ nType,
+ sal_False,sal_False,sal_False,sal_True);
+ xRet = pRet;
+ break;
+ }
+ }
+ }
+
+ return xRet;
+}
+
+// -------------------------------------------------------------------------
+void OColumns::impl_refresh() throw(RuntimeException)
+{
+ m_pTable->refreshColumns();
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/mozab/MColumns.hxx b/connectivity/source/drivers/mozab/MColumns.hxx
new file mode 100644
index 000000000000..8596c4b46ff3
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MColumns.hxx
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+#define _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include "MTable.hxx"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class OColumns : public sdbcx::OCollection
+ {
+ protected:
+ OTable* m_pTable;
+
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OColumns( OTable* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector
+ ) : sdbcx::OCollection(*_pTable,sal_True,_rMutex,_rVector)
+ ,m_pTable(_pTable)
+ {}
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_COLUMNS_HXX_
+
diff --git a/connectivity/source/drivers/mozab/MConfigAccess.cxx b/connectivity/source/drivers/mozab/MConfigAccess.cxx
new file mode 100644
index 000000000000..37d3a21a8a7c
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MConfigAccess.cxx
@@ -0,0 +1,273 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#ifndef CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+#include "MConfigAccess.hxx"
+#endif
+#ifndef CONNECTIVITY_MOZAB_MEXTCONFIGACCESS_HXX
+#include "MExtConfigAccess.hxx"
+#endif
+#include "MConnection.hxx"
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+
+//.........................................................................
+namespace connectivity
+{
+ namespace mozab
+ {
+ //-----------------------------------------------------------------
+ Reference< XPropertySet > createDriverConfigNode( Reference< XMultiServiceFactory > _rxORB )
+ {
+ Reference< XPropertySet > xNode;
+ try
+ {
+ //=============================================================
+ // create the config provider
+ Reference< XMultiServiceFactory > xConfigProvider(
+ _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider" )) ),
+ UNO_QUERY
+ );
+ OSL_ENSURE( xConfigProvider.is(), "createDriverConfigNode: could not create the config provider!" );
+
+ if ( xConfigProvider.is() )
+ {
+ ::rtl::OUString sCompleteNodePath = ::rtl::OUString::createFromAscii ("/org.openoffice.Office.DataAccess/DriverSettings/" );
+ sCompleteNodePath += OConnection::getDriverImplementationName();
+
+ //=========================================================
+ // arguments for creating the config access
+ Sequence< Any > aArguments(2);
+ // the path to the node to open
+ aArguments[0] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("nodepath")),
+ 0,
+ makeAny( sCompleteNodePath ),
+ PropertyState_DIRECT_VALUE
+ );
+ // the depth: -1 means unlimited
+ aArguments[1] <<= PropertyValue(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("depth")),
+ 0,
+ makeAny( (sal_Int32)-1 ),
+ PropertyState_DIRECT_VALUE
+ );
+
+ //=========================================================
+ // create the access
+ Reference< XInterface > xAccess = xConfigProvider->createInstanceWithArguments(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess" )),
+ aArguments
+ );
+ OSL_ENSURE( xAccess.is(), "createDriverConfigNode: invalid access returned (should throw an exception instead)!" );
+
+ xNode = xNode.query( xAccess );
+ }
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "createDriverConfigNode: caught an exception while accessing the driver's config node!" );
+ }
+
+ // outta here
+ return xNode;
+ }
+
+ //-----------------------------------------------------------------
+ namespace
+ {
+ // a private helper to accessing the point where we store the reference
+ // to the factory
+ Reference< XMultiServiceFactory >& accessFactoryStorage( )
+ {
+ static Reference< XMultiServiceFactory > xMozabServiceFactory;
+ return xMozabServiceFactory;
+ }
+ }
+
+ //-----------------------------------------------------------------
+ void setMozabServiceFactory( const Reference< XMultiServiceFactory >& _rxFactory )
+ {
+ accessFactoryStorage( ) = _rxFactory;
+ }
+
+ //-----------------------------------------------------------------
+ const Reference< XMultiServiceFactory >& getMozabServiceFactory( )
+ {
+ return accessFactoryStorage( );
+ }
+
+ //-----------------------------------------------------------------
+ ::rtl::OUString getDescription(const sal_Char* sNode,const ::rtl::OUString & sDefault)
+ {
+ ::rtl::OUString sPreferredName;
+ ::rtl::OUString sDescription;
+
+ Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory();
+ OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
+ if ( xFactory.is() )
+ {
+ try
+ {
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory );
+ Reference< XPropertySet > xMozPrefsNode;
+ if ( xDriverNode.is() )
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MozillaPreferences" )) ) >>= xMozPrefsNode;
+ OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" );
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ProfileName" )) ) >>= sPreferredName;
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString::createFromAscii(sNode) ) >>= sDescription;
+ if (sDescription.getLength() == 0)
+ sDescription = sDefault;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "getDescription: caught an exception!" );
+ }
+ }
+ if (sDescription.getLength() == 0)
+ sDescription = sDefault;
+ return sDescription;
+ }
+ //-----------------------------------------------------------------
+ ::rtl::OUString getPreferredProfileName( )
+ {
+ ::rtl::OUString sPreferredName;
+
+ Reference< XMultiServiceFactory > xFactory = getMozabServiceFactory();
+ OSL_ENSURE( xFactory.is(), "getPreferredProfileName: invalid service factory!" );
+ if ( xFactory.is() )
+ {
+ try
+ {
+ Reference< XPropertySet > xDriverNode = createDriverConfigNode( xFactory );
+ Reference< XPropertySet > xMozPrefsNode;
+ if ( xDriverNode.is() )
+ xDriverNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("MozillaPreferences" )) ) >>= xMozPrefsNode;
+ OSL_ENSURE( xMozPrefsNode.is(), "getPreferredProfileName: could not access the node for the mozilla preferences!" );
+ if ( xMozPrefsNode.is() )
+ xMozPrefsNode->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ProfileName" )) ) >>= sPreferredName;
+ }
+ catch( const Exception& )
+ {
+ OSL_ENSURE( sal_False, "getPreferredProfileName: caught an exception!" );
+ }
+ }
+ return sPreferredName;
+ }
+ }
+}
+
+//.........................................................................
+
+//-------------------------------------------------------------------------
+extern "C" const sal_Unicode* SAL_CALL getUserProfile( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString sUserProfile;
+ if ( !bReadConfig )
+ {
+ sUserProfile = ::connectivity::mozab::getPreferredProfileName( );
+ bReadConfig = sal_True;
+ }
+
+ return sUserProfile.getStr();
+}
+//------------------------------------------------------------------------
+extern "C" const sal_Char* SAL_CALL getPabDescription( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString usPabDescription;
+ static ::rtl::OString sPabDescription;
+
+ if ( !bReadConfig )
+ {
+ usPabDescription = ::connectivity::mozab::getDescription(
+ "PabDescription" ,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Personal Address Book" )));
+ sPabDescription = ::rtl::OUStringToOString( usPabDescription,
+ RTL_TEXTENCODING_UTF8);
+ bReadConfig = sal_True;
+ }
+
+ return sPabDescription.getStr();
+}
+
+//-------------------------------------------------------------------------
+extern "C" const sal_Char* SAL_CALL getHisDescription( void )
+{
+ static sal_Bool bReadConfig = sal_False;
+ static ::rtl::OUString usHisDescription;
+ static ::rtl::OString sHisDescription;
+
+ if ( !bReadConfig )
+ {
+ usHisDescription = ::connectivity::mozab::getDescription(
+ "HisDescription" ,
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Collected Addresses" )));
+ sHisDescription = ::rtl::OUStringToOString( usHisDescription,
+ RTL_TEXTENCODING_UTF8);
+ bReadConfig = sal_True;
+ }
+
+ return sHisDescription.getStr();
+}
+
+//-------------------------------------------------------------------------
+// MConfigAccess was invented to allow non-UNO parts access to the configuration.
+// Unfortunately, configuration access requires a XMultiServiceFactory - which the
+// mozilla side does not have.
+// So we create a "library-local" service factory here: Every need for a service
+// factory can be fullfilled by this factory (similar to the get/setProcessServiceFactory
+// in comphelper).
+// This is halfway valid, as usually, the mozabdrv library is invoked from the mozab library
+// only. The latter contains the driver class (and only this class and nothing more), and
+// the driver class is a singleton. The driver itself is created with a service factory,
+// which (by definition) can and should be used for all subsequent service requests.
+// And this is exactly what we're allowing with the following functions ....
+
+/** _pFactory must point to an XMultiServiceFactory, which must be aquired once
+ for purpose of safely transfering it. The callee will release this interface
+ when it has stored the pointer somewhere else.
+*/
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL setMozabServiceFactory(
+ void* _pFactory )
+{
+ Reference< XMultiServiceFactory > xFactory = static_cast< XMultiServiceFactory* >( _pFactory );
+ ::connectivity::mozab::setMozabServiceFactory( xFactory );
+
+ // by definition, the object behind the interface pointer has been acquired once for purpose
+ // of safely transporting it
+ xFactory->release();
+}
+
diff --git a/connectivity/source/drivers/mozab/MConfigAccess.hxx b/connectivity/source/drivers/mozab/MConfigAccess.hxx
new file mode 100644
index 000000000000..ee0dd3da7570
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MConfigAccess.hxx
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+
+#include <sal/types.h>
+
+extern "C" const sal_Unicode* SAL_CALL getUserProfile( void );
+
+extern "C" const sal_Char* SAL_CALL getPabDescription( void );
+
+extern "C" const sal_Char* SAL_CALL getHisDescription( void );
+
+#endif // CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+
diff --git a/connectivity/source/drivers/mozab/MConnection.cxx b/connectivity/source/drivers/mozab/MConnection.cxx
new file mode 100644
index 000000000000..71c65d05ca74
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MConnection.cxx
@@ -0,0 +1,603 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "diagnose_ex.h"
+#include "MConnection.hxx"
+#include "MDatabaseMetaData.hxx"
+#include "MDriver.hxx"
+#include "MColumnAlias.hxx"
+#include "MStatement.hxx"
+#include "MPreparedStatement.hxx"
+
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/sqlerror.hxx>
+
+#include "resource/mozab_res.hrc"
+#include "resource/common_res.hrc"
+
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+
+#include <comphelper/officeresourcebundle.hxx>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL OMozabConnection_CreateInstance(
+ void* _pDriver)
+{
+ return (new connectivity::mozab::OConnection( reinterpret_cast<connectivity::mozab::MozabDriver*>(_pDriver) ));
+}
+
+using namespace dbtools;
+
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+// --------------------------------------------------------------------------------
+
+namespace connectivity { namespace mozab {
+
+// =====================================================================
+// = ConnectionImplData
+// =====================================================================
+struct ConnectionImplData
+{
+ ::boost::shared_ptr< ::comphelper::OfficeResourceBundle > pResourceBundle;
+};
+
+// -----------------------------------------------------------------------------
+#ifdef __MINGW32__
+extern "C"
+#endif
+const sal_Char* getSdbcScheme( SdbcScheme _eScheme )
+{
+ switch ( _eScheme )
+ {
+ case SDBC_MOZILLA: return "mozilla";
+ case SDBC_THUNDERBIRD: return "thunderbird";
+ case SDBC_LDAP: return "ldap";
+ case SDBC_OUTLOOK_MAPI: return "outlook";
+ case SDBC_OUTLOOK_EXPRESS: return "outlookexp";
+ }
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OConnection::getDriverImplementationName()
+{
+ return rtl::OUString::createFromAscii(MOZAB_DRIVER_IMPL_NAME);
+}
+
+// -----------------------------------------------------------------------------
+const sal_Char* getSchemeURI( MozillaScheme _eScheme )
+{
+ switch ( _eScheme )
+ {
+ case SCHEME_MOZILLA : return "moz-abdirectory://";
+ case SCHEME_MOZILLA_MDB : return "moz-abmdbdirectory://";
+ case SCHEME_LDAP : return "moz-abldapdirectory://";
+ case SCHEME_OUTLOOK_MAPI : return "moz-aboutlookdirectory://op/";
+ case SCHEME_OUTLOOK_EXPRESS : return "moz-aboutlookdirectory://oe/";
+ }
+ return NULL;
+}
+
+// -----------------------------------------------------------------------------
+
+OConnection::OConnection(MozabDriver* _pDriver)
+ :OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+ ,m_pDriver(_pDriver)
+ ,m_pImplData( new ConnectionImplData )
+ ,m_aColumnAlias( _pDriver->getMSFactory() )
+ ,m_nMaxResultRecords( -1 )
+ ,m_aNameMapper(NULL)
+ ,m_eSDBCAddressType(SDBCAddress::Unknown)
+{
+ m_pDriver->acquire();
+
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ acquire();
+ if(!isClosed())
+ close();
+ m_pDriver->release();
+ m_pDriver = NULL;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+void OConnection::construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ OSL_TRACE("IN OConnection::construct()\n" );
+ // open file
+ setURL(url);
+ //
+ // Skip 'sdbc:mozab: part of URL
+ //
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ OSL_ENSURE( url.copy( 0, nLen ).equalsAscii( "sdbc:address" ), "OConnection::construct: invalid start of the URI - should never have survived XDriver::acceptsURL!" );
+
+ ::rtl::OUString aAddrbookURI(url.copy(nLen+1));
+ // Get Scheme
+ nLen = aAddrbookURI.indexOf(':');
+ ::rtl::OUString aAddrbookScheme;
+ ::rtl::OUString sAdditionalInfo;
+ if ( nLen == -1 )
+ {
+ // There isn't any subschema: - but could be just subschema
+ if ( aAddrbookURI.getLength() > 0 )
+ {
+ aAddrbookScheme= aAddrbookURI;
+ }
+ else
+ {
+ OSL_TRACE( "No subschema given!!!\n");
+ throwSQLException( STR_URI_SYNTAX_ERROR, *this );
+ }
+ }
+ else
+ {
+ aAddrbookScheme = aAddrbookURI.copy(0, nLen);
+ sAdditionalInfo = aAddrbookURI.copy( nLen + 1 );
+ }
+
+ OSL_TRACE("URI = %s\n", ((OUtoCStr(aAddrbookURI)) ? (OUtoCStr(aAddrbookURI)):("NULL")) );
+ OSL_TRACE("Scheme = %s\n", ((OUtoCStr(aAddrbookScheme)) ? (OUtoCStr(aAddrbookScheme)):("NULL")) );
+
+ //
+ // Now we have a URI convert it to a MozillaURI
+ //
+ // The Mapping being used is:
+ //
+ // * for Mozilla
+ // "sdbc:address:mozilla:" -> abdirectory://
+ // * for LDAP
+ // "sdbc:address:ldap:" -> abldapdirectory://
+ // * for Outlook (using MAPI API)
+ // "sdbc:address:outlook:" -> aboutlookdirectory://op/
+ // * for windows system address book
+ // "sdbc:address:outlookexp:" -> aboutlookdirectory://oe/
+ //
+ m_sBindDN = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+ m_sPassword = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+ m_bUseSSL = sal_False;
+
+ if ( aAddrbookScheme.compareToAscii( getSdbcScheme( SDBC_MOZILLA ) ) == 0 ) {
+ m_sMozillaURI = rtl::OUString::createFromAscii( getSchemeURI( SCHEME_MOZILLA ) );
+ m_eSDBCAddressType = SDBCAddress::Mozilla;
+ if(sAdditionalInfo.getLength())
+ m_sMozillaProfile = sAdditionalInfo;
+ }
+ else
+ if ( aAddrbookScheme.compareToAscii( getSdbcScheme( SDBC_THUNDERBIRD ) ) == 0 ) {
+ //Yes. I am sure it is SCHEME_MOZILLA
+ m_sMozillaURI = rtl::OUString::createFromAscii( getSchemeURI( SCHEME_MOZILLA ) );
+ m_eSDBCAddressType = SDBCAddress::ThunderBird;
+ if(sAdditionalInfo.getLength())
+ m_sMozillaProfile = sAdditionalInfo;
+ }
+ else if ( aAddrbookScheme.compareToAscii( getSdbcScheme( SDBC_LDAP ) ) == 0 ) {
+ rtl::OUString sBaseDN;
+ sal_Int32 nPortNumber = -1;
+
+ m_sMozillaURI = rtl::OUString::createFromAscii( getSchemeURI( SCHEME_LDAP ) );
+ m_eSDBCAddressType = SDBCAddress::LDAP;
+
+ if ( !m_sHostName.getLength() )
+ {
+ // see whether the URI contains a hostname/port
+ if ( sAdditionalInfo.getLength() )
+ {
+ sal_Int32 nPortSeparator = sAdditionalInfo.indexOf( ':' );
+ if ( nPortSeparator == -1 )
+ m_sHostName = sAdditionalInfo;
+ else
+ {
+ m_sHostName = sAdditionalInfo.copy( 0, nPortSeparator );
+ nPortNumber = sAdditionalInfo.copy( nPortSeparator + 1 ).toInt32();
+ OSL_ENSURE( nPortNumber != 0, "OConnection::construct: invalid LDAP port number in the URL!" );
+ if ( nPortNumber == 0 )
+ nPortNumber = -1;
+ }
+ }
+ }
+
+ const PropertyValue* pInfo = info.getConstArray();
+ const PropertyValue* pInfoEnd = pInfo + info.getLength();
+
+ for (; pInfo != pInfoEnd; ++pInfo)
+ {
+ OSL_TRACE( "info[%d].Name = %s\n", pInfo - info.getConstArray(), OUtoCStr( pInfo->Name ) );
+
+ if ( 0 == pInfo->Name.compareToAscii("HostName") )
+ {
+ pInfo->Value >>= m_sHostName;
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("BaseDN") )
+ {
+ pInfo->Value >>= sBaseDN;
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("user") )
+ {
+ pInfo->Value >>= m_sBindDN;
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("password") )
+ {
+ pInfo->Value >>= m_sPassword;
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("UseSSL") )
+ {
+ pInfo->Value >>= m_bUseSSL;
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("PortNumber") )
+ {
+ OSL_VERIFY( pInfo->Value >>= nPortNumber );
+ }
+ else if ( 0 == pInfo->Name.compareToAscii("MaxRowCount") )
+ {
+ pInfo->Value >>= m_nMaxResultRecords;
+ }
+ }
+
+ if ( m_sHostName.getLength() != 0 ) {
+ m_sMozillaURI += m_sHostName;
+ }
+ else
+ throwSQLException( STR_NO_HOSTNAME, *this );
+
+ if ( nPortNumber > 0 ) {
+ m_sMozillaURI += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(":") );
+ m_sMozillaURI += rtl::OUString::valueOf( nPortNumber );
+ }
+
+ if ( sBaseDN.getLength() != 0 ) {
+ m_sMozillaURI += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/") );
+ m_sMozillaURI += sBaseDN;
+ }
+ else
+ throwSQLException( STR_NO_BASEDN, *this );
+
+ // Addition of a fake query to enable the Mozilla LDAP directory to work correctly.
+ m_sMozillaURI += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?(or(DisplayName,=,DontDoThisAtHome)))"));
+
+ }
+ else if ( aAddrbookScheme.compareToAscii( getSdbcScheme( SDBC_OUTLOOK_MAPI ) ) == 0 ) {
+ m_sMozillaURI = ::rtl::OUString::createFromAscii( getSchemeURI( SCHEME_OUTLOOK_MAPI ) );
+ m_eSDBCAddressType = SDBCAddress::Outlook;
+ }
+ else if ( aAddrbookScheme.compareToAscii( getSdbcScheme( SDBC_OUTLOOK_EXPRESS ) ) == 0 ) {
+ m_sMozillaURI = rtl::OUString::createFromAscii( getSchemeURI( SCHEME_OUTLOOK_EXPRESS ) );
+ m_eSDBCAddressType = SDBCAddress::OutlookExp;
+ }
+ else
+ {
+ OSL_TRACE("Invalid subschema given!!!\n");
+ throwSQLException( STR_URI_SYNTAX_ERROR, *this );
+ }
+
+ OSL_TRACE("Moz URI = %s, %s\n", ((OUtoCStr(m_sMozillaURI)) ? (OUtoCStr(m_sMozillaURI)):("NULL")), usesFactory() ? "uses factory" : "no factory");
+ OSL_TRACE( "\tOUT OConnection::construct()\n" );
+
+ MDatabaseMetaDataHelper _aDbHelper;
+
+ // The creation of the nsIAbDirectory i/f for LDAP doesn't actually test
+ // the validity of the connection, it's normally delayed until the query
+ // is executed, but it's a bit late then to fail...
+ if ( isLDAP() )
+ {
+ if ( !_aDbHelper.testLDAPConnection( this ) )
+ {
+ OSL_TRACE("testLDAPConnection : FAILED\n" );
+ throwSQLException( _aDbHelper.getError(), *this );
+ }
+ else
+ {
+ OSL_TRACE("testLDAPConnection : SUCCESS\n" );
+ }
+ }
+
+ // Test connection by getting to get the Table Names
+ ::std::vector< ::rtl::OUString > tables;
+ ::std::vector< ::rtl::OUString > types;
+ if ( !_aDbHelper.getTableStrings( this, tables, types ) )
+ {
+ throwSQLException( _aDbHelper.getError(), *this );
+ }
+
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.mozab.OConnection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // create a statement
+ // the statement can only be executed once
+ Reference< XStatement > xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ OSL_TRACE("OConnection::prepareStatement( %s )", OUtoCStr( _sSql ) );
+ // the pre
+ // create a statement
+ // the statement can only be executed more than once
+ OPreparedStatement* pPrepared = new OPreparedStatement(this,_sSql);
+ Reference< XPreparedStatement > xReturn = pPrepared;
+ pPrepared->lateInit();
+
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ OSL_UNUSED( _sSql );
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ OSL_TRACE("OConnection::prepareCall( %s )", OUtoCStr( _sSql ) );
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& _sSql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ // when you need to transform SQL92 to you driver specific you can do it here
+ OSL_TRACE("OConnection::nativeSQL( %s )", OUtoCStr( _sSql ) );
+
+ return _sSql;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool /*autoCommit*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setAutoCommit", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ // you have to distinguish which if you are in autocommit mode or not
+ // at normal case true should be fine here
+
+ return sal_True;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ // when you database does support transactions you should commit here
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ // same as commit but for the other case
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ // just simple -> we are close when we are disposed taht means someone called dispose(); (XComponent)
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ // here we have to create the class with biggest interface
+ // The answer is 42 :-)
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(this); // need the connection because it can return it
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool /*readOnly*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setReadOnly", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ // return if your connection to readonly
+ return sal_False;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& /*catalog*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setCatalog", *this );
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ // return your current catalog
+ return ::rtl::OUString();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTransactionIsolation", *this );
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ // please have a look at @see com.sun.star.sdbc.TransactionIsolation
+ return TransactionIsolation::NONE;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ // if your driver has special database types you can return it here
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ // we just dispose us
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ // when you collected some warnings -> return it
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ // you should clear your collected warnings here
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ // we noticed that we should be destroied in near future so we have to dispose our statements
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_pImplData->pResourceBundle.reset();
+
+ OConnection_BASE::disposing();
+ if ( m_aNameMapper ) {
+ MQuery::FreeNameMapper( m_aNameMapper );
+ m_aNameMapper = NULL;
+ }
+
+ dispose_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+
+Reference< XTablesSupplier > SAL_CALL OConnection::createCatalog()
+{
+ OSL_TRACE("IN OConnection::createCatalog()\n" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ Reference< XTablesSupplier > xTab = m_xCatalog;
+ if(!m_xCatalog.is())
+ {
+ OCatalog *pCat = new OCatalog(this);
+ xTab = pCat;
+ m_xCatalog = xTab;
+ }
+ OSL_TRACE( "\tOUT OConnection::createCatalog()\n" );
+ return xTab;
+}
+// -----------------------------------------------------------------------------
+
+MNameMapper* OConnection::getNameMapper ()
+{
+ if (m_aNameMapper==NULL)
+ m_aNameMapper = MQuery::CreateNameMapper();
+
+ return m_aNameMapper;
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::throwSQLException( const ErrorDescriptor& _rError, const Reference< XInterface >& _rxContext )
+{
+ if ( _rError.getResId() != 0 )
+ {
+ OSL_ENSURE( ( _rError.getErrorCondition() == 0 ),
+ "OConnection::throwSQLException: unsupported error code combination!" );
+
+ ::rtl::OUString sParameter( _rError.getParameter() );
+ if ( sParameter.getLength() )
+ {
+ const ::rtl::OUString sError( getResources().getResourceStringWithSubstitution(
+ _rError.getResId(),
+ "$1$", sParameter
+ ) );
+ ::dbtools::throwGenericSQLException( sError, _rxContext );
+ OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (1)!" );
+ }
+
+ throwGenericSQLException( _rError.getResId(), _rxContext );
+ OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (2)!" );
+ }
+
+ if ( _rError.getErrorCondition() != 0 )
+ {
+ SQLError aErrorHelper( getDriver()->getMSFactory() );
+ ::rtl::OUString sParameter( _rError.getParameter() );
+ if ( sParameter.getLength() )
+ aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext, sParameter );
+ else
+ aErrorHelper.raiseException( _rError.getErrorCondition(), _rxContext);
+ OSL_ENSURE( false, "OConnection::throwSQLException: unreachable (3)!" );
+ }
+
+ throwGenericSQLException( STR_UNSPECIFIED_ERROR, _rxContext );
+}
+
+// -----------------------------------------------------------------------------
+void OConnection::throwSQLException( const sal_uInt16 _nErrorResourceId, const Reference< XInterface >& _rxContext )
+{
+ ErrorDescriptor aError;
+ aError.setResId( _nErrorResourceId );
+ throwSQLException( aError, _rxContext );
+}
+
+} } // namespace connectivity::mozab
diff --git a/connectivity/source/drivers/mozab/MConnection.hxx b/connectivity/source/drivers/mozab/MConnection.hxx
new file mode 100644
index 000000000000..f61aac114bf9
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MConnection.hxx
@@ -0,0 +1,231 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SCONNECTION_HXX
+#define CONNECTIVITY_SCONNECTION_HXX
+
+#include "connectivity/CommonTools.hxx"
+
+#include "MCatalog.hxx"
+#include "MColumnAlias.hxx"
+#include "OSubComponent.hxx"
+#include "TConnection.hxx"
+
+#include <com/sun/star/beans/PropertyValue.hpp>
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
+
+#include <cppuhelper/weakref.hxx>
+
+#include <memory>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ class MozabDriver;
+ class ODatabaseMetaData;
+ class MNameMapper;
+ class ErrorDescriptor;
+
+ namespace SDBCAddress {
+ typedef enum {
+ Unknown = 0,
+ Mozilla = 1,
+ ThunderBird = 2,
+ LDAP = 3,
+ Outlook = 4,
+ OutlookExp = 5
+ } sdbc_address_type;
+ }
+
+ // For the moment, we will connect the Mozilla address book to the Mozilla
+ // top-level address book which will display whatever is in the preferences
+ // file of Mozilla.
+ enum MozillaScheme
+ {
+ // This one is a base uri which will be completed with the connection data.
+ SCHEME_MOZILLA,
+ // This one is for mozilla native address book
+ SCHEME_MOZILLA_MDB,
+ // This one is for LDAP address book
+ SCHEME_LDAP,
+ // These two uris will be used to obtain directory factories to access all
+ // address books of the given type.
+ SCHEME_OUTLOOK_MAPI,
+ SCHEME_OUTLOOK_EXPRESS
+ };
+ const sal_Char* getSchemeURI( MozillaScheme _eScheme );
+
+ enum SdbcScheme
+ {
+ SDBC_MOZILLA,
+ SDBC_THUNDERBIRD,
+ SDBC_LDAP,
+ SDBC_OUTLOOK_MAPI,
+ SDBC_OUTLOOK_EXPRESS
+ };
+#ifdef __MINGW32__
+ extern "C"
+#endif
+ const sal_Char* getSdbcScheme( SdbcScheme _eScheme );
+
+ typedef connectivity::OMetaConnection OConnection_BASE; // implements basics and text encoding
+
+ struct ConnectionImplData;
+ class OConnection : public OConnection_BASE,
+ public connectivity::OSubComponent<OConnection, OConnection_BASE>
+ {
+ friend class connectivity::OSubComponent<OConnection, OConnection_BASE>;
+
+ protected:
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning; // Last SQLWarning generated by
+ // an operation
+ MozabDriver* m_pDriver; // Pointer to the owning
+ // driver object
+ ::std::auto_ptr< ConnectionImplData > m_pImplData;
+ // This is to be able to hold a boost::shared_ptr. If we would hold it as member, it would
+ // not compile the mozillasrc directory, since this directory is compiled without RTTI support
+ // and boost seems to require RTTI on some platforms.
+ // Store Catalog
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> m_xCatalog;
+ // Start of Additions from the land of mozilla
+ OColumnAlias m_aColumnAlias;
+ rtl::OUString m_sMozillaURI;
+ rtl::OUString m_sMozillaProfile;
+ sal_Int32 m_nMaxResultRecords;
+ MNameMapper* m_aNameMapper;
+ //LDAP only
+ rtl::OUString m_sHostName;
+ sal_Bool m_bUseSSL;
+ rtl::OUString m_sBindDN;
+ rtl::OUString m_sUser; // the user name
+ rtl::OUString m_sPassword;
+
+ SDBCAddress::sdbc_address_type m_eSDBCAddressType;
+
+ sal_Bool m_bForceLoadTable;
+
+ public:
+ virtual void construct( const ::rtl::OUString& url,const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info) throw(::com::sun::star::sdbc::SQLException);
+ OConnection(MozabDriver* _pDriver);
+ virtual ~OConnection();
+
+ void closeAllStatements () throw( ::com::sun::star::sdbc::SQLException);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual void SAL_CALL release() throw();
+
+ // XServiceInfo
+ DECLARE_SERVICE_INFO();
+ // XConnection
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XStatement > SAL_CALL createStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareStatement( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XPreparedStatement > SAL_CALL prepareCall( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL nativeSQL( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setAutoCommit( sal_Bool autoCommit ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getAutoCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL commit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL rollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isClosed( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setReadOnly( sal_Bool readOnly ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCatalog( const ::rtl::OUString& catalog ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalog( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTransactionIsolation( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess > SAL_CALL getTypeMap( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTypeMap( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ //
+ MozabDriver* getDriver() const { return m_pDriver;}
+
+ // Added to enable me to use SQLInterpreter which requires an
+ // XNameAccess i/f to access tables.
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier > SAL_CALL createCatalog();
+
+
+ // Additions from the land of mozilla
+ rtl::OUString getMozURI() const { return m_sMozillaURI; }
+ rtl::OUString getMozProfile() const { return m_sMozillaProfile; }
+ void setMozProfile(rtl::OUString &aNewProfile) { m_sMozillaProfile = aNewProfile; }
+
+ ::com::sun::star::mozilla::MozillaProductType getProduct()
+ {
+ if (m_eSDBCAddressType == SDBCAddress::ThunderBird)
+ return ::com::sun::star::mozilla::MozillaProductType_Thunderbird;
+ return ::com::sun::star::mozilla::MozillaProductType_Mozilla;
+ }
+
+ // Get Ldap BindDN (user name)
+ rtl::OUString getBindDN() const { return m_sBindDN; }
+ // Get Ldap Password
+ rtl::OUString getPassword() const { return m_sPassword; }
+ // Get Ldap Host name
+ rtl::OUString getHost() const { return m_sHostName; }
+ // Get whether use ssl to connect to ldap
+ sal_Bool getUseSSL() const {return m_bUseSSL;}
+
+ sal_Bool usesFactory(void) const { return (m_eSDBCAddressType == SDBCAddress::Outlook) || (m_eSDBCAddressType == SDBCAddress::OutlookExp); }
+ sal_Bool isLDAP(void) const { return m_eSDBCAddressType == SDBCAddress::LDAP; }
+ sal_Bool isThunderbird(void) const { return m_eSDBCAddressType == SDBCAddress::ThunderBird; }
+
+ sal_Bool isOutlookExpress() const { return m_eSDBCAddressType == SDBCAddress::OutlookExp;}
+ sal_Int32 getMaxResultRecords() const { return m_nMaxResultRecords; }
+
+ SDBCAddress::sdbc_address_type getSDBCAddressType() const { return m_eSDBCAddressType;}
+
+ const OColumnAlias & getColumnAlias() const { return (m_aColumnAlias); }
+
+ static ::rtl::OUString getDriverImplementationName();
+
+ MNameMapper* getNameMapper();
+ void setForceLoadTables(sal_Bool aForce){ m_bForceLoadTable = aForce;}
+ sal_Bool getForceLoadTables() { return m_bForceLoadTable;}
+
+ void throwSQLException( const ErrorDescriptor& _rError, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
+ void throwSQLException( const sal_uInt16 _nErrorResourceId, const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext );
+
+ private:
+ // make this private - clients should use throwSQLException instead
+ using OConnection_BASE::throwGenericSQLException;
+ };
+ }
+}
+#endif // CONNECTIVITY_SCONNECTION_HXX
+
diff --git a/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx b/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx
new file mode 100644
index 000000000000..48733bfac196
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MDatabaseMetaData.cxx
@@ -0,0 +1,1031 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MDatabaseMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/TransactionIsolation.hpp>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/FValue.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/ColumnSearch.hpp>
+#include "resource/common_res.hrc"
+#include <vector>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ static sal_Int32 const s_nCOLUMN_SIZE = 256;
+ static sal_Int32 const s_nDECIMAL_DIGITS = 0;
+ static sal_Int32 const s_nNULLABLE = 1;
+ static sal_Int32 const s_nCHAR_OCTET_LENGTH = 65535;
+ }
+}
+
+
+ODatabaseMetaData::ODatabaseMetaData(OConnection* _pCon)
+ : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_pConnection(_pCon)
+{
+ OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
+ m_pDbMetaDataHelper = new MDatabaseMetaDataHelper();
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+ delete m_pDbMetaDataHelper;
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ORows& SAL_CALL ODatabaseMetaData::getColumnRows(
+ const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException)
+{
+ static ODatabaseMetaDataResultSet::ORows aRows;
+ ODatabaseMetaDataResultSet::ORow aRow(19);
+ aRows.clear();
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::std::vector< ::rtl::OUString > tables;
+ ::std::vector< ::rtl::OUString > types;
+ if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types) ) {
+ getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
+ }
+
+ // ****************************************************
+ // Some entries in a row never change, so set them now
+ // ****************************************************
+
+ // Catalog
+ aRow[1] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
+ // Schema
+ aRow[2] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("")));
+ // DATA_TYPE
+ aRow[5] = new ORowSetValueDecorator(static_cast<sal_Int16>(DataType::VARCHAR));
+ // TYPE_NAME, not used
+ aRow[6] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR")));
+ // COLUMN_SIZE
+ aRow[7] = new ORowSetValueDecorator(s_nCOLUMN_SIZE);
+ // BUFFER_LENGTH, not used
+ aRow[8] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // DECIMAL_DIGITS.
+ aRow[9] = new ORowSetValueDecorator(s_nDECIMAL_DIGITS);
+ // NUM_PREC_RADIX
+ aRow[10] = new ORowSetValueDecorator((sal_Int32)10);
+ // NULLABLE
+ aRow[11] = new ORowSetValueDecorator(s_nNULLABLE);
+ // REMARKS
+ aRow[12] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // COULUMN_DEF, not used
+ aRow[13] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATA_TYPE, not used
+ aRow[14] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // SQL_DATETIME_SUB, not used
+ aRow[15] = ODatabaseMetaDataResultSet::getEmptyValue();
+ // CHAR_OCTET_LENGTH, refer to [5]
+ aRow[16] = new ORowSetValueDecorator(s_nCHAR_OCTET_LENGTH);
+ // IS_NULLABLE
+ aRow[18] = new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("YES")));
+
+ const OColumnAlias& colNames = m_pConnection->getColumnAlias();
+
+ // Iterate over all tables
+ for(size_t j = 0; j < tables.size(); j++ ) {
+ if(match(tableNamePattern, tables[j],'\0')) {
+ // TABLE_NAME
+ aRow[3] = new ORowSetValueDecorator( tables[j] );
+
+ OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables[j] ));
+
+ // Iterate over all collumns in the table.
+ for ( OColumnAlias::AliasMap::const_iterator compare = colNames.begin();
+ compare != colNames.end();
+ ++compare
+ )
+ {
+ if ( match( columnNamePattern, compare->first, '\0' ) )
+ {
+ OSL_TRACE( "\t\t\tColumnName = %s;\n", OUtoCStr( compare->first ) );
+ // COLUMN_NAME
+ aRow[4] = new ORowSetValueDecorator( compare->first );
+ // ORDINAL_POSITION
+ aRow[17] = new ORowSetValueDecorator( static_cast< sal_Int32 >( compare->second.columnPosition ) + 1 );
+ aRows.push_back(aRow);
+ }
+ }
+ }
+ }
+ return( aRows );
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 65535; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 254; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 20; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ // We only support a single table
+ return 1;
+}
+// -------------------------------------------------------------------------
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ // normally this is "
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("\""));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ //We support create table
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 /*level*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_True; // should be supported at least
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ return 0;// 0 means no limit
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ // We allow you to select from any table.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ //we support insert/update/delete now
+ //But we have to set this to return sal_True otherwise the UI will add create "table/edit table"
+ //entry to the popup menu. We should avoid them.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ // Support added for this.
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 /*fromType*/, sal_Int32 /*toType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ // Any case may be used
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return m_pConnection->getURL();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)1);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = ::rtl::OUString::valueOf((sal_Int32)0);
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ return TransactionIsolation::NONE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue = 0; // 0 means no limit
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 /*setType*/, sal_Int32 /*concurrency*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+// here follow all methods which return a resultset
+// the first methods is an example implementation how to use this resultset
+// of course you could implement it on your and you should do this because
+// the general way is more memory expensive
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+ // there exists no possibility to get table types so we have to check
+ static ::rtl::OUString sTableTypes[] =
+ {
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")),
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW"))
+ // Currently we only support a 'TABLE' and 'VIEW' nothing more complex
+ //
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEM TABLE")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("GLOBAL TEMPORARY")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("LOCAL TEMPORARY")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("ALIAS")),
+ // ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYNONYM"))
+ };
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+
+ // here we fill the rows which should be visible when ask for data from the resultset returned here
+ const sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
+ ODatabaseMetaDataResultSet::ORows aRows;
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(sTableTypes[i]));
+ // bound row
+ aRows.push_back(aRow);
+ }
+ // here we set the rows at the resultset
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTypeInfo);
+ Reference< XResultSet > xResultSet = pResultSet;
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ if(aRows.empty())
+ {
+ ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.reserve(19);
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VARCHAR"))));
+ aRow.push_back(new ORowSetValueDecorator(DataType::VARCHAR));
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)s_nCHAR_OCTET_LENGTH));
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getQuoteValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ // aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnValue::NULLABLE));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)ColumnSearch::CHAR));
+ aRow.push_back(ODatabaseMetaDataResultSet::get1Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::get0Value());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ORowSetValueDecorator((sal_Int32)10));
+
+ aRows.push_back(aRow);
+
+ }
+ pResultSet->setRows(aRows);
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eColumns);
+ Reference< XResultSet > xResultSet = pResultSet;
+ pResultSet->setRows( getColumnRows( tableNamePattern, columnNamePattern ));
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ // this returns an empty resultset where the column-names are already set
+ // in special the metadata of the resultset already returns the right columns
+ ODatabaseMetaDataResultSet* pResultSet = new ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTables);
+ Reference< XResultSet > xResultSet = pResultSet;
+
+ // ODatabaseMetaDataResultSet::ORows aRows;
+ // aRows = m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern );
+ // pResultSet->setRows( aRows );
+ ODatabaseMetaDataResultSet::ORows _rRows;
+ if ( !m_pDbMetaDataHelper->getTables( m_pConnection, tableNamePattern, types,_rRows ) ) {
+ getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
+ }
+ pResultSet->setRows( _rRows );
+
+ return xResultSet;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(ODatabaseMetaDataResultSet::eTablePrivileges);
+ Reference< XResultSet > xRef = NULL;
+
+ xRef = pResult;
+
+ ::std::vector< ::rtl::OUString > tables;
+ ::std::vector< ::rtl::OUString > types;
+ if ( !m_pDbMetaDataHelper->getTableStrings( m_pConnection, tables, types ) )
+ getOwnConnection()->throwSQLException( m_pDbMetaDataHelper->getError(), *this );
+
+ ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow(8);
+ aRows.reserve(8);
+ aRow[0] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[1] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[3] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[4] = ::connectivity::ODatabaseMetaDataResultSet::getEmptyValue();
+ aRow[5] = new ::connectivity::ORowSetValueDecorator(getUserName());
+ aRow[7] = new ::connectivity::ORowSetValueDecorator(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("NO")));
+
+
+ // Iterate over all tables
+ for(size_t j = 0; j < tables.size(); j++ ) {
+ if(match(tableNamePattern, tables[j],'\0'))
+ {
+ // TABLE_NAME
+ aRow[2] = new ORowSetValueDecorator( tables[j] );
+
+ OSL_TRACE( "\t\tTableName = %s;\n",OUtoCStr( tables[j] ));
+
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getSelectValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getInsertValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDeleteValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getUpdateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getCreateValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getReadValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getAlterValue();
+ aRows.push_back(aRow);
+ aRow[6] = ::connectivity::ODatabaseMetaDataResultSet::getDropValue();
+ aRows.push_back(aRow);
+ }
+ }
+ pResult->setRows(aRows);
+ return xRef;
+
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx b/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx
new file mode 100644
index 000000000000..883fc339be80
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MDatabaseMetaData.hxx
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SDATABASEMETADATA_HXX
+#define CONNECTIVITY_SDATABASEMETADATA_HXX
+#include "MConnection.hxx"
+#include "mozillasrc/MDatabaseMetaDataHelper.hxx"
+#include "TDatabaseMetaDataBase.hxx"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ //**************************************************************
+ //************ Class: ODatabaseMetaData
+ //**************************************************************
+
+ class ODatabaseMetaData : public ODatabaseMetaDataBase
+ {
+ OConnection* m_pConnection;
+ MDatabaseMetaDataHelper* m_pDbMetaDataHelper;
+
+ ODatabaseMetaDataResultSet::ORows& SAL_CALL getColumnRows( const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw( ::com::sun::star::sdbc::SQLException );
+
+ protected:
+ virtual ~ODatabaseMetaData();
+ public:
+
+ inline OConnection* getOwnConnection() const { return m_pConnection; }
+
+ ODatabaseMetaData(OConnection* _pCon);
+
+ private:
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > impl_getTypeInfo_throw();
+ // cached database information
+ virtual ::rtl::OUString impl_getIdentifierQuoteString_throw( );
+ virtual sal_Bool impl_isCatalogAtStart_throw( );
+ virtual ::rtl::OUString impl_getCatalogSeparator_throw( );
+ virtual sal_Bool impl_supportsCatalogsInTableDefinitions_throw( );
+ virtual sal_Bool impl_supportsSchemasInTableDefinitions_throw( ) ;
+ virtual sal_Bool impl_supportsCatalogsInDataManipulation_throw( );
+ virtual sal_Bool impl_supportsSchemasInDataManipulation_throw( ) ;
+ virtual sal_Bool impl_supportsMixedCaseQuotedIdentifiers_throw( ) ;
+ virtual sal_Bool impl_supportsAlterTableWithAddColumn_throw( );
+ virtual sal_Bool impl_supportsAlterTableWithDropColumn_throw( );
+ virtual sal_Int32 impl_getMaxStatements_throw( );
+ virtual sal_Int32 impl_getMaxTablesInSelect_throw( );
+ virtual sal_Bool impl_storesMixedCaseQuotedIdentifiers_throw( );
+
+ // as I mentioned before this interface is really BIG
+ // XDatabaseMetaData
+ virtual sal_Bool SAL_CALL allProceduresAreCallable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL allTablesAreSelectable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getURL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getUserName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedHigh( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedLow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtStart( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullsAreSortedAtEnd( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDatabaseProductVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverName( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDriverVersion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDriverMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFiles( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL usesLocalFilePerTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesMixedCaseIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesUpperCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL storesLowerCaseQuotedIdentifiers( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSQLKeywords( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getNumericFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getStringFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSystemFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTimeDateFunctions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSearchStringEscape( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getExtraNameCharacters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsColumnAliasing( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL nullPlusNonNullIsNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTypeConversion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDifferentTableCorrelationNames( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExpressionsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOrderByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByUnrelated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsGroupByBeyondSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLikeEscapeClause( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleResultSets( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMultipleTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsNonNullableColumns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsMinimumSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCoreSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsExtendedSQLGrammar( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92EntryLevelSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92IntermediateSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsANSI92FullSQL( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsIntegrityEnhancementFacility( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsFullOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsLimitedOuterJoins( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProcedureTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogTerm( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSchemasInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInProcedureCalls( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInIndexDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCatalogsInPrivilegeDefinitions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedDelete( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsPositionedUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSelectForUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsStoredProcedures( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInComparisons( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInExists( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInIns( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsSubqueriesInQuantifieds( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsCorrelatedSubqueries( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnion( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsUnionAll( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenCursorsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsOpenStatementsAcrossRollback( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxBinaryLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCharLiteralLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInGroupBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInIndex( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInOrderBy( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInSelect( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxColumnsInTable( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxConnections( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCursorNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxIndexLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxSchemaNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxProcedureNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxCatalogNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxRowSize( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL doesMaxRowSizeIncludeBlobs( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxStatementLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxTableNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMaxUserNameLength( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getDefaultTransactionIsolation( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsTransactionIsolationLevel( sal_Int32 level ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataDefinitionAndDataManipulationTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsDataManipulationTransactionsOnly( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionCausesTransactionCommit( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL dataDefinitionIgnoredInTransactions( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTables( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTableTypes( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getTablePrivileges( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getColumns( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual sal_Bool SAL_CALL supportsResultSetType( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL ownInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersUpdatesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersDeletesAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL othersInsertsAreVisible( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL updatesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL deletesAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL insertsAreDetected( sal_Int32 setType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsBatchUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getUDTs( const ::com::sun::star::uno::Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& typeNamePattern, const ::com::sun::star::uno::Sequence< sal_Int32 >& types ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SDATABASEMETADATA_HXX
diff --git a/connectivity/source/drivers/mozab/MDriver.cxx b/connectivity/source/drivers/mozab/MDriver.cxx
new file mode 100644
index 000000000000..b0757a201844
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MDriver.cxx
@@ -0,0 +1,329 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MDriver.hxx"
+#include "MConnection.hxx"
+#include "connectivity/dbexception.hxx"
+#include "resource/mozab_res.hrc"
+#include "resource/common_res.hrc"
+
+#include <tools/solar.h>
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace connectivity::mozab;
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ //------------------------------------------------------------------
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL MozabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+ {
+ return *(new MozabDriver( _rxFactory ));
+ }
+ }
+}
+// --------------------------------------------------------------------------------
+MozabDriver::MozabDriver(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : ODriver_BASE(m_aMutex), m_xMSFactory( _rxFactory )
+ ,m_hModule(NULL)
+ ,m_pCreationFunc(NULL)
+{
+}
+// -----------------------------------------------------------------------------
+MozabDriver::~MozabDriver()
+{
+}
+// --------------------------------------------------------------------------------
+void MozabDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ // when driver will be destroied so all our connections have to be destroied as well
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+ connectivity::OWeakRefArray().swap(m_xConnections); // this really clears
+
+ ODriver_BASE::disposing();
+ if(m_hModule)
+ {
+ m_pCreationFunc = NULL;
+ osl_unloadModule(m_hModule);
+ m_hModule = NULL;
+ }
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString MozabDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii(MOZAB_DRIVER_IMPL_NAME);
+ // this name is referenced in the configuration and in the mozab.xml
+ // Please take care when changing it.
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > MozabDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.sdbc.Driver
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.Driver"));
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL MozabDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL MozabDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL MozabDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL MozabDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( !ensureInit() )
+ return NULL;
+
+ if ( ! acceptsURL( url ) )
+ return NULL;
+ // create a new connection with the given properties and append it to our vector
+ Reference< XConnection > xCon;
+ if (m_pCreationFunc)
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+ //We must make sure we create an com.sun.star.mozilla.MozillaBootstrap brfore call any mozilla codes
+ Reference<XInterface> xInstance = m_xMSFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+
+ OConnection* pCon = reinterpret_cast<OConnection*>((*m_pCreationFunc)(this));
+ xCon = pCon; // important here because otherwise the connection could be deleted inside (refcount goes -> 0)
+ pCon->construct(url,info); // late constructor call which can throw exception and allows a correct dtor call when so
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ }
+ else
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(
+ STR_COULD_NOT_LOAD_LIB,
+ "$libname$", ::rtl::OUString::createFromAscii( SVLIBRARY( "mozabdrv" ) )
+ ) );
+
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL MozabDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ if ( !ensureInit() )
+ return sal_False;
+
+ // here we have to look if we support this url format
+ return impl_classifyURL(url) != Unknown;
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL MozabDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( !ensureInit() )
+ return Sequence< DriverPropertyInfo >();
+
+ if ( acceptsURL(url) )
+ {
+ if ( impl_classifyURL(url) != LDAP )
+ return Sequence< DriverPropertyInfo >();
+
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("BaseDN"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Base DN."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRowCount"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Records (max.)"))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("100"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ // if you have somthing special to say return it here :-)
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL MozabDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1; // depends on you
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL MozabDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0; // depends on you
+}
+// --------------------------------------------------------------------------------
+EDriverType MozabDriver::impl_classifyURL( const ::rtl::OUString& url )
+{
+ // Skip 'sdbc:mozab: part of URL
+ //
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aAddrbookURI(url.copy(nLen+1));
+ // Get Scheme
+ nLen = aAddrbookURI.indexOf(':');
+ ::rtl::OUString aAddrbookScheme;
+ if ( nLen == -1 )
+ {
+ // There isn't any subschema: - but could be just subschema
+ if ( aAddrbookURI.getLength() > 0 )
+ aAddrbookScheme= aAddrbookURI;
+ else if(url == ::rtl::OUString::createFromAscii("sdbc:address:") )
+ return Unknown; // TODO check
+ else
+ return Unknown;
+ }
+ else
+ aAddrbookScheme = aAddrbookURI.copy(0, nLen);
+
+ struct __scheme_map
+ {
+ EDriverType eType;
+ const sal_Char* pScheme;
+ } aSchemeMap[] =
+ {
+#if defined(WNT) || defined(WIN)
+ { Outlook, "outlook" },
+ { OutlookExpress, "outlookexp" },
+#endif
+ { Mozilla, "mozilla" },
+ { ThunderBird, "thunderbird" },
+ { LDAP, "ldap" }
+ };
+
+ for ( size_t i=0; i < sizeof( aSchemeMap ) / sizeof( aSchemeMap[0] ); ++i )
+ {
+ if ( aAddrbookScheme.compareToAscii( aSchemeMap[i].pScheme ) == 0 )
+ return aSchemeMap[i].eType;
+ }
+
+ return Unknown;
+}
+
+// --------------------------------------------------------------------------------
+namespace
+{
+ template< typename FUNCTION >
+ void lcl_getFunctionFromModuleOrUnload( oslModule& _rModule, const sal_Char* _pAsciiSymbolName, FUNCTION& _rFunction )
+ {
+ _rFunction = NULL;
+ if ( _rModule )
+ {
+ const ::rtl::OUString sSymbolName = ::rtl::OUString::createFromAscii( _pAsciiSymbolName );
+ _rFunction = (FUNCTION)( osl_getFunctionSymbol( _rModule, sSymbolName.pData ) );
+
+ if ( !_rFunction )
+ { // did not find the symbol
+ OSL_ENSURE( false, ::rtl::OString( "lcl_getFunctionFromModuleOrUnload: could not find the symbol " ) + ::rtl::OString( _pAsciiSymbolName ) );
+ osl_unloadModule( _rModule );
+ _rModule = NULL;
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+extern "C" { static void SAL_CALL thisModule() {} }
+
+bool MozabDriver::ensureInit()
+{
+ if ( m_hModule )
+ return true;
+
+ OSL_ENSURE(NULL == m_pCreationFunc, "MozabDriver::ensureInit: inconsistence: already have a factory function!");
+
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(SVLIBRARY( "mozabdrv" ));
+
+ // load the mozabdrv library
+ m_hModule = osl_loadModuleRelative(&thisModule, sModuleName.pData, 0);
+ OSL_ENSURE(NULL != m_hModule, "MozabDriver::ensureInit: could not load the mozabdrv library!");
+ if ( !m_hModule )
+ return false;
+
+ OSetMozabServiceFactory pSetFactoryFunc( NULL );
+
+ lcl_getFunctionFromModuleOrUnload( m_hModule, "setMozabServiceFactory", pSetFactoryFunc );
+ lcl_getFunctionFromModuleOrUnload( m_hModule, "OMozabConnection_CreateInstance", m_pCreationFunc );
+
+ if ( !m_hModule )
+ // one of the symbols did not exist
+ return false;
+
+ if ( m_xMSFactory.is() )
+ {
+ // for purpose of transfer safety, the interface needs to be acuired once
+ // (will be release by the callee)
+ m_xMSFactory->acquire();
+ ( *pSetFactoryFunc )( m_xMSFactory.get() );
+ }
+
+ return true;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mozab/MDriver.hxx b/connectivity/source/drivers/mozab/MDriver.hxx
new file mode 100644
index 000000000000..bdf085e9d3a8
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MDriver.hxx
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SDRIVER_HXX
+#define CONNECTIVITY_SDRIVER_HXX
+
+#include <com/sun/star/sdbc/XDriver.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include "connectivity/CommonTools.hxx"
+#include <osl/module.h>
+
+
+#define MOZAB_DRIVER_IMPL_NAME "com.sun.star.comp.sdbc.MozabDriver"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL MozabDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception );
+
+ typedef void* (SAL_CALL * OMozabConnection_CreateInstanceFunction)(void* _pDriver );
+ typedef void (SAL_CALL * OSetMozabServiceFactory)( void* _pFactory );
+ typedef const void* (SAL_CALL * OGetSdbcScheme_Function)( short );
+
+
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::sdbc::XDriver,
+ ::com::sun::star::lang::XServiceInfo > ODriver_BASE;
+
+ enum EDriverType
+ {
+ Mozilla,
+ ThunderBird,
+ LDAP,
+ Outlook,
+ OutlookExpress,
+ Unknown
+ };
+
+ class MozabDriver : public ODriver_BASE
+ {
+ protected:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xMSFactory;
+
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ connectivity::OWeakRefArray m_xConnections; // vector containing a list
+ // of all the Connection objects
+ // for this Driver
+ oslModule m_hModule;
+ OMozabConnection_CreateInstanceFunction m_pCreationFunc;
+ OGetSdbcScheme_Function m_pSchemeFunction;
+
+ bool ensureInit();
+ virtual ~MozabDriver();
+ public:
+
+ MozabDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XDriver
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL connect( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL acceptsURL( const ::rtl::OUString& url ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::sdbc::DriverPropertyInfo > SAL_CALL getPropertyInfo( const ::rtl::OUString& url, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& info ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMajorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getMinorVersion( ) throw(::com::sun::star::uno::RuntimeException);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ & getMSFactory(void) const { return m_xMSFactory; }
+
+ private:
+ EDriverType impl_classifyURL( const ::rtl::OUString& url );
+ };
+ }
+
+}
+
+#endif // CONNECTIVITY_SDRIVER_HXX
diff --git a/connectivity/source/drivers/mozab/MExtConfigAccess.hxx b/connectivity/source/drivers/mozab/MExtConfigAccess.hxx
new file mode 100644
index 000000000000..2292831dc388
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MExtConfigAccess.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECTIVITY_MOZAB_MEXTCONFIGACCESS_HXX
+
+// This is the extended version (for use on the SO side of the driver) of MConfigAccess
+// (which is for use on the mozilla side only)
+
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >
+ createDriverConfigNode( ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxORB );
+ }
+}
+
+#endif // CONNECTIVITY_MOZAB_MEXTCONFIGACCESS_HXX
+
diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.cxx b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
new file mode 100644
index 000000000000..5aad943b151a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MPreparedStatement.cxx
@@ -0,0 +1,544 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "MPreparedStatement.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "MResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include "diagnose_ex.h"
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::mozab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.mozab.PreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql)
+ :OCommonStatement(_pConnection)
+ ,m_nNumParams(0)
+ ,m_sSqlStatement(sql)
+ ,m_bPrepared(sal_False)
+ ,m_pResultSet()
+{
+}
+// -----------------------------------------------------------------------------
+OPreparedStatement::~OPreparedStatement()
+{
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::lateInit()
+{
+ if ( eSelect != parseSql( m_sSqlStatement ) )
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OCommonStatement::disposing();
+
+ m_xMetaData.clear();
+ if(m_aParameterRow.isValid())
+ {
+ m_aParameterRow->get().clear();
+ m_aParameterRow = NULL;
+ }
+ m_xParamColumns = NULL;
+}
+// -----------------------------------------------------------------------------
+
+OCommonStatement::StatementType OPreparedStatement::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted )
+ throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException )
+{
+ StatementType eStatementType = OCommonStatement::parseSql( sql, bAdjusted );
+ if ( eStatementType != eSelect )
+ return eStatementType;
+
+ m_xParamColumns = new OSQLColumns();
+
+ // describe all parameters need for the resultset
+ describeParameter();
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ OResultSet::setBoundedColumns( m_aRow, m_xParamColumns, xNames, sal_False, m_xDBMetaData, m_aColMapping );
+
+ return eStatementType;
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::initializeResultSet( OResultSet* _pResult )
+{
+ OCommonStatement::initializeResultSet( _pResult );
+ _pResult->setParameterColumns( m_xParamColumns );
+ _pResult->setParameterRow( m_aParameterRow );
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::clearCachedResultSet()
+{
+ OCommonStatement::clearCachedResultSet();
+ m_pResultSet.clear();
+ m_xMetaData.clear();
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult )
+{
+ OCommonStatement::cacheResultSet( _pResult );
+ OSL_PRECOND( m_pResultSet == NULL, "OPreparedStatement::parseSql: you should call clearCachedResultSet before!" );
+ m_pResultSet = _pResult;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OCommonStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OCommonStatement::release();
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPreparedStatement_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OCommonStatement::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ sal_Bool bReadOnly = sal_True;
+ if ( m_pResultSet.is() )
+ bReadOnly = m_pResultSet->determineReadOnly();
+ // if we do not have a result set, then we have not been executed, yet. In this case, assuming readonly=true is
+ // okay, /me thinks.
+
+ if ( !m_xMetaData.is() )
+ m_xMetaData = new OResultSetMetaData( m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,bReadOnly );
+
+ return m_xMetaData;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ Reference< XResultSet> xResult = executeQuery();
+ return xResult.is();
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("prepStmt::setString( %s )", OUtoCStr( x ) );
+ setParameter( parameterIndex, x );
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ OSL_TRACE("In: OPreparedStatement::executeQuery" );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ // our statement has already been parsed in lateInit, no need to do all this (potentially expensive)
+ // stuff again. Just execute.
+ return impl_executeCurrentQuery();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 /*parameterIndex*/, sal_Bool /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBoolean", *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 /*parameterIndex*/, sal_Int8 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setByte", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 /*parameterIndex*/, const Date& /*aData*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setDate", *this );
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 /*parameterIndex*/, const Time& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setTime", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 /*parameterIndex*/, const DateTime& /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setTimestamp", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 /*parameterIndex*/, double /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setDouble", *this );
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 /*parameterIndex*/, float /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setFloat", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 /*parameterIndex*/, sal_Int32 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setInt", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 /*parameterIndex*/, sal_Int64 /*aVal*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setLong", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 /*sqlType*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ checkAndResizeParameters(parameterIndex);
+
+ (m_aParameterRow->get())[parameterIndex].setNull();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 /*parameterIndex*/, const Reference< XClob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setClob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 /*parameterIndex*/, const Reference< XBlob >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBlob", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 /*parameterIndex*/, const Any& /*x*/, sal_Int32 /*sqlType*/, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setObjectWithInfo", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::implSetObject(this,parameterIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 /*parameterIndex*/, sal_Int16 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setShort", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 /*parameterIndex*/, const Sequence< sal_Int8 >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBytes", *this );
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setCharacterStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 /*parameterIndex*/, const Reference< ::com::sun::star::io::XInputStream >& /*x*/, sal_Int32 /*length*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XParameters::setBinaryStream", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ break;
+ default:
+ OCommonStatement::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkParameterIndex(sal_Int32 _parameterIndex)
+{
+ if( !_parameterIndex || _parameterIndex > m_nNumParams)
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkAndResizeParameters(sal_Int32 parameterIndex)
+{
+ ::connectivity::checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ if ( !m_aParameterRow.isValid() ) {
+ m_aParameterRow = new OValueVector();
+ m_aParameterRow->get().push_back(sal_Int32(0));
+ }
+
+ if ((sal_Int32)(m_aParameterRow->get()).size() <= parameterIndex)
+ (m_aParameterRow->get()).resize(parameterIndex+1);
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex, const
+ORowSetValue& x)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkAndResizeParameters(parameterIndex);
+
+ OSL_TRACE("setParameter( %d, '%s')", parameterIndex, OUtoCStr(x) );
+ (m_aParameterRow->get())[parameterIndex] = x;
+}
+
+//------------------------------------------------------------------
+sal_uInt32 OPreparedStatement::AddParameter(OSQLParseNode * pParameter, const Reference<XPropertySet>& _xCol)
+{
+ OSL_UNUSED( pParameter );
+ // Nr. des neu hinzuzufuegenden Parameters:
+ sal_uInt32 nParameter = m_xParamColumns->get().size()+1;
+
+ OSL_ENSURE(SQL_ISRULE(pParameter,parameter),"OResultSet::AddParameter: Argument ist kein Parameter");
+ OSL_ENSURE(pParameter->count() > 0,"OResultSet: Fehler im Parse Tree");
+#if OSL_DEBUG_LEVEL > 0
+ OSQLParseNode * pMark = pParameter->getChild(0);
+ OSL_UNUSED( pMark );
+#endif
+
+ ::rtl::OUString sParameterName;
+
+ // Parameter-Column aufsetzen:
+ sal_Int32 eType = DataType::VARCHAR;
+ sal_uInt32 nPrecision = 255;
+ sal_Int32 nScale = 0;
+ sal_Int32 nNullable = ColumnValue::NULLABLE;
+
+ if (_xCol.is())
+ {
+ // Typ, Precision, Scale ... der angegebenen Column verwenden,
+ // denn dieser Column wird der Wert zugewiesen bzw. mit dieser
+ // Column wird der Wert verglichen.
+ eType = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE)));
+ nPrecision = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+ nScale = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+ nNullable = getINT32(_xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+ _xCol->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= sParameterName;
+ }
+
+ Reference<XPropertySet> xParaColumn = new connectivity::sdbcx::OColumn(sParameterName
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,::rtl::OUString()
+ ,nNullable
+ ,nPrecision
+ ,nScale
+ ,eType
+ ,sal_False
+ ,sal_False
+ ,sal_False
+ ,m_pSQLIterator->isCaseSensitive());
+ m_xParamColumns->get().push_back(xParaColumn);
+ return nParameter;
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::describeColumn(OSQLParseNode*
+_pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable)
+{
+ Reference<XPropertySet> xProp;
+ if(SQL_ISRULE(_pNode,column_ref))
+ {
+ ::rtl::OUString sColumnName,sTableRange;
+ m_pSQLIterator->getColumnRange(_pNode,sColumnName,sTableRange);
+ if(sColumnName.getLength())
+ {
+ Reference<XNameAccess> xNameAccess = _xTable->getColumns();
+ if(xNameAccess->hasByName(sColumnName))
+ xNameAccess->getByName(sColumnName) >>= xProp;
+ AddParameter(_pParameter,xProp);
+ }
+ }
+ // else
+ // AddParameter(_pParameter,xProp);
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::describeParameter()
+{
+ ::std::vector< OSQLParseNode*> aParseNodes;
+ scanParameter(m_pParseTree,aParseNodes);
+ if(aParseNodes.size())
+ {
+ m_xParamColumns = new OSQLColumns();
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if(xTabs.size())
+ {
+ OSQLTable xTable = xTabs.begin()->second;
+ ::std::vector< OSQLParseNode*>::const_iterator aIter =
+aParseNodes.begin();
+ for (;aIter != aParseNodes.end();++aIter )
+ {
+ describeColumn(*aIter,(*aIter)->getParent()->getChild(0),xTable);
+ }
+ }
+ }
+}
+
+// -----------------------------------------------------------------------------
+void OPreparedStatement::scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes)
+{
+ OSL_ENSURE(pParseNode != NULL,"OResultSet: interner Fehler: ungueltiger ParseNode");
+
+ // Parameter Name-Regel gefunden?
+ if (SQL_ISRULE(pParseNode,parameter))
+ {
+ OSL_ENSURE(pParseNode->count() >= 1,"OResultSet: Parse Tree fehlerhaft");
+ OSL_ENSURE(pParseNode->getChild(0)->getNodeType() == SQL_NODE_PUNCTUATION,"OResultSet: Parse Tree fehlerhaft");
+
+ _rParaNodes.push_back(pParseNode);
+ // Weiterer Abstieg nicht erforderlich
+ return;
+ }
+
+ // Weiter absteigen im Parse Tree
+ for (sal_uInt32 i = 0; i < pParseNode->count(); i++)
+ scanParameter(pParseNode->getChild(i),_rParaNodes);
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL OPreparedStatement::getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OPreparedStatement::getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return 0;
+}
+// -----------------------------------------------------------------------------
+sal_Bool SAL_CALL OPreparedStatement::getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/mozab/MPreparedStatement.hxx b/connectivity/source/drivers/mozab/MPreparedStatement.hxx
new file mode 100644
index 000000000000..215b77307c38
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MPreparedStatement.hxx
@@ -0,0 +1,169 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+#define CONNECTIVITY_SPREPAREDSTATEMENT_HXX
+
+#ifndef CONNECTIVITY_SRESULTSET_HXX
+#include "MResultSet.hxx"
+#endif
+#include "MStatement.hxx"
+#include <com/sun/star/sdbc/XPreparedStatement.hpp>
+#include <com/sun/star/sdbc/XParameters.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/sdbc/XMultipleResults.hpp>
+#include <cppuhelper/compbase5.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ class OBoundParam;
+ typedef ::cppu::ImplHelper5< ::com::sun::star::sdbc::XPreparedStatement,
+ ::com::sun::star::sdbc::XParameters,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::sdbc::XMultipleResults,
+ ::com::sun::star::lang::XServiceInfo> OPreparedStatement_BASE;
+
+ class OPreparedStatement : public OCommonStatement,
+ public OPreparedStatement_BASE
+ {
+ protected:
+ struct Parameter
+ {
+ ::com::sun::star::uno::Any aValue;
+ sal_Int32 nDataType;
+
+ Parameter(const ::com::sun::star::uno::Any& rValue,
+ sal_Int32 rDataType) : aValue(rValue),nDataType(rDataType)
+ {
+ }
+
+ };
+
+ ::std::vector< Parameter> m_aParameters;
+ //====================================================================
+ // Data attributes
+ //====================================================================
+ sal_Int32 m_nNumParams; // Number of parameter markers
+ // for the prepared statement
+
+ ::rtl::OUString m_sSqlStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > m_xMetaData;
+ sal_Bool m_bPrepared;
+ ::rtl::Reference< OResultSet > m_pResultSet;
+ ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns; // the parameter columns
+ OValueRow m_aParameterRow;
+
+
+ void checkParameterIndex(sal_Int32 _parameterIndex);
+
+ protected:
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue)
+ throw (::com::sun::star::uno::Exception);
+ virtual ~OPreparedStatement();
+
+ virtual void SAL_CALL disposing();
+
+ // OCommonStatement overridables
+ virtual StatementType
+ parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ virtual void initializeResultSet( OResultSet* _pResult );
+ virtual void clearCachedResultSet();
+ virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult );
+
+
+ void checkAndResizeParameters(sal_Int32 parameterIndex);
+ void setParameter(sal_Int32 parameterIndex, const ORowSetValue& x);
+
+ sal_uInt32 AddParameter(connectivity::OSQLParseNode * pParameter,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xCol);
+ void scanParameter(OSQLParseNode* pParseNode,::std::vector< OSQLParseNode*>& _rParaNodes);
+ void describeColumn(OSQLParseNode* _pParameter,OSQLParseNode* _pNode,const OSQLTable& _xTable);
+ void describeParameter();
+
+ public:
+ DECLARE_SERVICE_INFO();
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql);
+ void lateInit();
+
+ //XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPreparedStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL executeUpdate( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL execute( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XParameters
+ virtual void SAL_CALL setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& typeName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setFloat( sal_Int32 parameterIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDouble( sal_Int32 parameterIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBytes( sal_Int32 parameterIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setDate( sal_Int32 parameterIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTime( sal_Int32 parameterIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setTimestamp( sal_Int32 parameterIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBinaryStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setCharacterStream( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObject( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setObjectWithInfo( sal_Int32 parameterIndex, const ::com::sun::star::uno::Any& x, sal_Int32 targetSqlType, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setRef( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setBlob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setClob( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL setArray( sal_Int32 parameterIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearParameters( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XMultipleResults
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL getResultSet( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getUpdateCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getMoreResults( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ public:
+ using OCommonStatement::executeQuery;
+ using OCommonStatement::executeUpdate;
+ using OCommonStatement::execute;
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+ }
+}
+#endif // CONNECTIVITY_SPREPAREDSTATEMENT_HXX
diff --git a/connectivity/source/drivers/mozab/MResultSet.cxx b/connectivity/source/drivers/mozab/MResultSet.cxx
new file mode 100644
index 000000000000..c7c85770419e
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MResultSet.cxx
@@ -0,0 +1,1980 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <connectivity/dbtools.hxx>
+
+#include <TSortIndex.hxx>
+#include <rtl/string.hxx>
+#include <vector>
+#include <algorithm>
+#include "MResultSet.hxx"
+#include "MResultSetMetaData.hxx"
+#include "FDatabaseMetaDataResultSet.hxx"
+#include "resource/mozab_res.hrc"
+#include "resource/common_res.hrc"
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::mozab;
+using namespace ::cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+//------------------------------------------------------------------------------
+// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
+::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException) \
+{
+ return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.mozab.ResultSet"));
+}
+// -------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.ResultSet"));
+ aSupported[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbcx.ResultSet"));
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< connectivity::OSQLParseTreeIterator >& _pSQLIterator )
+ : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_pStatement(pStmt)
+ ,m_xStatement(*pStmt)
+ ,m_xMetaData(NULL)
+ ,m_nRowPos(0)
+ ,m_nOldRowPos(0)
+ ,m_nFetchSize(0)
+ ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE)
+ ,m_nFetchDirection(FetchDirection::FORWARD)
+ ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE)
+ ,m_pSQLIterator( _pSQLIterator )
+ ,m_pParseTree( _pSQLIterator->getParseTree() )
+ ,m_aQuery( pStmt->getOwnConnection()->getColumnAlias() )
+ ,m_pTable(NULL)
+ ,m_CurrentRowCount(0)
+ ,m_nParamIndex(0)
+ ,m_bIsAlwaysFalseQuery(sal_False)
+ ,m_pKeySet(NULL)
+ ,m_nNewRow(0)
+ ,m_nUpdatedRow(0)
+ ,m_RowStates(0)
+ ,m_bIsReadOnly(-1)
+{
+
+ m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords());
+}
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+}
+
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_xStatement.clear();
+ m_xMetaData.clear();
+ m_pParseTree = NULL;
+ m_xColumns = NULL;
+ m_xParamColumns = NULL;
+ m_pKeySet = NULL;
+ if(m_pTable)
+ {
+ m_pTable->release();
+ m_pTable = NULL;
+ }
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OResultSet_BASE::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException)
+{
+ OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void OResultSet::methodEntry()
+{
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ if ( !m_pTable )
+ {
+ OSL_ENSURE( false, "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" );
+ throw DisposedException( ::rtl::OUString(), *this );
+ }
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // find the first column with the name columnName
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ m_bWasNull = sal_True;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Sequence< sal_Int8 >();
+}
+// -------------------------------------------------------------------------
+
+Date SAL_CALL OResultSet::getDate( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Date();
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0.0;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return 0;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos );
+ return m_nRowPos;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return sal_Int64();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(
+ m_pSQLIterator->getSelectColumns(), m_pSQLIterator->getTables().begin()->first ,m_pTable,determineReadOnly());
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+void OResultSet::checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException)
+{
+ if(columnIndex <= 0 || columnIndex > (sal_Int32)m_xColumns->get().size())
+ ::dbtools::throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_uInt32 OResultSet::currentRowCount()
+{
+ if ( m_bIsAlwaysFalseQuery )
+ return 0;
+ return m_aQuery.getRealRowCount() - deletedCount();
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool OResultSet::fetchCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("fetchCurrentRow, m_nRowPos = %u", m_nRowPos );
+ return fetchRow(getCurrentCardNumber());
+}
+
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::pushCard(sal_uInt32 cardNumber) throw(SQLException, RuntimeException)
+{
+ if (cardNumber == 0)
+ return sal_True;
+ // Check whether we are storing the updated row
+ if ( (m_aRow->get())[0].isNull() || (sal_Int32)(m_aRow->get())[0] != (sal_Int32)cardNumber )
+ return sal_False;
+
+ sal_Int32 nCount = m_aColumnNames.getLength();
+ m_aQuery.setRowStates(cardNumber,m_RowStates);
+ for( sal_Int32 i = 1; i <= nCount; i++ )
+ {
+ if ( (m_aRow->get())[i].isBound() )
+ {
+ //
+ // Everything in the addressbook is a string!
+ //
+ if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+ }
+ }
+ return sal_True;
+
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::fetchRow(sal_Int32 cardNumber,sal_Bool bForceReload) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("fetchRow, cardNumber = %u", cardNumber );
+ if (!bForceReload)
+ {
+ // Check whether we've already fetched the row...
+ if ( !(m_aRow->get())[0].isNull() && (sal_Int32)(m_aRow->get())[0] == (sal_Int32)cardNumber )
+ return sal_True;
+ //Check whether the old row has been changed
+ if (cardNumber == m_nUpdatedRow)
+ {
+ //write back the changes first
+ if (!pushCard(cardNumber)) //error write back the changes
+ throw SQLException();
+ }
+ }
+ else
+ m_aQuery.resyncRow(cardNumber);
+
+ if ( validRow( cardNumber ) == sal_False )
+ return sal_False;
+
+ (m_aRow->get())[0] = (sal_Int32)cardNumber;
+ sal_Int32 nCount = m_aColumnNames.getLength();
+ m_RowStates = m_aQuery.getRowStates(cardNumber);
+ for( sal_Int32 i = 1; i <= nCount; i++ )
+ {
+ if ( (m_aRow->get())[i].isBound() )
+ {
+ //
+ // Everything in the addressbook is a string!
+ //
+ if ( !m_aQuery.getRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+ }
+ }
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+const ORowSetValue& OResultSet::getValue(sal_Int32 cardNumber, sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ if ( fetchRow( cardNumber ) == sal_False )
+ {
+ OSL_ASSERT("fetchRow() returned False" );
+ m_bWasNull = sal_True;
+ return *ODatabaseMetaDataResultSet::getEmptyValue();
+ }
+
+ m_bWasNull = (m_aRow->get())[columnIndex].isNull();
+ return (m_aRow->get())[columnIndex];
+
+}
+// -------------------------------------------------------------------------
+
+
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_ENSURE(m_xColumns.isValid(), "Need the Columns!!");
+ OSL_ENSURE(columnIndex <= (sal_Int32)m_xColumns->get().size(), "Trying to access invalid columns number");
+ checkIndex( columnIndex );
+
+ // If this query was sorted then we should have a valid KeySet, so use it
+ return getValue(getCurrentCardNumber(), mapColumn( columnIndex ) );
+
+}
+// -------------------------------------------------------------------------
+
+Time SAL_CALL OResultSet::getTime( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return Time();
+}
+// -------------------------------------------------------------------------
+
+
+DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ return DateTime();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // here you have to implement your movements
+ // return true means there is no data
+ OSL_TRACE("In/Out: OResultSet::isBeforeFirst" );
+ return( m_nRowPos < 1 );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isAfterLast" );
+ return m_nRowPos > currentRowCount() && m_aQuery.queryComplete();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isFirst" );
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::isLast" );
+ return m_nRowPos == currentRowCount() && m_aQuery.queryComplete();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ // move before the first row so that isBeforeFirst returns false
+ OSL_TRACE("In/Out: OResultSet::beforeFirst" );
+ if ( first() )
+ previous();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::afterLast" );
+
+ if(last())
+ next();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::close" );
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::first" );
+ return seekRow( FIRST_POS );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::last" );
+ return seekRow( LAST_POS );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::absolute" );
+ return seekRow( ABSOLUTE_POS, row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::relative" );
+ return seekRow( RELATIVE_POS, row );
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::previous" );
+ return seekRow( PRIOR_POS );
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_TRACE("In/Out: OResultSet::getStatement" );
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates );
+ return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates );
+ return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates );
+ return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ return seekRow( NEXT_POS );
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("In/Out: OResultSet::cancel" );
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::clearWarnings" );
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::getWarnings" );
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("In/Out: OResultSet::refreshRow" );
+ if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW, *this );
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(5);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::convertFastPropertyValue(
+ Any & /*rConvertedValue*/,
+ Any & /*rOldValue*/,
+ sal_Int32 nHandle,
+ const Any& /*rValue*/ )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ OSL_ENSURE( false, "OResultSet::convertFastPropertyValue: not implemented!" );
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& /*rValue*/
+ )
+ throw (Exception)
+{
+ OSL_ENSURE( false, "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" );
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ case PROPERTY_ID_FETCHDIRECTION:
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OResultSet::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= (sal_Int32)m_nResultSetConcurrency;
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= m_nResultSetType;
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= m_nFetchDirection;
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= m_nFetchSize;
+ break;
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ const_cast< OResultSet* >( this )->determineReadOnly();
+ rValue <<= !m_bIsReadOnly;
+ break;
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void OResultSet::initializeRow(OValueRow& _rRow,sal_Int32 _nColumnCount)
+{
+ if(!_rRow.isValid())
+ {
+ _rRow = new OValueVector(_nColumnCount);
+ (_rRow->get())[0].setBound(sal_True);
+ ::std::for_each(_rRow->get().begin()+1,_rRow->get().end(),TSetBound(sal_False));
+ }
+}
+
+// -------------------------------------------------------------------------
+void OResultSet::parseParameter( const OSQLParseNode* pNode, rtl::OUString& rMatchString )
+{
+ OSL_ENSURE(pNode->count() > 0,"Error parsing parameter in Parse Tree");
+ OSQLParseNode *pMark = pNode->getChild(0);
+
+ // Initialize to empty string
+ rMatchString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+
+ rtl::OUString aParameterName;
+ if (SQL_ISPUNCTUATION(pMark,"?")) {
+ aParameterName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("?"));
+ }
+ else if (SQL_ISPUNCTUATION(pMark,":")) {
+ aParameterName = pNode->getChild(1)->getTokenValue();
+ }
+ // XXX - Now we know name, what's value????
+ m_nParamIndex ++;
+ OSL_TRACE("Parameter name [%d]: %s\n", m_nParamIndex,OUtoCStr(aParameterName) );
+
+ if ( m_aParameterRow.isValid() ) {
+ OSL_ENSURE( m_nParamIndex < (sal_Int32)m_aParameterRow->get().size() + 1, "More parameters than values found" );
+ rMatchString = (m_aParameterRow->get())[(sal_uInt16)m_nParamIndex];
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Prop Value : %s\n", OUtoCStr( rMatchString ) );
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE("Prop Value : Invalid ParameterRow!\n" );
+ }
+#endif
+}
+
+void OResultSet::analyseWhereClause( const OSQLParseNode* parseTree,
+ MQueryExpression &queryExpression)
+{
+ ::rtl::OUString columnName;
+ MQueryOp::cond_type op( MQueryOp::Is );
+ ::rtl::OUString matchString;
+
+ if ( parseTree == NULL )
+ return;
+
+ if ( m_pSQLIterator->getParseTree() != NULL ) {
+ ::vos::ORef<OSQLColumns> xColumns = m_pSQLIterator->getParameters();
+ if(xColumns.isValid())
+ {
+ ::rtl::OUString aTabName,aColName,aParameterName,aParameterValue;
+ OSQLColumns::Vector::iterator aIter = xColumns->get().begin();
+ sal_Int32 i = 1;
+ for(;aIter != xColumns->get().end();++aIter)
+ {
+ (*aIter)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME)) >>= aColName;
+ OSL_TRACE("Prop Column Name : %s\n", OUtoCStr( aColName ) );
+ if ( m_aParameterRow.isValid() ) {
+ aParameterValue = (m_aParameterRow->get())[(sal_uInt16)i];
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Prop Value : %s\n", OUtoCStr( aParameterValue ) );
+#endif
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE("Prop Value : Invalid ParameterRow!\n" );
+ }
+#endif
+ i++;
+ }
+ }
+
+ }
+
+ if ( SQL_ISRULE(parseTree,where_clause) )
+ {
+ OSL_TRACE("analyseSQL : Got WHERE clause\n");
+ // Reset Parameter Counter
+ resetParameters();
+ analyseWhereClause( parseTree->getChild( 1 ), queryExpression );
+ }
+ else if ( parseTree->count() == 3 && // Handle ()'s
+ SQL_ISPUNCTUATION(parseTree->getChild(0),"(") &&
+ SQL_ISPUNCTUATION(parseTree->getChild(2),")"))
+ {
+
+ OSL_TRACE("analyseSQL : Got Punctuation ()\n");
+ MQueryExpression *subExpression = new MQueryExpression();
+ analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
+ queryExpression.getExpressions().push_back( subExpression );
+ }
+ else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
+ && parseTree->count() == 3) // Handle AND/OR
+ {
+
+ OSL_TRACE("analyseSQL : Got AND/OR clause\n");
+
+ // TODO - Need to take care or AND, for now match is always OR
+ analyseWhereClause( parseTree->getChild( 0 ), queryExpression );
+ analyseWhereClause( parseTree->getChild( 2 ), queryExpression );
+
+ if (SQL_ISTOKEN(parseTree->getChild(1),OR)) { // OR-Operator
+ queryExpression.setExpressionCondition( MQueryExpression::OR );
+ }
+ else if (SQL_ISTOKEN(parseTree->getChild(1),AND)) { // AND-Operator
+ queryExpression.setExpressionCondition( MQueryExpression::AND );
+ }
+ else {
+ OSL_ASSERT("analyseSQL: Error in Parse Tree");
+ }
+ }
+ else if (SQL_ISRULE(parseTree,comparison_predicate))
+ {
+ OSL_ENSURE(parseTree->count() == 3, "Error parsing COMPARE predicate");
+ if (!(SQL_ISRULE(parseTree->getChild(0),column_ref) ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_STRING ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_INTNUM ||
+ parseTree->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM ||
+ SQL_ISTOKEN(parseTree->getChild(2),TRUE) ||
+ SQL_ISTOKEN(parseTree->getChild(2),FALSE) ||
+ SQL_ISRULE(parseTree->getChild(2),parameter) ||
+ // odbc date
+ (SQL_ISRULE(parseTree->getChild(2),set_fct_spec) && SQL_ISPUNCTUATION(parseTree->getChild(2)->getChild(0),"{"))))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+
+ OSQLParseNode *pPrec = parseTree->getChild(1);
+ if (pPrec->getNodeType() == SQL_NODE_EQUAL)
+ op = MQueryOp::Is;
+ else if (pPrec->getNodeType() == SQL_NODE_NOTEQUAL)
+ op = MQueryOp::IsNot;
+
+ ::rtl::OUString sTableRange;
+ if(SQL_ISRULE(parseTree->getChild(0),column_ref))
+ m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
+ else if(parseTree->getChild(0)->isToken())
+ columnName = parseTree->getChild(0)->getTokenValue();
+
+ if ( SQL_ISRULE(parseTree->getChild(2),parameter) ) {
+ parseParameter( parseTree->getChild(2), matchString );
+ }
+ else {
+ matchString = parseTree->getChild(2)->getTokenValue();
+ }
+
+ if ( columnName.compareToAscii("0") ==0 && op == MQueryOp::Is &&
+ matchString.compareToAscii("1") == 0 ) {
+ OSL_TRACE("Query always evaluates to FALSE");
+ m_bIsAlwaysFalseQuery = sal_True;
+ }
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+ }
+ else if (SQL_ISRULE(parseTree,like_predicate))
+ {
+ OSL_ENSURE(parseTree->count() == 2, "Error parsing LIKE predicate");
+
+ OSL_TRACE("analyseSQL : Got LIKE rule\n");
+
+ if ( !(SQL_ISRULE(parseTree->getChild(0), column_ref)) )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN, *this );
+ }
+
+
+ OSQLParseNode *pColumn;
+ OSQLParseNode *pAtom;
+ OSQLParseNode *pOptEscape;
+ const OSQLParseNode* pPart2 = parseTree->getChild(1);
+ pColumn = parseTree->getChild(0); // Match Item
+ pAtom = pPart2->getChild(parseTree->count()-2); // Match String
+ pOptEscape = pPart2->getChild(parseTree->count()-1); // Opt Escape Rule
+ const bool bNot = SQL_ISTOKEN(pPart2->getChild(0), NOT);
+
+ if (!(pAtom->getNodeType() == SQL_NODE_STRING ||
+ pAtom->getNodeType() == SQL_NODE_NAME ||
+ SQL_ISRULE(pAtom,parameter) ||
+ ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_NAME ) ||
+ ( pAtom->getChild(0) && pAtom->getChild(0)->getNodeType() == SQL_NODE_STRING )
+ ) )
+ {
+ OSL_TRACE("analyseSQL : pAtom->count() = %d\n", pAtom->count() );
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING, *this );
+ }
+
+ const sal_Unicode WILDCARD = '%';
+ const sal_Unicode ALT_WILDCARD = '*';
+ const sal_Unicode MATCHCHAR = '_';
+
+ ::rtl::OUString sTableRange;
+ if(SQL_ISRULE(pColumn,column_ref))
+ m_pSQLIterator->getColumnRange(pColumn,columnName,sTableRange);
+
+ OSL_TRACE("ColumnName = %s\n", OUtoCStr( columnName ) );
+
+ if ( SQL_ISRULE(pAtom,parameter) ) {
+ parseParameter( pAtom, matchString );
+ // Replace all '*' with '%' : UI Usually does this but not with
+ // Parameters for some reason.
+ matchString = matchString.replace( ALT_WILDCARD, WILDCARD );
+ }
+ else
+ {
+ matchString = pAtom->getTokenValue();
+ }
+
+ // Determine where '%' character is...
+
+ if ( matchString.equals( ::rtl::OUString::valueOf( WILDCARD ) ) )
+ {
+ // String containing only a '%' and nothing else
+ op = MQueryOp::Exists;
+ // Will be ignored for Exists case, but clear anyway.
+ matchString = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(""));
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == -1 &&
+ matchString.indexOf ( MATCHCHAR ) == -1 )
+ {
+ // Simple string , eg. "to match"
+ if ( bNot )
+ op = MQueryOp::DoesNotContain;
+ else
+ op = MQueryOp::Contains;
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == 0
+ && matchString.lastIndexOf ( WILDCARD ) == matchString.getLength() -1
+ && matchString.indexOf ( WILDCARD, 1 ) == matchString.lastIndexOf ( WILDCARD )
+ && matchString.indexOf( MATCHCHAR ) == -1
+ )
+ {
+ // Relatively simple "%string%" - ie, contains...
+ // Cut '%' from front and rear
+ matchString = matchString.replaceAt( 0, 1, rtl::OUString() );
+ matchString = matchString.replaceAt( matchString.getLength() -1 , 1, rtl::OUString() );
+
+ if (bNot)
+ op = MQueryOp::DoesNotContain;
+ else
+ op = MQueryOp::Contains;
+ }
+ else if ( bNot )
+ {
+ // We currently can't handle a 'NOT LIKE' when there are '%' or
+ // '_' dispersed throughout
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX, *this );
+ }
+ else
+ {
+ if ( (matchString.indexOf ( WILDCARD ) == matchString.lastIndexOf ( WILDCARD ))
+ && matchString.indexOf( MATCHCHAR ) == -1
+ )
+ {
+ // One occurance of '%' - no '_' matches...
+ if ( matchString.indexOf ( WILDCARD ) == 0 )
+ {
+ op = MQueryOp::EndsWith;
+ matchString = matchString.replaceAt( 0, 1, rtl::OUString());
+ }
+ else if ( matchString.indexOf ( WILDCARD ) == matchString.getLength() -1 )
+ {
+ op = MQueryOp::BeginsWith;
+ matchString = matchString.replaceAt( matchString.getLength() -1 , 1, rtl::OUString() );
+ }
+ else
+ {
+ sal_Int32 pos = matchString.indexOf ( WILDCARD );
+ matchString = matchString.replaceAt( pos, 1,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".*")) );
+ op = MQueryOp::RegExp;
+ }
+
+ }
+ else
+ {
+ // Most Complex, need to use an RE
+ sal_Int32 pos = matchString.indexOf ( WILDCARD );
+ while ( (pos = matchString.indexOf ( WILDCARD )) != -1 )
+ {
+ matchString = matchString.replaceAt( pos, 1, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".*")) );
+ }
+
+ pos = matchString.indexOf ( MATCHCHAR );
+ while ( (pos = matchString.indexOf( MATCHCHAR )) != -1 )
+ {
+ matchString = matchString.replaceAt( pos, 1, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(".")) );
+ }
+
+ op = MQueryOp::RegExp;
+ }
+ }
+
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
+ }
+ else if (SQL_ISRULE(parseTree,test_for_null))
+ {
+ OSL_ENSURE(parseTree->count() == 2,"Error in ParseTree");
+ const OSQLParseNode* pPart2 = parseTree->getChild(1);
+ OSL_ENSURE(SQL_ISTOKEN(pPart2->getChild(0),IS),"Error in ParseTree");
+
+ if (!SQL_ISRULE(parseTree->getChild(0),column_ref))
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN, *this );
+ }
+
+ if (SQL_ISTOKEN(pPart2->getChild(1),NOT))
+ {
+ op = MQueryOp::Exists;
+ }
+ else
+ op = MQueryOp::DoesNotExist;
+
+ ::rtl::OUString sTableRange;
+ m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
+
+ queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op ));
+ }
+ else
+ {
+ OSL_TRACE( "Unexpected statement!!!" );
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+
+void OResultSet::fillRowData()
+ throw( ::com::sun::star::sdbc::SQLException )
+{
+ OSL_ENSURE( m_pStatement, "Require a statement" );
+
+ MQueryExpression queryExpression;
+
+ OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
+ m_xColumns = m_pSQLIterator->getSelectColumns();
+
+ OSL_ENSURE(m_xColumns.isValid(), "Need the Columns!!");
+
+ OSQLColumns::Vector::const_iterator aIter = m_xColumns->get().begin();
+ const ::rtl::OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ ::rtl::OUString sName;
+ m_aAttributeStrings.clear();
+ m_aAttributeStrings.reserve(m_xColumns->get().size());
+ for (sal_Int32 i = 1; aIter != m_xColumns->get().end();++aIter, i++)
+ {
+ (*aIter)->getPropertyValue(sProprtyName) >>= sName;
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Query Columns : (%d) %s\n", i, OUtoCStr(sName) );
+#endif
+ m_aAttributeStrings.push_back( sName );
+ }
+
+
+ // Generate Match Conditions for Query
+ const OSQLParseNode* pParseTree = m_pSQLIterator->getWhereTree();
+
+ // const OSQLParseNode* pParseTree = NULL;
+
+ m_bIsAlwaysFalseQuery = sal_False;
+ if ( pParseTree != NULL )
+ {
+ // Extract required info
+
+ OSL_TRACE("\tHave a Where Clause\n");
+
+ analyseWhereClause( pParseTree, queryExpression );
+ }
+ else
+ {
+ OSL_TRACE("\tDon't have a Where Clause\n");
+
+ MQueryExpression::ExprVector eVector;
+
+ // LDAP does not allow a query without restriction, so we add a dummy
+ // for PrimaryEmail
+ // For other types we stick to the old behaviour of using
+ // card:nsIAbCard.
+ OSL_ENSURE(m_pStatement, "Cannot determine Parent Statement");
+ ::rtl::OUString aStr;
+ if (xConnection->isLDAP())
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("PrimaryEmail"));
+ else
+ aStr = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("card:nsIAbCard"));
+ eVector.push_back( new MQueryExpressionString(aStr, MQueryOp::Exists) );
+
+ queryExpression.setExpressions( eVector );
+ }
+
+ // If the query is a 0=1 then set Row count to 0 and return
+ if ( m_bIsAlwaysFalseQuery )
+ {
+ m_bIsReadOnly = 1;
+ return;
+ }
+
+ m_aQuery.setExpression( queryExpression );
+
+ rtl::OUString aStr( m_pTable->getName() );
+ m_aQuery.setAddressbook( aStr );
+
+ sal_Int32 rv = m_aQuery.executeQuery(xConnection);
+ if ( rv == -1 ) {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
+ }
+ //determine whether the address book is readonly
+ determineReadOnly();
+
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "executeQuery returned %d\n", rv );
+
+ OSL_TRACE( "\tOUT OResultSet::fillRowData()\n" );
+#endif
+}
+
+// -----------------------------------------------------------------------------
+static sal_Bool matchRow( OValueRow& row1, OValueRow& row2 )
+{
+ OValueVector::Vector::iterator row1Iter = row1->get().begin();
+ OValueVector::Vector::iterator row2Iter = row2->get().begin();
+ for ( ++row1Iter,++row2Iter; // the first column is the bookmark column
+ row1Iter != row1->get().end(); ++row1Iter,++row2Iter)
+ {
+ if ( row1Iter->isBound())
+ {
+ // Compare values, if at anytime there's a mismatch return false
+ if ( !( (*row1Iter) == (*row2Iter) ) )
+ return sal_False;
+ }
+ }
+
+ // If we get to here the rows match
+ return sal_True;
+}
+sal_Int32 OResultSet::getRowForCardNumber(sal_Int32 nCardNum)
+{
+ OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", nCardNum );
+
+ if ( m_pKeySet.isValid() )
+ {
+ sal_Int32 nPos;
+ for(nPos=0;nPos < (sal_Int32)m_pKeySet->get().size();nPos++)
+ {
+ if (nCardNum == (m_pKeySet->get())[nPos])
+ {
+ OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos+1 );
+ return nPos+1;
+ }
+ }
+ }
+
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ OSL_ENSURE( m_pTable, "Need a Table object");
+ if(!m_pTable)
+ {
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if ((xTabs.begin() == xTabs.end()) || !xTabs.begin()->second.is())
+ m_pStatement->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+
+ m_pTable = static_cast< OTable* > ((xTabs.begin()->second).get());
+
+ }
+
+ m_nRowPos = 0;
+
+ fillRowData();
+
+ OSL_ENSURE(m_xColumns.isValid(), "Need the Columns!!");
+
+ // sal_Int32 nColumnCount = m_xColumns->size();
+ // initializeRow(m_aRow,nColumnCount);
+ // initializeRow(m_aEvaluateRow,nColumnCount);
+
+ switch( m_pSQLIterator->getStatementType() )
+ {
+ case SQL_STATEMENT_SELECT:
+ {
+ if(m_bIsAlwaysFalseQuery) {
+ break;
+ }
+ else if(isCount())
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT, *this );
+ }
+ else
+ {
+ sal_Bool bDistinct = sal_False;
+ sal_Bool bWasSorted = sal_False;
+ OSQLParseNode *pDistinct = m_pParseTree->getChild(1);
+ if (pDistinct && pDistinct->getTokenID() == SQL_TOKEN_DISTINCT)
+ {
+ if(!IsSorted())
+ {
+ m_aOrderbyColumnNumber.push_back(m_aColMapping[1]);
+ m_aOrderbyAscending.push_back(SQL_DESC);
+ }
+ else
+ bWasSorted = sal_True;
+ bDistinct = sal_True;
+ }
+
+ OSortIndex::TKeyTypeVector eKeyType(m_aOrderbyColumnNumber.size());
+ ::std::vector<sal_Int32>::iterator aOrderByIter = m_aOrderbyColumnNumber.begin();
+ for ( ::std::vector<sal_Int16>::size_type i = 0; aOrderByIter != m_aOrderbyColumnNumber.end(); ++aOrderByIter,++i)
+ {
+ OSL_ENSURE((sal_Int32)m_aRow->get().size() > *aOrderByIter,"Invalid Index");
+ switch ((m_aRow->get().begin()+*aOrderByIter)->getTypeKind())
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ eKeyType[i] = SQL_ORDERBYKEY_STRING;
+ break;
+
+ case DataType::OTHER:
+ case DataType::TINYINT:
+ case DataType::SMALLINT:
+ case DataType::INTEGER:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ case DataType::DATE:
+ case DataType::TIME:
+ case DataType::TIMESTAMP:
+ case DataType::BIT:
+ eKeyType[i] = SQL_ORDERBYKEY_DOUBLE;
+ break;
+
+ // Andere Typen sind nicht implementiert (und damit immer
+ // FALSE)
+ default:
+ eKeyType[i] = SQL_ORDERBYKEY_NONE;
+ OSL_ASSERT("MResultSet::executeQuery: Order By Data Type not implemented");
+ break;
+ }
+ }
+
+ if (IsSorted())
+ {
+ // Implement Sorting
+
+ // So that we can sort we need to wait until the executed
+ // query to the mozilla addressbooks has returned all
+ // values.
+
+ OSL_TRACE("Query is to be sorted");
+ if( ! m_aQuery.queryComplete() )
+ if ( !m_aQuery.waitForQueryComplete() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+
+ OSL_ENSURE( m_aQuery.queryComplete(), "Query not complete!!");
+
+ m_pSortIndex = new OSortIndex(eKeyType,m_aOrderbyAscending);
+
+ OSL_TRACE("OrderbyColumnNumber->size() = %d",m_aOrderbyColumnNumber.size());
+#if OSL_DEBUG_LEVEL > 0
+ for ( ::std::vector<sal_Int32>::size_type i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+ for ( sal_Int32 nRow = 1; nRow <= m_aQuery.getRowCount(); nRow++ ) {
+
+ OKeyValue* pKeyValue = OKeyValue::createKeyValue((nRow));
+
+ ::std::vector<sal_Int32>::iterator aIter = m_aOrderbyColumnNumber.begin();
+ for (;aIter != m_aOrderbyColumnNumber.end(); ++aIter)
+ {
+ const ORowSetValue& value = getValue(nRow, *aIter);
+
+ OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow, *aIter,OUtoCStr( value ));
+
+ pKeyValue->pushKey(new ORowSetValueDecorator(value));
+ }
+
+ m_pSortIndex->AddKeyValue( pKeyValue );
+ }
+
+ m_pKeySet = m_pSortIndex->CreateKeySet();
+ m_CurrentRowCount = m_pKeySet->get().size();
+#if OSL_DEBUG_LEVEL > 0
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ OSL_TRACE("Sorted: %d -> %d", i, (m_pKeySet->get())[i] );
+#endif
+
+ m_pSortIndex = NULL;
+ beforeFirst(); // Go back to start
+ }
+ else //we always need m_pKeySet now
+ m_pKeySet = new OKeySet();
+
+ // Handle the DISTINCT case
+ if ( bDistinct && m_pKeySet.isValid() )
+ {
+ OValueRow aSearchRow = new OValueVector( m_aRow->get().size() );
+
+ for( OKeySet::Vector::size_type i = 0; i < m_pKeySet->get().size(); i++ )
+ {
+ fetchRow( (m_pKeySet->get())[i] ); // Fills m_aRow
+ if ( matchRow( m_aRow, aSearchRow ) )
+ {
+ (m_pKeySet->get())[i] = 0; // Marker for later to be removed
+ }
+ else
+ {
+ // They don't match, so it's not a duplicate.
+ // Use the current Row as the next one to match against
+ *aSearchRow = *m_aRow;
+ }
+ }
+ // Now remove any keys marked with a 0
+ m_pKeySet->get().erase(::std::remove_if(m_pKeySet->get().begin(),m_pKeySet->get().end()
+ ,::std::bind2nd(::std::equal_to<sal_Int32>(),0))
+ ,m_pKeySet->get().end());
+
+ }
+ }
+ } break;
+
+ case SQL_STATEMENT_UPDATE:
+ case SQL_STATEMENT_DELETE:
+ case SQL_STATEMENT_INSERT:
+ break;
+ default:
+ m_pStatement->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED, *this );
+ break;
+ }
+}
+
+// -----------------------------------------------------------------------------
+
+void OResultSet::setBoundedColumns(const OValueRow& _rRow,
+ const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,
+ const Reference<XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const Reference<XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping)
+{
+ ::comphelper::UStringMixEqual aCase(_xMetaData->storesMixedCaseQuotedIdentifiers());
+
+ Reference<XPropertySet> xTableColumn;
+ ::rtl::OUString sTableColumnName, sSelectColumnRealName;
+
+ const ::rtl::OUString sName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ const ::rtl::OUString sRealName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME);
+
+ ::std::vector< ::rtl::OUString> aColumnNames;
+ aColumnNames.reserve(_rxColumns->get().size());
+ OValueVector::Vector::iterator aRowIter = _rRow->get().begin()+1;
+ for (sal_Int32 i=0; // the first column is the bookmark column
+ aRowIter != _rRow->get().end();
+ ++i, ++aRowIter
+ )
+ {
+ try
+ {
+ // get the table column and it's name
+ _xNames->getByIndex(i) >>= xTableColumn;
+ OSL_ENSURE(xTableColumn.is(), "OResultSet::setBoundedColumns: invalid table column!");
+ if (xTableColumn.is())
+ xTableColumn->getPropertyValue(sName) >>= sTableColumnName;
+ else
+ sTableColumnName = ::rtl::OUString();
+
+ // look if we have such a select column
+ // TODO: would like to have a O(log n) search here ...
+ sal_Int32 nColumnPos = 0;
+ for ( OSQLColumns::Vector::iterator aIter = _rxColumns->get().begin();
+ aIter != _rxColumns->get().end();
+ ++aIter,++nColumnPos
+ )
+ {
+ if ( nColumnPos < (sal_Int32)aColumnNames.size() )
+ sSelectColumnRealName = aColumnNames[nColumnPos];
+ else
+ {
+ if((*aIter)->getPropertySetInfo()->hasPropertyByName(sRealName))
+ (*aIter)->getPropertyValue(sRealName) >>= sSelectColumnRealName;
+ else
+ (*aIter)->getPropertyValue(sName) >>= sSelectColumnRealName;
+ aColumnNames.push_back(sSelectColumnRealName);
+ }
+
+ if (aCase(sTableColumnName, sSelectColumnRealName))
+ {
+ if(_bSetColumnMapping)
+ {
+ sal_Int32 nSelectColumnPos = aIter - _rxColumns->get().begin() + 1;
+ // the getXXX methods are 1-based ...
+ sal_Int32 nTableColumnPos = i + 1;
+ // get first table column is the bookmark column
+ // ...
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("Set Col Mapping: %d -> %d", nSelectColumnPos, nTableColumnPos );
+#endif
+ _rColMapping[nSelectColumnPos] = nTableColumnPos;
+ }
+
+ aRowIter->setBound(sal_True);
+ aRowIter->setTypeKind(DataType::VARCHAR);
+ }
+ }
+ }
+ catch (Exception&)
+ {
+ OSL_ENSURE(sal_False, "OResultSet::setBoundedColumns: caught an Exception!");
+ }
+ }
+}
+
+
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::isCount() const
+{
+ return (m_pParseTree &&
+ m_pParseTree->count() > 2 &&
+ SQL_ISRULE(m_pParseTree->getChild(2),scalar_exp_commalist) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0),derived_column) &&
+ SQL_ISRULE(m_pParseTree->getChild(2)->getChild(0)->getChild(0),general_set_fct) &&
+ m_pParseTree->getChild(2)->getChild(0)->getChild(0)->count() == 4
+ );
+}
+
+// -----------------------------------------------------------------------------
+//
+// Check for valid row in m_aQuery
+//
+sal_Bool OResultSet::validRow( sal_uInt32 nRow )
+{
+ sal_Int32 nNumberOfRecords = m_aQuery.getRealRowCount();
+
+ while ( nRow > (sal_uInt32)nNumberOfRecords && !m_aQuery.queryComplete() ) {
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("validRow: waiting...");
+#endif
+ m_aQuery.checkRowAvailable( nRow );
+ if ( m_aQuery.hadError() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+ nNumberOfRecords = m_aQuery.getRealRowCount();
+ }
+
+ if (( nRow == 0 ) ||
+ ( nRow > (sal_uInt32)nNumberOfRecords && m_aQuery.queryComplete()) ){
+ OSL_TRACE("validRow(%u): return False", nRow);
+ return sal_False;
+ }
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("validRow(%u): return True", nRow);
+#endif
+ return sal_True;
+}
+sal_Bool OResultSet::fillKeySet(sal_Int32 nMaxCardNumber)
+{
+ impl_ensureKeySet();
+ if (m_CurrentRowCount < nMaxCardNumber)
+ {
+ sal_Int32 nKeyValue;
+ if ( (sal_Int32)m_pKeySet->get().capacity() < nMaxCardNumber )
+ m_pKeySet->get().reserve(nMaxCardNumber + 20 );
+
+ for (nKeyValue = m_CurrentRowCount+1; nKeyValue <= nMaxCardNumber; nKeyValue ++)
+ m_pKeySet->get().push_back( nKeyValue );
+ m_CurrentRowCount = nMaxCardNumber;
+ }
+ return sal_True;
+}
+
+sal_Int32 OResultSet::deletedCount()
+{
+ impl_ensureKeySet();
+ return m_CurrentRowCount - m_pKeySet->get().size();
+
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::seekRow( eRowPosition pos, sal_Int32 nOffset )
+{
+ ResultSetEntryGuard aGuard( *this );
+ if ( !m_pKeySet.isValid() )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT, *this );
+
+ sal_Int32 nNumberOfRecords = m_aQuery.getRealRowCount();
+ sal_Int32 nRetrivedRows = currentRowCount();
+ sal_Int32 nCurPos = m_nRowPos;
+
+ OSL_TRACE("seekRow: nCurPos = %d", nCurPos );
+ switch( pos ) {
+ case NEXT_POS:
+ OSL_TRACE("seekRow: NEXT");
+ nCurPos++;
+ break;
+ case PRIOR_POS:
+ OSL_TRACE("seekRow: PRIOR");
+ if ( nCurPos > 0 )
+ nCurPos--;
+ break;
+
+ case FIRST_POS:
+ OSL_TRACE("seekRow: FIRST");
+ nCurPos = 1;
+ break;
+
+ case LAST_POS:
+ OSL_TRACE("seekRow: LAST");
+ nCurPos = nRetrivedRows;
+ break;
+ case ABSOLUTE_POS:
+ OSL_TRACE("seekRow: ABSOLUTE : %d", nOffset);
+ nCurPos = nOffset;
+ break;
+ case RELATIVE_POS:
+ OSL_TRACE("seekRow: RELATIVE : %d", nOffset);
+ nCurPos += sal_uInt32( nOffset );
+ break;
+ }
+
+ if ( nCurPos <= 0 ) {
+ m_nRowPos = 0;
+ OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
+ return sal_False;
+ }
+ sal_Int32 nCurCard = nCurPos;
+ if ( nCurPos < (sal_Int32)m_pKeySet->get().size() ) //The requested row is exist in m_pKeySet, so we just use it
+ {
+ nCurCard = (m_pKeySet->get())[nCurPos-1];
+ }
+ else //The requested row has not been retrived until now. We should get the right card for it.
+ nCurCard = nCurPos + deletedCount();
+
+ while ( nCurCard > nNumberOfRecords && !m_aQuery.queryComplete() ) {
+ m_aQuery.checkRowAvailable( nCurCard );
+ if ( m_aQuery.hadError() )
+ {
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+ nNumberOfRecords = m_aQuery.getRealRowCount();
+ }
+
+ if ( nCurCard > nNumberOfRecords && m_aQuery.queryComplete()) {
+ fillKeySet(nNumberOfRecords);
+ m_nRowPos = m_pKeySet->get().size() + 1;
+ OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos );
+ return sal_False;
+ }
+ //Insert new retrived items for later use
+ fillKeySet(nNumberOfRecords);
+ m_nRowPos = (sal_uInt32)nCurPos;
+ OSL_TRACE("seekRow: return True, m_nRowPos = %u", m_nRowPos );
+ fetchCurrentRow();
+ return sal_True;
+}
+// -----------------------------------------------------------------------------
+void OResultSet::setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping)
+{
+ m_aColMapping = _aColumnMapping;
+#if OSL_DEBUG_LEVEL > 0
+ for ( sal_uInt32 i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("Set Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+::com::sun::star::uno::Any OResultSet::getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+ OSL_ENSURE((!m_aRow->isDeleted()),"getBookmark called for deleted row");
+ return makeAny((sal_Int32)(m_aRow->get())[0]);
+}
+sal_Bool OResultSet::moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark) );
+ sal_Int32 nCardNum = comphelper::getINT32(bookmark);
+ m_nRowPos = getRowForCardNumber(nCardNum);
+ fetchCurrentRow();
+ return sal_True;
+}
+sal_Bool OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark),rows );
+ sal_Int32 nCardNum = comphelper::getINT32(bookmark);
+ m_nRowPos = getRowForCardNumber(nCardNum);
+ return seekRow(RELATIVE_POS,rows );
+}
+sal_Int32 OResultSet::compareBookmarks( const ::com::sun::star::uno::Any& lhs, const ::com::sun::star::uno::Any& rhs ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos );
+ sal_Int32 nFirst=0;
+ sal_Int32 nSecond=0;
+ sal_Int32 nResult=0;
+
+ if ( !( lhs >>= nFirst ) || !( rhs >>= nSecond ) )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK, *this );
+
+ if(nFirst < nSecond)
+ nResult = -1;
+ else if(nFirst > nSecond)
+ nResult = 1;
+ else
+ nResult = 0;
+
+ return nResult;
+}
+sal_Bool OResultSet::hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos );
+ return sal_True;
+}
+sal_Int32 OResultSet::hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos );
+ return comphelper::getINT32(bookmark);
+}
+
+sal_Int32 OResultSet::getCurrentCardNumber()
+{
+ if ( ( m_nRowPos == 0 ) || !m_pKeySet.isValid() )
+ return 0;
+ if (m_pKeySet->get().size() < m_nRowPos)
+ return 0;
+ return (m_pKeySet->get())[m_nRowPos-1];
+}
+void OResultSet::checkPendingUpdate() throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("checkPendingUpdate, m_nRowPos = %u", m_nRowPos );
+ const sal_Int32 nCurrentRow = getCurrentCardNumber();
+
+ if ((m_nNewRow && nCurrentRow != m_nNewRow)
+ || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COMMIT_ROW,
+ "$position$", ::rtl::OUString::valueOf(nCurrentRow)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+}
+void OResultSet::updateValue(sal_Int32 columnIndex ,const ORowSetValue& x) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+
+ checkPendingUpdate();
+
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aRow->get())[columnIndex].setBound(sal_True);
+ (m_aRow->get())[columnIndex] = x;
+ m_nUpdatedRow = getCurrentCardNumber();
+ m_RowStates = m_RowStates | RowStates_Updated;
+}
+// -----------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if ( fetchCurrentRow() == sal_False )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+ checkPendingUpdate();
+ checkIndex(columnIndex );
+ columnIndex = mapColumn(columnIndex);
+
+ (m_aRow->get())[columnIndex].setBound(sal_True);
+ (m_aRow->get())[columnIndex].setNull();
+ m_nUpdatedRow = getCurrentCardNumber();
+ m_RowStates = m_RowStates | RowStates_Updated;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateValue(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ updateBinaryStream(columnIndex,x,length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_UPDATEABLE,
+ "$position$", ::rtl::OUString::valueOf(columnIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ }
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ {
+ const ::rtl::OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_COLUMN_NOT_UPDATEABLE,
+ "$position$", ::rtl::OUString::valueOf(columnIndex)
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+}
+
+// XResultSetUpdate
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos );
+ m_RowStates = RowStates_Inserted;
+ updateRow();
+ m_nOldRowPos = 0;
+ m_nNewRow = 0;
+ m_aQuery.setRowStates(getCurrentCardNumber(),m_RowStates);
+ OSL_TRACE("insertRow out, m_nRowPos = %u", m_nRowPos );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("updateRow in, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ impl_ensureKeySet();
+
+ if (!m_nRowPos || m_pKeySet->get().size() < m_nRowPos )
+ m_pStatement->getOwnConnection()->throwSQLException( STR_INVALID_ROW_UPDATE, *this );
+
+ const sal_Int32 nCurrentCard = getCurrentCardNumber();
+
+ if (!pushCard(nCurrentCard))
+ {
+ m_RowStates = RowStates_Error;
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_CAN_NOT_SAVE, *this );
+ }
+
+ if (!m_aQuery.commitRow(nCurrentCard))
+ {
+ m_RowStates = RowStates_Error;
+ m_nUpdatedRow = 0;
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+ }
+
+ m_nUpdatedRow = 0;
+ fetchCurrentRow();
+ OSL_TRACE("updateRow out, m_nRowPos = %u", m_nRowPos );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("deleteRow, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ if (rowDeleted())
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ROW_ALREADY_DELETED, *this );
+
+ const sal_Int32 nCurrentRow = getCurrentCardNumber();
+ //fetchRow(nCurrentRow);
+ if (!nCurrentRow)
+ m_pStatement->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW, *this );
+
+ sal_Bool m_bRowDeleted = ( m_aQuery.deleteRow( nCurrentRow ) > 0 );
+ if (!m_bRowDeleted)
+ m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
+
+ m_aQuery.setRowStates(nCurrentRow,RowStates_Deleted);
+ m_pKeySet->get().erase(m_pKeySet->get().begin() + m_nRowPos -1);
+ m_RowStates = RowStates_Deleted;
+ OSL_TRACE("deleteRow out, m_nRowPos = %u", m_nRowPos );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("cancelRowUpdates, m_nRowPos = %u", m_nRowPos );
+ if (fetchRow(getCurrentCardNumber(),sal_True)) //force fetch current row will cause we lose all change to the current row
+ m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CANCEL_ROW_UPDATE, *this );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ OSL_TRACE("moveToInsertRow in, m_nRowPos = %u", m_nRowPos );
+ ResultSetEntryGuard aGuard( *this );
+ m_nOldRowPos = m_nRowPos;
+
+ if (!m_nNewRow) //no new row now, insert one
+ {
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ checkPendingUpdate();
+ if (rowUpdated())
+ {
+ if (m_nRowPos && !pushCard(getCurrentCardNumber()))
+ throw SQLException();
+ }
+ m_nNewRow = m_aQuery.createNewCard();
+ if (!m_nNewRow)
+ m_pStatement->getOwnConnection()->throwSQLException( STR_CAN_NOT_CREATE_ROW, *this );
+
+ m_RowStates = RowStates_Normal;
+ fillKeySet(m_nNewRow);
+ }
+ else
+ m_nUpdatedRow = 0;
+
+ m_nRowPos = m_pKeySet->get().size();
+ fetchCurrentRow();
+ OSL_TRACE("moveToInsertRow out, m_nRowPos = %u", m_nRowPos );
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ ResultSetEntryGuard aGuard( *this );
+ OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos );
+ if (rowInserted())
+ {
+ m_nRowPos = m_nOldRowPos;
+ fetchCurrentRow();
+ }
+}
+
+sal_Bool OResultSet::determineReadOnly()
+{
+ if (m_bIsReadOnly == -1)
+ {
+ OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
+ m_bIsReadOnly = !m_aQuery.isWritable(xConnection) || m_bIsAlwaysFalseQuery;
+ }
+
+ return m_bIsReadOnly != 0;
+}
+
+void OResultSet::setTable(OTable* _rTable)
+{
+ OSL_TRACE("In : setTable");
+ m_pTable = _rTable;
+ m_pTable->acquire();
+ m_xTableColumns = m_pTable->getColumns();
+ if(m_xTableColumns.is())
+ m_aColumnNames = m_xTableColumns->getElementNames();
+ OSL_TRACE("Out : setTable");
+}
+
+void OResultSet::setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy)
+{
+ m_aOrderbyColumnNumber = _aColumnOrderBy;
+}
+
+void OResultSet::setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc)
+{
+ m_aOrderbyAscending = _aOrderbyAsc;
+}
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& /*rows*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
+ return Sequence< sal_Int32 >();
+};
diff --git a/connectivity/source/drivers/mozab/MResultSet.hxx b/connectivity/source/drivers/mozab/MResultSet.hxx
new file mode 100644
index 000000000000..d089d827168e
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MResultSet.hxx
@@ -0,0 +1,366 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SRESULTSET_HXX
+#define CONNECTIVITY_SRESULTSET_HXX
+
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSetMetaDataSupplier.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/XColumnLocate.hpp>
+#include <com/sun/star/util/XCancellable.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XResultSetUpdate.hpp>
+#include <com/sun/star/sdbcx/XRowLocate.hpp>
+#include <com/sun/star/sdbcx/XDeleteRows.hpp>
+#include <com/sun/star/sdbc/XRowUpdate.hpp>
+#include <cppuhelper/compbase12.hxx>
+#include <comphelper/proparrhlp.hxx>
+#include "MStatement.hxx"
+#include "connectivity/CommonTools.hxx"
+#include "connectivity/FValue.hxx"
+#include "connectivity/sqliterator.hxx"
+#include "TSortIndex.hxx"
+#include "mozillasrc/MQuery.hxx"
+
+
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ /*
+ ** java_sql_ResultSet
+ */
+ typedef ::cppu::WeakComponentImplHelper12< ::com::sun::star::sdbc::XResultSet,
+ ::com::sun::star::sdbc::XRow,
+ ::com::sun::star::sdbc::XResultSetMetaDataSupplier,
+ ::com::sun::star::util::XCancellable,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XCloseable,
+ ::com::sun::star::sdbc::XColumnLocate,
+ ::com::sun::star::sdbc::XResultSetUpdate,
+ ::com::sun::star::sdbc::XRowUpdate,
+ ::com::sun::star::sdbcx::XRowLocate,
+ ::com::sun::star::sdbcx::XDeleteRows,
+ ::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
+
+
+ typedef sal_Int64 TVoidPtr;
+ typedef ::std::allocator< TVoidPtr > TVoidAlloc;
+ typedef ::std::vector<TVoidPtr> TVoidVector;
+
+ class OResultSet : public comphelper::OBaseMutex,
+ public OResultSet_BASE,
+ public ::cppu::OPropertySetHelper,
+ public ::comphelper::OPropertyArrayUsageHelper<OResultSet>
+ {
+ protected:
+ OCommonStatement* m_pStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> m_xStatement;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData> m_xMetaData;
+ sal_uInt32 m_nRowPos;
+ sal_uInt32 m_nOldRowPos;
+ sal_Bool m_bWasNull;
+ sal_Int32 m_nFetchSize;
+ sal_Int32 m_nResultSetType;
+ sal_Int32 m_nFetchDirection;
+ sal_Int32 m_nResultSetConcurrency;
+
+
+
+ ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >
+ m_pSQLIterator;
+ const connectivity::OSQLParseNode* m_pParseTree;
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue
+ )
+ throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle
+ ) const;
+
+ // you can't delete objects of this type
+ virtual ~OResultSet();
+ public:
+ DECLARE_SERVICE_INFO();
+
+ OResultSet(OCommonStatement* pStmt, const ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >& _pSQLIterator );
+
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > operator *()
+ {
+ return ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(*(OResultSet_BASE*)this);
+ }
+
+ // ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XResultSet
+ virtual sal_Bool SAL_CALL next( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isBeforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAfterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL beforeFirst( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL afterLast( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL first( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL last( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL absolute( sal_Int32 row ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL relative( sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL previous( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL refreshRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowUpdated( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowInserted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL rowDeleted( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getStatement( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRow
+ virtual sal_Bool SAL_CALL wasNull( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getString( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL getBoolean( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int8 SAL_CALL getByte( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int16 SAL_CALL getShort( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getInt( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int64 SAL_CALL getLong( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual float SAL_CALL getFloat( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual double SAL_CALL getDouble( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getBytes( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Date SAL_CALL getDate( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::Time SAL_CALL getTime( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::util::DateTime SAL_CALL getTimestamp( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getBinaryStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > SAL_CALL getCharacterStream( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Any SAL_CALL getObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRef > SAL_CALL getRef( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XBlob > SAL_CALL getBlob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XClob > SAL_CALL getClob( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XArray > SAL_CALL getArray( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XResultSetMetaDataSupplier
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > SAL_CALL getMetaData( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCancellable
+ virtual void SAL_CALL cancel( ) throw(::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XColumnLocate
+ virtual sal_Int32 SAL_CALL findColumn( const ::rtl::OUString& columnName ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ // XResultSetUpdate
+ virtual void SAL_CALL insertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL deleteRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowUpdate
+ virtual void SAL_CALL updateNull( sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateLong( sal_Int32 columnIndex, sal_Int64 x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateFloat( sal_Int32 columnIndex, float x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDouble( sal_Int32 columnIndex, double x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBytes( sal_Int32 columnIndex, const ::com::sun::star::uno::Sequence< sal_Int8 >& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateDate( sal_Int32 columnIndex, const ::com::sun::star::util::Date& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTime( sal_Int32 columnIndex, const ::com::sun::star::util::Time& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateTimestamp( sal_Int32 columnIndex, const ::com::sun::star::util::DateTime& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateBinaryStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateCharacterStream( sal_Int32 columnIndex, const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL updateNumericObject( sal_Int32 columnIndex, const ::com::sun::star::uno::Any& x, sal_Int32 scale ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XRowLocate
+ virtual ::com::sun::star::uno::Any SAL_CALL getBookmark( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveToBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL moveRelativeToBookmark( const ::com::sun::star::uno::Any& bookmark, sal_Int32 rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL compareBookmarks( const ::com::sun::star::uno::Any& first, const ::com::sun::star::uno::Any& second ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL hashBookmark( const ::com::sun::star::uno::Any& bookmark ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XDeleteRows
+ virtual ::com::sun::star::uno::Sequence< sal_Int32 > SAL_CALL deleteRows( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& rows ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+protected:
+ MQuery m_aQuery;
+ OTable* m_pTable;
+ sal_Int32 m_CurrentRowCount;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
+ m_xTableColumns;
+
+ ::std::vector<sal_Int32> m_aColMapping; // pos 0 is unused so we don't have to decrement 1 everytime
+ ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
+ ::std::vector<TAscendingOrder> m_aOrderbyAscending;
+ ::com::sun::star::uno::Sequence< ::rtl::OUString> m_aColumnNames;
+ OValueRow m_aRow;
+ OValueRow m_aParameterRow;
+ ::std::vector< ::rtl::OUString> m_aAttributeStrings;
+ sal_Int32 m_nParamIndex;
+ sal_Bool m_bIsAlwaysFalseQuery;
+ ::vos::ORef<OKeySet> m_pKeySet;
+ OSortIndex* m_pSortIndex;
+ sal_Int32 m_nNewRow; //inserted row
+ sal_Int32 m_nUpdatedRow; //updated row
+ sal_Int32 m_RowStates;
+ sal_Int32 m_bIsReadOnly;
+ inline void resetParameters() { m_nParamIndex = 0; }
+
+ ::vos::ORef<connectivity::OSQLColumns> m_xColumns; // this are the select columns
+ ::vos::ORef<connectivity::OSQLColumns> m_xParamColumns;
+
+ void parseParameter( const OSQLParseNode* pNode, rtl::OUString& rMatchString );
+ void fillRowData() throw( ::com::sun::star::sdbc::SQLException );
+ void initializeRow(OValueRow& _rRow,sal_Int32 _nColumnCount);
+ void analyseWhereClause( const OSQLParseNode* parseTree,
+ MQueryExpression &queryExpression);
+
+ sal_Bool isCount() const;
+
+ // XXX sal_Bool IsSorted() const { return !m_aOrderbyColumnNumber.empty() && m_aOrderbyColumnNumber[0] != STRING_NOTFOUND ;}
+ sal_Bool IsSorted() const { return !m_aOrderbyColumnNumber.empty(); }
+
+ enum eRowPosition {
+ NEXT_POS, PRIOR_POS, FIRST_POS, LAST_POS, ABSOLUTE_POS, RELATIVE_POS
+ };
+
+ sal_uInt32 currentRowCount();
+
+ sal_Bool fetchRow(sal_Int32 rowIndex,sal_Bool bForceReload=sal_False) throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool fetchCurrentRow() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool pushCard(sal_uInt32 rowIndex) throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+ sal_Bool validRow( sal_uInt32 nRow );
+ sal_Bool seekRow( eRowPosition pos, sal_Int32 nOffset = 0 );
+ sal_Int32 deletedCount();
+ sal_Bool fillKeySet(sal_Int32 nMaxCardNumber); //When we get new rows, fill the m_pKeySet items for them
+ sal_Int32 getRowForCardNumber(sal_Int32 nCardNum);
+ const ORowSetValue& getValue(sal_Int32 rowIndex, sal_Int32 columnIndex)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ void updateValue(sal_Int32 columnIndex,const ORowSetValue& x ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ void checkPendingUpdate() throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ sal_Int32 getCurrentCardNumber();
+
+public:
+ sal_Bool determineReadOnly();
+ // MozAddressbook Specific methods
+ void SAL_CALL executeQuery() throw( ::com::sun::star::sdbc::SQLException,
+ ::com::sun::star::uno::RuntimeException);
+
+ void setTable(OTable* _rTable);
+
+ void setParameterRow(const OValueRow& _rParaRow)
+ { m_aParameterRow = _rParaRow; }
+
+ void setParameterColumns(const ::vos::ORef<connectivity::OSQLColumns>& _xParamColumns)
+ { m_xParamColumns = _xParamColumns; }
+
+ void setBindingRow(const OValueRow& _aRow)
+ { m_aRow = _aRow; }
+
+ void setColumnMapping(const ::std::vector<sal_Int32>& _aColumnMapping);
+
+ void setOrderByColumns(const ::std::vector<sal_Int32>& _aColumnOrderBy);
+
+ void setOrderByAscending(const ::std::vector<TAscendingOrder>& _aOrderbyAsc);
+
+ inline sal_Int32 mapColumn(sal_Int32 column);
+
+ void checkIndex(sal_Int32 columnIndex ) throw(::com::sun::star::sdbc::SQLException);
+
+ static void setBoundedColumns(
+ const OValueRow& _rRow,
+ const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess>& _xNames,
+ sal_Bool _bSetColumnMapping,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
+ ::std::vector<sal_Int32>& _rColMapping);
+
+ ::osl::Mutex& getMutex() { return m_aMutex; }
+ void methodEntry();
+
+ private:
+ inline void impl_ensureKeySet()
+ {
+ if ( !m_pKeySet.isValid() )
+ m_pKeySet = new OKeySet();
+ }
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+
+ inline sal_Int32 OResultSet::mapColumn(sal_Int32 column)
+ {
+ sal_Int32 map = column;
+
+ OSL_ENSURE(column > 0, "OResultSet::mapColumn: invalid column index!");
+ // the first column (index 0) is for convenience only. The
+ // first real select column is no 1.
+ if ((column > 0) && (column < (sal_Int32)m_aColMapping.size()))
+ map = m_aColMapping[column];
+
+ return map;
+ }
+
+ class ResultSetEntryGuard : public ::osl::MutexGuard
+ {
+ public:
+ ResultSetEntryGuard( OResultSet& _rRS ) : ::osl::MutexGuard( _rRS.getMutex() )
+ {
+ _rRS.methodEntry();
+ }
+ };
+
+ }
+}
+#endif // CONNECTIVITY_SRESULTSET_HXX
diff --git a/connectivity/source/drivers/mozab/MResultSetMetaData.cxx b/connectivity/source/drivers/mozab/MResultSetMetaData.cxx
new file mode 100644
index 000000000000..49daa10ce386
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MResultSetMetaData.cxx
@@ -0,0 +1,212 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+#include <comphelper/extract.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <tools/diagnose_ex.h>
+#include "MResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+
+using namespace connectivity::mozab;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::beans;
+using namespace ::dbtools;
+using namespace ::comphelper;
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+ m_xColumns = NULL;
+}
+
+// -----------------------------------------------------------------------------
+void OResultSetMetaData::checkColumnIndex(sal_Int32 column) throw(SQLException, RuntimeException)
+{
+ if(column <= 0 || column > (sal_Int32)(sal_Int32)m_xColumns->get().size())
+ throwInvalidIndexException(*this);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getPrecision(column);
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return DataType::VARCHAR; // at the moment there exists only this type
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ return (m_xColumns->get()).size();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+
+ ::rtl::OUString sColumnName;
+ try
+ {
+ Reference< XPropertySet > xColumnProps( (m_xColumns->get())[column-1], UNO_QUERY_THROW );
+ OSL_VERIFY( xColumnProps->getPropertyValue( OMetaConnection::getPropMap().getNameByIndex( PROPERTY_ID_NAME ) ) >>= sColumnName );
+ }
+ catch( const Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ return sColumnName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return m_aTableName;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getString((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPENAME)));
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getColumnName(column);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getBOOL((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISCURRENCY)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRECISION)));
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_SCALE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ return getINT32((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISNULLABLE)));
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString sColumnName( getColumnName( column ) );
+
+ if ( !m_pTable || !m_pTable->getConnection() )
+ {
+ OSL_ENSURE( false, "OResultSetMetaData::isSearchable: suspicious: called without table or connection!" );
+ return sal_False;
+ }
+
+ if ( m_pTable->getConnection()->isLDAP() )
+ {
+ const OColumnAlias& aAliases( m_pTable->getConnection()->getColumnAlias() );
+ if ( !aAliases.isColumnSearchable( sColumnName ) )
+ return sal_False;
+ }
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ checkColumnIndex(column);
+ sal_Bool bReadOnly = (m_xColumns->get())[column-1]->getPropertySetInfo()->hasPropertyByName(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)) &&
+ ::cppu::any2bool((m_xColumns->get())[column-1]->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FUNCTION)));
+
+ return m_bReadOnly || bReadOnly || m_pTable->isReadOnly();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return !isReadOnly(column);
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/mozab/MResultSetMetaData.hxx b/connectivity/source/drivers/mozab/MResultSetMetaData.hxx
new file mode 100644
index 000000000000..50ff8e6c6ffe
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MResultSetMetaData.hxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SRESULSETMETADATA_HXX
+#define CONNECTIVITY_SRESULSETMETADATA_HXX
+
+#include <com/sun/star/sdbc/XResultSetMetaData.hpp>
+#include <cppuhelper/implbase1.hxx>
+#include <vector>
+#include <vos/ref.hxx>
+#include "MConnection.hxx"
+#include "MTable.hxx"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ //**************************************************************
+ //************ Class: ResultSetMetaData
+ //**************************************************************
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::sdbc::XResultSetMetaData> OResultSetMetaData_BASE;
+
+ class OResultSetMetaData : public OResultSetMetaData_BASE
+ {
+ ::rtl::OUString m_aTableName;
+ ::vos::ORef<connectivity::OSQLColumns> m_xColumns;
+ OTable* m_pTable;
+ sal_Bool m_bReadOnly;
+
+ protected:
+ virtual ~OResultSetMetaData();
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ // OResultSetMetaData(OConnection* _pConnection) : m_pConnection(_pConnection){}
+ OResultSetMetaData(const ::vos::ORef<connectivity::OSQLColumns>& _rxColumns,
+ const ::rtl::OUString& _aTableName,OTable* _pTable,sal_Bool aReadOnly
+ )
+ :m_aTableName(_aTableName)
+ ,m_xColumns(_rxColumns)
+ ,m_pTable(_pTable)
+ ,m_bReadOnly(aReadOnly)
+ {}
+
+
+ /// Avoid ambigous cast error from the compiler.
+ inline operator ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSetMetaData > () throw()
+ { return this; }
+
+ void checkColumnIndex(sal_Int32 column) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnCount( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isAutoIncrement( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCaseSensitive( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSearchable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isCurrency( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL isNullable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isSigned( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnDisplaySize( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnLabel( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getSchemaName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getPrecision( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getTableName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCatalogName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Int32 SAL_CALL getColumnType( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnTypeName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isReadOnly( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL isDefinitelyWritable( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getColumnServiceName( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ };
+ }
+}
+
+#endif // CONNECTIVITY_SRESULSETMETADATA_HXX
diff --git a/connectivity/source/drivers/mozab/MServices.cxx b/connectivity/source/drivers/mozab/MServices.cxx
new file mode 100644
index 000000000000..4e595dad57ed
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MServices.cxx
@@ -0,0 +1,225 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+#include "bootstrap/MMozillaBootstrap.hxx"
+#include <tools/solar.h>
+
+using namespace connectivity::mozab;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+using ::com::sun::star::mozilla::XMozillaBootstrap;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pTemp
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString( RTL_CONSTASCII_USTRINGPARAM("/"));
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "MOZAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+
+ REGISTER_PROVIDER(
+ MozabDriver::getImplementationName_Static(),
+ MozabDriver::getSupportedServiceNames_Static(), xKey);
+
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ REGISTER_PROVIDER(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")),
+ aSNS, xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "Mozab::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+typedef void* (SAL_CALL * OMozillaBootstrap_CreateInstanceFunction)(const Reference< XMultiServiceFactory >& _rxFactory );
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL createMozillaBootstrap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ const ::rtl::OUString sModuleName = ::rtl::OUString::createFromAscii(SVLIBRARY( "mozabdrv" ));
+
+ // load the dbtools library
+ oslModule s_hModule = osl_loadModuleRelative(
+ reinterpret_cast< oslGenericFunction >(&createMozillaBootstrap),
+ sModuleName.pData, 0);
+ OSL_ENSURE(NULL != s_hModule, "MozabDriver::registerClient: could not load the dbtools library!");
+ if (NULL != s_hModule)
+ {
+
+ // get the symbol for the method creating the factory
+ const ::rtl::OUString sFactoryCreationFunc = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("OMozillaBootstrap_CreateInstance"));
+ // reinterpret_cast<OMozabConnection_CreateInstanceFunction> removed GNU C
+ OMozillaBootstrap_CreateInstanceFunction s_pCreationFunc = (OMozillaBootstrap_CreateInstanceFunction)osl_getFunctionSymbol(s_hModule, sFactoryCreationFunc.pData);
+
+ if (NULL == s_pCreationFunc)
+ { // did not find the symbol
+ OSL_ENSURE(sal_False, "MozabDriver::registerClient: could not find the symbol for creating the factory!");
+ osl_unloadModule(s_hModule);
+ s_hModule = NULL;
+ }
+ MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>((*s_pCreationFunc)(_rxFactory));
+ return *pBootstrap;
+ }
+ return NULL;
+}
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ OUString aImplName( OUString::createFromAscii( pImplementationName ) );
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+ if (aImplName.equals( MozabDriver::getImplementationName_Static() ))
+ {
+ aReq.CREATE_PROVIDER(
+ MozabDriver::getImplementationName_Static(),
+ MozabDriver::getSupportedServiceNames_Static(),
+ MozabDriver_CreateInstance, ::cppu::createSingleFactory);
+ }
+ else if (aImplName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")) ))
+ {
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ aReq.CREATE_PROVIDER(
+ aImplName,
+ aSNS,
+ createMozillaBootstrap, ::cppu::createSingleFactory);
+ }
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/mozab/MStatement.cxx b/connectivity/source/drivers/mozab/MStatement.cxx
new file mode 100644
index 000000000000..13f64b124d0a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MStatement.cxx
@@ -0,0 +1,561 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include <comphelper/property.hxx>
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <tools/diagnose_ex.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include <connectivity/dbexception.hxx>
+#include <com/sun/star/container/XIndexAccess.hpp>
+
+#include <algorithm>
+
+#include "diagnose_ex.h"
+#include "MDriver.hxx"
+#include "MStatement.hxx"
+#include "MConnection.hxx"
+#include "MResultSet.hxx"
+#include "MDatabaseMetaData.hxx"
+#include "resource/mozab_res.hrc"
+#include "resource/common_res.hrc"
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+static ::osl::Mutex m_ThreadMutex;
+
+using namespace ::comphelper;
+using namespace connectivity::mozab;
+using namespace connectivity;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OCommonStatement::OCommonStatement(OConnection* _pConnection )
+ :OCommonStatement_IBASE(m_aMutex)
+ ,OPropertySetHelper(OCommonStatement_IBASE::rBHelper)
+ ,OCommonStatement_SBASE((::cppu::OWeakObject*)_pConnection, this)
+ ,m_xDBMetaData(_pConnection->getMetaData())
+ ,m_pTable(NULL)
+ ,m_pConnection(_pConnection)
+ ,m_aParser(_pConnection->getDriver()->getMSFactory())
+ ,m_pSQLIterator( new OSQLParseTreeIterator( _pConnection, _pConnection->createCatalog()->getTables(), m_aParser, NULL ) )
+ ,m_pParseTree(NULL)
+ ,rBHelper(OCommonStatement_IBASE::rBHelper)
+{
+ m_pConnection->acquire();
+ OSL_TRACE("In/Out: OCommonStatement::OCommonStatement" );
+}
+// -----------------------------------------------------------------------------
+OCommonStatement::~OCommonStatement()
+{
+}
+
+//------------------------------------------------------------------------------
+void OCommonStatement::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ clearWarnings();
+ clearCachedResultSet();
+
+ if (m_pConnection)
+ m_pConnection->release();
+ m_pConnection = NULL;
+
+ m_pSQLIterator->dispose();
+
+ dispose_ChildImpl();
+ OCommonStatement_IBASE::disposing();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OCommonStatement_IBASE::queryInterface(rType);
+ if(!aRet.hasValue())
+ aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OCommonStatement::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OCommonStatement_IBASE::getTypes());
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+ }
+ dispose();
+}
+
+
+// -------------------------------------------------------------------------
+void OCommonStatement::createTable( ) throw ( SQLException, RuntimeException )
+{
+ if(m_pParseTree)
+ {
+ ::vos::ORef<connectivity::OSQLColumns> xCreateColumn;
+ if (m_pSQLIterator->getStatementType() == SQL_STATEMENT_CREATE_TABLE)
+ {
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ OSL_ENSURE( !xTabs.empty(), "Need a Table");
+ ::rtl::OUString ouTableName=xTabs.begin()->first;
+ xCreateColumn = m_pSQLIterator->getCreateColumns();
+ OSL_ENSURE(xCreateColumn.isValid(), "Need the Columns!!");
+
+ const OColumnAlias& aColumnAlias = m_pConnection->getColumnAlias();
+
+ OSQLColumns::Vector::const_iterator aIter = xCreateColumn->get().begin();
+ const ::rtl::OUString sProprtyName = OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME);
+ ::rtl::OUString sName;
+ for (sal_Int32 i = 1; aIter != xCreateColumn->get().end();++aIter, i++)
+ {
+ (*aIter)->getPropertyValue(sProprtyName) >>= sName;
+ if ( !aColumnAlias.hasAlias( sName ) )
+ {
+
+ const ::rtl::OUString sError( getOwnConnection()->getResources().getResourceStringWithSubstitution(
+ STR_INVALID_COLUMNNAME,
+ "$columnname$", sName
+ ) );
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+ }
+ MDatabaseMetaDataHelper _aDbHelper;
+ if (!_aDbHelper.NewAddressBook(m_pConnection,ouTableName))
+ {
+ getOwnConnection()->throwSQLException( _aDbHelper.getError(), *this );
+ }
+ m_pSQLIterator.reset( new ::connectivity::OSQLParseTreeIterator(
+ m_pConnection, m_pConnection->createCatalog()->getTables(), m_aParser, NULL ) );
+ }
+
+ }
+ else
+ getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+}
+// -------------------------------------------------------------------------
+OCommonStatement::StatementType OCommonStatement::parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted)
+ throw ( SQLException, RuntimeException )
+{
+ ::rtl::OUString aErr;
+
+ m_pParseTree = m_aParser.parseTree(aErr,sql);
+
+#if OSL_DEBUG_LEVEL > 0
+ {
+ const char* str = OUtoCStr(sql);
+ OSL_UNUSED( str );
+ OSL_TRACE("ParseSQL: %s\n", OUtoCStr( sql ) );
+ }
+#endif // OSL_DEBUG_LEVEL
+
+ if(m_pParseTree)
+ {
+ m_pSQLIterator->setParseTree(m_pParseTree);
+ m_pSQLIterator->traverseAll();
+ const OSQLTables& xTabs = m_pSQLIterator->getTables();
+ if(xTabs.empty())
+ getOwnConnection()->throwSQLException( STR_QUERY_AT_LEAST_ONE_TABLES, *this );
+
+#if OSL_DEBUG_LEVEL > 0
+ OSQLTables::const_iterator citer;
+ for( citer = xTabs.begin(); citer != xTabs.end(); ++citer ) {
+ OSL_TRACE("SELECT Table : %s\n", OUtoCStr(citer->first) );
+ }
+#endif
+
+ Reference<XIndexAccess> xNames;
+ switch(m_pSQLIterator->getStatementType())
+ {
+ case SQL_STATEMENT_SELECT:
+
+ // at this moment we support only one table per select statement
+
+ OSL_ENSURE( xTabs.begin() != xTabs.end(), "Need a Table");
+
+ m_pTable = static_cast< OTable* > (xTabs.begin()->second.get());
+ m_xColNames = m_pTable->getColumns();
+ xNames = Reference<XIndexAccess>(m_xColNames,UNO_QUERY);
+ // set the binding of the resultrow
+ m_aRow = new OValueVector(xNames->getCount());
+ (m_aRow->get())[0].setBound(sal_True);
+ ::std::for_each(m_aRow->get().begin()+1,m_aRow->get().end(),TSetBound(sal_False));
+ // create the column mapping
+ createColumnMapping();
+
+ analyseSQL();
+ return eSelect;
+
+ case SQL_STATEMENT_CREATE_TABLE:
+ createTable();
+ return eCreateTable;
+
+ default:
+ break;
+ }
+ }
+ else if(!bAdjusted) //Our sql parser does not support a statement like "create table foo"
+ // So we append ("E-mail" varchar) to the last of it to make it work
+ {
+ return parseSql(sql + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("(""E-mail"" caracter)")),sal_True);
+ }
+
+ getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX, *this );
+ OSL_ENSURE( false, "OCommonStatement::parseSql: unreachable!" );
+ return eSelect;
+
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > OCommonStatement::impl_executeCurrentQuery()
+{
+ clearCachedResultSet();
+
+ ::rtl::Reference< OResultSet > pResult( new OResultSet( this, m_pSQLIterator ) );
+ initializeResultSet( pResult.get() );
+
+ pResult->executeQuery();
+ cacheResultSet( pResult ); // only cache if we survived the execution
+
+ return pResult.get();
+
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::initializeResultSet( OResultSet* _pResult )
+{
+ ENSURE_OR_THROW( _pResult, "invalid result set" );
+
+ _pResult->setColumnMapping(m_aColMapping);
+ _pResult->setOrderByColumns(m_aOrderbyColumnNumber);
+ _pResult->setOrderByAscending(m_aOrderbyAscending);
+ _pResult->setBindingRow(m_aRow);
+ _pResult->setTable(m_pTable);
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::clearCachedResultSet()
+{
+ Reference< XResultSet > xResultSet( m_xResultSet.get(), UNO_QUERY );
+ if ( !xResultSet.is() )
+ return;
+
+ try
+ {
+ Reference< XCloseable > xCloseable( xResultSet, UNO_QUERY_THROW );
+ xCloseable->close();
+ }
+ catch( const DisposedException& )
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+
+ m_xResultSet = Reference< XResultSet >();
+}
+
+// -------------------------------------------------------------------------
+void OCommonStatement::cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult )
+{
+ ENSURE_OR_THROW( _pResult.is(), "invalid result set" );
+ m_xResultSet = Reference< XResultSet >( _pResult.get() );
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OCommonStatement::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("Statement::execute( %s )", OUtoCStr( sql ) );
+
+ Reference< XResultSet > xRS = executeQuery( sql );
+ // returns true when a resultset is available
+ return xRS.is();
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OCommonStatement::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_ThreadMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ OSL_TRACE("Statement::executeQuery( %s )", OUtoCStr( sql ) );
+
+ // parse the statement
+ StatementType eStatementType = parseSql( sql );
+ if ( eStatementType != eSelect )
+ return NULL;
+
+ return impl_executeCurrentQuery();
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OCommonStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ // just return our connection here
+ return (Reference< XConnection >)m_pConnection;
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XServiceInfo*> (this));
+ if(!aRet.hasValue())
+ aRet = OCommonStatement::queryInterface(rType);
+ return aRet;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OCommonStatement::executeUpdate( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XStatement::executeUpdate", *this );
+ return 0;
+
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OCommonStatement::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OCommonStatement_IBASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OCommonStatement::createArrayHelper( ) const
+{
+ // this properties are define by the service resultset
+ // they must in alphabetic order
+ Sequence< Property > aProps(9);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OCommonStatement::getInfoHelper()
+{
+ return *const_cast<OCommonStatement*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OCommonStatement::convertFastPropertyValue(
+ Any & /*rConvertedValue*/,
+ Any & /*rOldValue*/,
+ sal_Int32 /*nHandle*/,
+ const Any& /*rValue*/ )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bConverted = sal_False;
+ // here we have to try to convert
+ return bConverted;
+}
+// -------------------------------------------------------------------------
+void OCommonStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& /*rValue*/) throw (Exception)
+{
+ // set the value to what ever is nescessary
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OCommonStatement::getFastPropertyValue(Any& /*rValue*/,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ case PROPERTY_ID_MAXFIELDSIZE:
+ case PROPERTY_ID_MAXROWS:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::acquire() throw()
+{
+ OCommonStatement_IBASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OCommonStatement::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OCommonStatement::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OCommonStatement::release();
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OCommonStatement::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void OCommonStatement::createColumnMapping()
+{
+ size_t i;
+
+ // initialize the column index map (mapping select columns to table columns)
+ ::vos::ORef<connectivity::OSQLColumns> xColumns = m_pSQLIterator->getSelectColumns();
+ m_aColMapping.resize(xColumns->get().size() + 1);
+ for (i=0; i<m_aColMapping.size(); ++i)
+ m_aColMapping[i] = i;
+
+ Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
+ // now check which columns are bound
+#if OSL_DEBUG_LEVEL > 0
+ for ( i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("BEFORE Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+ OResultSet::setBoundedColumns(m_aRow,xColumns,xNames,sal_True,m_xDBMetaData,m_aColMapping);
+#if OSL_DEBUG_LEVEL > 0
+ for ( i = 0; i < m_aColMapping.size(); i++ )
+ OSL_TRACE("AFTER Mapped: %d -> %d", i, m_aColMapping[i] );
+#endif
+}
+// -----------------------------------------------------------------------------
+
+void OCommonStatement::analyseSQL()
+{
+ const OSQLParseNode* pOrderbyClause = m_pSQLIterator->getOrderTree();
+ if(pOrderbyClause)
+ {
+ OSQLParseNode * pOrderingSpecCommalist = pOrderbyClause->getChild(2);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpecCommalist,ordering_spec_commalist),"OResultSet: Fehler im Parse Tree");
+
+ for (sal_uInt32 m = 0; m < pOrderingSpecCommalist->count(); m++)
+ {
+ OSQLParseNode * pOrderingSpec = pOrderingSpecCommalist->getChild(m);
+ OSL_ENSURE(SQL_ISRULE(pOrderingSpec,ordering_spec),"OResultSet: Fehler im Parse Tree");
+ OSL_ENSURE(pOrderingSpec->count() == 2,"OResultSet: Fehler im Parse Tree");
+
+ OSQLParseNode * pColumnRef = pOrderingSpec->getChild(0);
+ if(!SQL_ISRULE(pColumnRef,column_ref))
+ {
+ throw SQLException();
+ }
+ OSQLParseNode * pAscendingDescending = pOrderingSpec->getChild(1);
+ setOrderbyColumn(pColumnRef,pAscendingDescending);
+ }
+ }
+}
+//------------------------------------------------------------------
+void OCommonStatement::setOrderbyColumn( OSQLParseNode* pColumnRef,
+ OSQLParseNode* pAscendingDescending)
+{
+ ::rtl::OUString aColumnName;
+ if (pColumnRef->count() == 1)
+ aColumnName = pColumnRef->getChild(0)->getTokenValue();
+ else if (pColumnRef->count() == 3)
+ {
+ pColumnRef->getChild(2)->parseNodeToStr( aColumnName, getOwnConnection(), NULL, sal_False, sal_False );
+ }
+ else
+ {
+ throw SQLException();
+ }
+
+ Reference<XColumnLocate> xColLocate(m_xColNames,UNO_QUERY);
+ if(!xColLocate.is())
+ return;
+
+ m_aOrderbyColumnNumber.push_back(xColLocate->findColumn(aColumnName));
+
+ // Ascending or Descending?
+ m_aOrderbyAscending.push_back((SQL_ISTOKEN(pAscendingDescending,DESC)) ? SQL_DESC : SQL_ASC);
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mozab/MStatement.hxx b/connectivity/source/drivers/mozab/MStatement.hxx
new file mode 100644
index 000000000000..700e562ca6e3
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MStatement.hxx
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SSTATEMENT_HXX
+#define CONNECTIVITY_SSTATEMENT_HXX
+
+#include <com/sun/star/sdbc/XStatement.hpp>
+#include <com/sun/star/sdbc/XWarningsSupplier.hpp>
+#include <com/sun/star/sdbc/XBatchExecution.hpp>
+#include <com/sun/star/sdbc/XCloseable.hpp>
+#include <com/sun/star/sdbc/SQLWarning.hpp>
+#include <comphelper/proparrhlp.hxx>
+#include <cppuhelper/compbase3.hxx>
+#include <comphelper/uno3.hxx>
+#include "connectivity/CommonTools.hxx"
+#ifndef INCLUDED_LIST
+#include <list>
+#define INCLUDED_LIST
+#endif
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/broadcasthelper.hxx>
+#include "connectivity/sqliterator.hxx"
+#ifndef _CONNECTIVITY_PARSE_SQLPARSE_HXX_
+#include "connectivity/sqlparse.hxx"
+#endif
+#include <connectivity/FValue.hxx>
+#include "TSortIndex.hxx"
+#include "MConnection.hxx"
+#include "MTable.hxx"
+
+#include <boost/shared_ptr.hpp>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class OResultSet;
+
+ typedef ::cppu::WeakComponentImplHelper3< ::com::sun::star::sdbc::XStatement,
+ ::com::sun::star::sdbc::XWarningsSupplier,
+ ::com::sun::star::sdbc::XCloseable> OCommonStatement_IBASE;
+
+ //**************************************************************
+ //************ Class: OCommonStatement
+ // is a base class for the normal statement and for the prepared statement
+ //**************************************************************
+ class OCommonStatement;
+ typedef ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE > OCommonStatement_SBASE;
+
+ class OCommonStatement :public comphelper::OBaseMutex
+ ,public OCommonStatement_IBASE
+ ,public ::cppu::OPropertySetHelper
+ ,public ::comphelper::OPropertyArrayUsageHelper< OCommonStatement >
+ ,public OCommonStatement_SBASE
+ {
+ friend class ::connectivity::OSubComponent< OCommonStatement, OCommonStatement_IBASE >;
+
+ private:
+ ::com::sun::star::sdbc::SQLWarning m_aLastWarning;
+
+ protected:
+ ::com::sun::star::uno::WeakReference< ::com::sun::star::sdbc::XResultSet > m_xResultSet;
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData> m_xDBMetaData;
+ ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xColNames; // table columns
+
+ // for this Statement
+
+ ::std::list< ::rtl::OUString> m_aBatchList;
+
+ OTable* m_pTable;
+ OConnection* m_pConnection; // The owning Connection object
+
+ OValueRow m_aRow;
+
+ connectivity::OSQLParser m_aParser;
+ ::boost::shared_ptr< ::connectivity::OSQLParseTreeIterator >
+ m_pSQLIterator;
+
+ connectivity::OSQLParseNode* m_pParseTree;
+
+ ::std::vector<sal_Int32> m_aColMapping;
+ ::std::vector<sal_Int32> m_aOrderbyColumnNumber;
+ ::std::vector<TAscendingOrder> m_aOrderbyAscending;
+
+ ::cppu::OBroadcastHelper& rBHelper;
+
+ protected:
+
+ // OPropertyArrayUsageHelper
+ virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const;
+ // OPropertySetHelper
+ virtual ::cppu::IPropertyArrayHelper & SAL_CALL getInfoHelper();
+ virtual sal_Bool SAL_CALL convertFastPropertyValue(
+ ::com::sun::star::uno::Any & rConvertedValue,
+ ::com::sun::star::uno::Any & rOldValue,
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException);
+ virtual void SAL_CALL setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const ::com::sun::star::uno::Any& rValue) throw (::com::sun::star::uno::Exception);
+ virtual void SAL_CALL getFastPropertyValue(
+ ::com::sun::star::uno::Any& rValue,
+ sal_Int32 nHandle) const;
+ virtual ~OCommonStatement();
+
+ protected:
+ //
+ // Driver Internal Methods
+ //
+ enum StatementType { eSelect, eCreateTable };
+ /** called to do the parsing of a to-be-executed SQL statement, and set all members as needed
+ */
+ virtual StatementType
+ parseSql( const ::rtl::OUString& sql , sal_Bool bAdjusted = sal_False) throw ( ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+ /** called to initialize a result set, according to a previously parsed SQL statement
+ */
+ virtual void initializeResultSet( OResultSet* _pResult );
+ /** called when a possible cached instance of our last result set should be cleared
+ */
+ virtual void clearCachedResultSet();
+ /** caches a result set which has just been created by an execution of an SQL statement
+ */
+ virtual void cacheResultSet( const ::rtl::Reference< OResultSet >& _pResult );
+
+
+ /** executes the current query (the one which has been passed to the last parseSql call)
+ */
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >
+ impl_executeCurrentQuery();
+
+ void createColumnMapping();
+ void analyseSQL();
+ void setOrderbyColumn( connectivity::OSQLParseNode* pColumnRef,
+ connectivity::OSQLParseNode* pAscendingDescending);
+ virtual void createTable( ) throw (
+ ::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException );
+
+ public:
+ // other methods
+ OConnection* getOwnConnection() const { return m_pConnection;}
+
+ OCommonStatement(OConnection* _pConnection );
+ using OCommonStatement_IBASE::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+
+ // XInterface
+ virtual void SAL_CALL release() throw();
+ virtual void SAL_CALL acquire() throw();
+ // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ //XTypeProvider
+ virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XPropertySet
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException);
+ // XStatement
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet > SAL_CALL executeQuery( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Int32 SAL_CALL executeUpdate( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual sal_Bool SAL_CALL execute( const ::rtl::OUString& sql ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > SAL_CALL getConnection( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException) ;
+ // XWarningsSupplier
+ virtual ::com::sun::star::uno::Any SAL_CALL getWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL clearWarnings( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+ // XCloseable
+ virtual void SAL_CALL close( ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
+
+ protected:
+ using OPropertySetHelper::getFastPropertyValue;
+ };
+
+ class OStatement : public OCommonStatement,
+ public ::com::sun::star::lang::XServiceInfo
+ {
+ protected:
+ ~OStatement(){}
+ public:
+ // ein Konstruktor, der fuer das Returnen des Objektes benoetigt wird:
+ OStatement( OConnection* _pConnection) : OCommonStatement( _pConnection){}
+ DECLARE_SERVICE_INFO();
+
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw();
+ virtual void SAL_CALL release() throw();
+ };
+ }
+}
+#endif // CONNECTIVITY_SSTATEMENT_HXX
diff --git a/connectivity/source/drivers/mozab/MTable.cxx b/connectivity/source/drivers/mozab/MTable.cxx
new file mode 100644
index 000000000000..1b55ef7e3378
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MTable.cxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MTable.hxx"
+#include "MTables.hxx"
+#include "MColumns.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <comphelper/sequence.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/TKeys.hxx"
+#include "connectivity/TIndexes.hxx"
+#include "MCatalog.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OTable::OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection)
+ :OTable_Base( _pTables, _pConnection, sal_True )
+ ,m_pConnection( _pConnection )
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OTable::OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection,
+ const ::rtl::OUString& _Name, const ::rtl::OUString& _Type, const ::rtl::OUString& _Description )
+ :OTable_Base(_pTables, _pConnection, sal_True, _Name, _Type, _Description )
+ ,m_pConnection( _pConnection )
+{
+ construct();
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createColumns( const TStringVector& _rNames )
+{
+ return new OColumns( this, m_aMutex, _rNames );
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createKeys(const TStringVector& _rNames)
+{
+ return new OKeysHelper( this, m_aMutex, _rNames );
+}
+
+//--------------------------------------------------------------------------
+sdbcx::OCollection* OTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexesHelper( this, m_aMutex, _rNames );
+}
+
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/mozab/MTable.hxx b/connectivity/source/drivers/mozab/MTable.hxx
new file mode 100644
index 000000000000..ec82541243e6
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MTable.hxx
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MOZAB_TABLE_HXX_
+#define _CONNECTIVITY_MOZAB_TABLE_HXX_
+
+#include "connectivity/TTableHelper.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+#ifndef _CONNECTIVITY_MOZAB_BCONNECTION_HXX_
+#include "MConnection.hxx"
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ typedef ::connectivity::OTableHelper OTable_Base;
+
+ class OTable : public OTable_Base
+ {
+ OConnection* m_pConnection;
+
+ public:
+ OTable( sdbcx::OCollection* _pTables, OConnection* _pConnection);
+ OTable( sdbcx::OCollection* _pTables,
+ OConnection* _pConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description );
+
+ OConnection* getConnection() { return m_pConnection;}
+
+ sal_Bool isReadOnly() const { return sal_False; }
+
+ ::rtl::OUString getTableName() const { return m_Name; }
+ ::rtl::OUString getSchema() const { return m_SchemaName; }
+
+ // OTableHelper overridables
+ virtual sdbcx::OCollection* createColumns( const TStringVector& _rNames );
+ virtual sdbcx::OCollection* createKeys(const TStringVector& _rNames);
+ virtual sdbcx::OCollection* createIndexes(const TStringVector& _rNames);
+ private:
+ using OTable_Base::getConnection;
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_TABLE_HXX_
+
diff --git a/connectivity/source/drivers/mozab/MTables.cxx b/connectivity/source/drivers/mozab/MTables.cxx
new file mode 100644
index 000000000000..acf1a0e83dc8
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MTables.cxx
@@ -0,0 +1,104 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MTables.hxx"
+#include "MTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "MCatalog.hxx"
+#ifndef _CONNECTIVITY_MOZAB_BCONNECTION_HXX_
+#include "MConnection.hxx"
+#endif
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::mozab;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString aName,aSchema;
+ // sal_Int32 nLen = _rName.indexOf('.');
+ // aSchema = _rName.copy(0,nLen);
+ // aName = _rName.copy(nLen+1);
+ aSchema = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ aName = _rName;
+
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));
+ // aTypes[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+ // aTypes[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("SYSTEMTABLE"));
+ ::rtl::OUString sEmpty;
+
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),aSchema,aName,aTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if(xResult.is())
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if(xResult->next()) // there can be only one table with this name
+ {
+ OTable* pRet = new OTable( this, static_cast<OCatalog&>(m_rParent).getConnection(),
+ aName,xRow->getString(4),xRow->getString(5));
+ xRet = pRet;
+ }
+ }
+ ::comphelper::disposeComponent(xResult);
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/mozab/MTables.hxx b/connectivity/source/drivers/mozab/MTables.hxx
new file mode 100644
index 000000000000..c134fd6d6aff
--- /dev/null
+++ b/connectivity/source/drivers/mozab/MTables.hxx
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_MOZAB_TABLES_HXX_
+#define _CONNECTIVITY_MOZAB_TABLES_HXX_
+
+#include "connectivity/sdbcx/VCollection.hxx"
+#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
+namespace connectivity
+{
+ namespace mozab
+ {
+ class OTables : public sdbcx::OCollection
+ {
+ ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData > m_xMetaData;
+ // OCatalog* m_pParent;
+ protected:
+ virtual sdbcx::ObjectType createObject(const ::rtl::OUString& _rName);
+ virtual void impl_refresh() throw(::com::sun::star::uno::RuntimeException);
+ public:
+ OTables(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rMetaData,::cppu::OWeakObject& _rParent, ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector) : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_xMetaData(_rMetaData)
+ {}
+
+ // only the name is identical to ::cppu::OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MOZAB_TABLES_HXX_
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
new file mode 100644
index 000000000000..3a7c169d467d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.cxx
@@ -0,0 +1,334 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MMozillaBootstrap.hxx"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+using namespace connectivity::mozab;
+#include <MNSFolders.hxx>
+#include "MNSProfileDiscover.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
+# include "MNSProfileManager.hxx"
+# include "MNSRunnable.hxx"
+#endif
+#include <MNSInit.hxx>
+
+static MozillaBootstrap *pMozillaBootstrap=NULL;
+static Reference<XMozillaBootstrap> xMozillaBootstrap;
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL OMozillaBootstrap_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+{
+ if (!pMozillaBootstrap)
+ {
+ pMozillaBootstrap=new connectivity::mozab::MozillaBootstrap( _rxFactory );
+ pMozillaBootstrap->Init();
+ xMozillaBootstrap = pMozillaBootstrap;
+ }
+ return pMozillaBootstrap;
+}
+
+// --------------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------------
+MozillaBootstrap::MozillaBootstrap(
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ : OMozillaBootstrap_BASE(m_aMutex), m_xMSFactory( _rxFactory )
+{
+}
+// -----------------------------------------------------------------------------
+MozillaBootstrap::~MozillaBootstrap()
+{
+}
+// -----------------------------------------------------------------------------
+void MozillaBootstrap::Init()
+{
+ sal_Bool aProfileExists=sal_False;
+
+#ifndef MINIMAL_PROFILEDISCOVER
+ //This must be call before any mozilla code
+ MNS_Init(aProfileExists);
+
+ m_ProfileManager = new ProfileManager();
+#else
+ (void)aProfileExists; /* avoid warning about unused parameter */
+#endif
+ m_ProfileAccess = new ProfileAccess();
+ bootupProfile(::com::sun::star::mozilla::MozillaProductType_Mozilla,rtl::OUString());
+}
+
+// --------------------------------------------------------------------------------
+void MozillaBootstrap::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OMozillaBootstrap_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString MozillaBootstrap::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii(MOZAB_MozillaBootstrap_IMPL_NAME);
+}
+//------------------------------------------------------------------------------
+Sequence< ::rtl::OUString > MozillaBootstrap::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ // which service is supported
+ // for more information @see com.sun.star.mozilla.MozillaBootstrap
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL MozillaBootstrap::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL MozillaBootstrap::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL MozillaBootstrap::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+
+// XProfileDiscover
+::sal_Int32 SAL_CALL MozillaBootstrap::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileCount(product);
+}
+::sal_Int32 SAL_CALL MozillaBootstrap::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileList(product,list);
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getDefaultProfile(product);
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfilePath(product,profileName);
+}
+::sal_Bool SAL_CALL MozillaBootstrap::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->isProfileLocked(product,profileName);
+}
+::sal_Bool SAL_CALL MozillaBootstrap::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_ProfileAccess->getProfileExists(product,profileName);
+}
+
+// XProfileManager
+::sal_Int32 SAL_CALL MozillaBootstrap::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->bootupProfile(product,profileName);
+#else
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return -1;
+#endif
+}
+::sal_Int32 SAL_CALL MozillaBootstrap::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->shutdownProfile();
+#else
+ return -1;
+#endif
+}
+::com::sun::star::mozilla::MozillaProductType SAL_CALL MozillaBootstrap::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->getCurrentProduct();
+#else
+ return ::com::sun::star::mozilla::MozillaProductType_Default;
+#endif
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->getCurrentProfile();
+#else
+ return ::rtl::OUString();
+#endif
+}
+::sal_Bool SAL_CALL MozillaBootstrap::isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return isProfileLocked(getCurrentProduct(),m_ProfileManager->getCurrentProfile());
+#else
+ return true;
+#endif
+}
+::rtl::OUString SAL_CALL MozillaBootstrap::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ return m_ProfileManager->setCurrentProfile(product,profileName);
+#else
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return ::rtl::OUString();
+#endif
+}
+
+// XProxyRunner
+::sal_Int32 SAL_CALL MozillaBootstrap::Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException)
+{
+#ifndef MINIMAL_PROFILEDISCOVER
+ ::rtl::OUString profileName = aCode->getProfileName();
+ ::rtl::OUString currProfileName = getCurrentProfile();
+ ::com::sun::star::mozilla::MozillaProductType currProduct = getCurrentProduct();
+
+ //if client provides a profileName, we will use it
+ if (profileName.getLength()
+ && ( aCode->getProductType() != currProduct || !profileName.equals(currProfileName)) )
+ setCurrentProfile(aCode->getProductType(),profileName);
+ MNSRunnable xRunnable;
+
+ return xRunnable.StartProxy(aCode);;
+#else
+ (void)aCode; /* avoid warning about unused parameter */
+ return -1;
+#endif
+}
+
+#ifdef MINIMAL_PROFILEDISCOVER
+#include <cppuhelper/factory.hxx>
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const ::rtl::OUString& aServiceImplName,
+ const Sequence< ::rtl::OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ ::rtl::OUString aMainKeyName;
+ aMainKeyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/"));
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES"));
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "MOZAB::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+ REGISTER_PROVIDER(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")),
+ aSNS, xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "Mozab::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+static Reference< XInterface > SAL_CALL createInstance( const Reference< XMultiServiceFactory >& rServiceManager )
+{
+ MozillaBootstrap * pBootstrap = reinterpret_cast<MozillaBootstrap*>(OMozillaBootstrap_CreateInstance(rServiceManager));
+ return *pBootstrap;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+
+ if (pServiceManager)
+ {
+ ::rtl::OUString aImplName( ::rtl::OUString::createFromAscii( pImplementationName ) );
+ Reference< XSingleServiceFactory > xFactory;
+ if (aImplName.equals( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.mozilla.MozillaBootstrap")) ))
+ {
+ Sequence< ::rtl::OUString > aSNS( 1 );
+ aSNS[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap"));
+
+ xFactory = ::cppu::createSingleFactory(
+ reinterpret_cast< XMultiServiceFactory* > ( pServiceManager),
+ aImplName, createInstance, aSNS );
+ }
+ if ( xFactory.is() )
+ {
+ xFactory->acquire();
+ pRet = xFactory.get();
+ }
+ }
+
+ return pRet;
+};
+
+#endif
diff --git a/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
new file mode 100644
index 000000000000..04e6e525d835
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MMozillaBootstrap.hxx
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef CONNECTIVITY_SMOZILLABOOTSTRAP_HXX
+#define CONNECTIVITY_SMOZILLABOOTSTRAP_HXX
+
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <cppuhelper/compbase2.hxx>
+#include <osl/module.h>
+
+
+#define MOZAB_MozillaBootstrap_IMPL_NAME "com.sun.star.comp.mozilla.MozillaBootstrap"
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::mozilla::XMozillaBootstrap,
+ ::com::sun::star::lang::XServiceInfo > OMozillaBootstrap_BASE;
+ class ProfileAccess;
+ class ProfileManager;
+ class MozillaBootstrap : public OMozillaBootstrap_BASE
+ {
+ protected:
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xMSFactory;
+
+ ::osl::Mutex m_aMutex; // mutex is need to control member access
+ virtual ~MozillaBootstrap();
+ protected:
+ ProfileAccess * m_ProfileAccess;
+ ProfileManager * m_ProfileManager;
+ public:
+
+ void Init();
+ MozillaBootstrap(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory);
+
+ // OComponentHelper
+ virtual void SAL_CALL disposing(void);
+ // XInterface
+ static ::rtl::OUString getImplementationName_Static( ) throw(::com::sun::star::uno::RuntimeException);
+ static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static( ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XServiceInfo
+ virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
+ virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
+
+ // XMozillaBootstrap
+
+ // XProfileDiscover
+ virtual ::sal_Int32 SAL_CALL getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XProfileManager
+ virtual ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::sal_Bool SAL_CALL isCurrentProfileLocked( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+
+ // XProxyRunner
+ virtual ::sal_Int32 SAL_CALL Run( const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode ) throw (::com::sun::star::uno::RuntimeException);
+
+ const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
+ & getMSFactory(void) const { return m_xMSFactory; }
+
+ };
+ }
+
+}
+
+#endif // CONNECTIVITY_SMozillaBootstrap_HXX
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx
new file mode 100644
index 000000000000..a5d3211fecab
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.cxx
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSFolders.hxx>
+
+#ifdef UNIX
+#include <sys/types.h>
+#include <strings.h>
+#include <string.h>
+#endif // End UNIX
+
+#ifdef WNT
+#include "pre_include_windows.h"
+#include <windows.h>
+#include <stdlib.h>
+#include <shlobj.h>
+#include <objidl.h>
+#include "post_include_windows.h"
+#endif // End WNT
+#include <osl/security.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.h>
+
+using namespace ::com::sun::star::mozilla;
+
+namespace
+{
+ #if defined(XP_MAC) || defined(XP_MACOSX) || defined(MACOSX)
+ #define APP_REGISTRY_NAME "Application Registry"
+ #elif defined(XP_WIN) || defined(XP_OS2)
+ #define APP_REGISTRY_NAME "registry.dat"
+ #else
+ #define APP_REGISTRY_NAME "appreg"
+ #endif
+
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_getUserDataDirectory()
+ {
+ ::osl::Security aSecurity;
+ ::rtl::OUString aConfigPath;
+
+ aSecurity.getConfigDir( aConfigPath );
+ return aConfigPath + ::rtl::OUString::createFromAscii( "/" );
+ }
+
+ // -------------------------------------------------------------------
+ static const char* DefaultProductDir[3][3] =
+ {
+ #if defined(XP_WIN)
+ { "Mozilla/", NULL, NULL },
+ { "Mozilla/Firefox/", NULL, NULL },
+ { "Thunderbird/", "Mozilla/Thunderbird/", NULL }
+ #elif(MACOSX)
+ { "../Mozilla/", NULL, NULL },
+ { "Firefox/", NULL, NULL },
+ { "../Thunderbird/", NULL, NULL }
+ #else
+ { ".mozilla/", NULL, NULL },
+ { ".mozilla/firefox/", NULL, NULL },
+ { ".thunderbird/", ".mozilla-thunderbird/", ".mozilla/thunderbird/" }
+ #endif
+ };
+
+ static const char* ProductRootEnvironmentVariable[3] =
+ {
+ "MOZILLA_PROFILE_ROOT",
+ "MOZILLA_FIREFOX_PROFILE_ROOT",
+ "MOZILLA_THUNDERBIRD_PROFILE_ROOT",
+ };
+
+ // -------------------------------------------------------------------
+ static ::rtl::OUString lcl_guessProfileRoot( MozillaProductType _product )
+ {
+ size_t productIndex = _product - 1;
+
+ static ::rtl::OUString s_productDirectories[3];
+
+ if ( !s_productDirectories[ productIndex ].getLength() )
+ {
+ ::rtl::OUString sProductPath;
+
+ // check whether we have an anevironment variable which helps us
+ const char* pProfileByEnv = getenv( ProductRootEnvironmentVariable[ productIndex ] );
+ if ( pProfileByEnv )
+ {
+ sProductPath = ::rtl::OUString( pProfileByEnv, rtl_str_getLength( pProfileByEnv ), osl_getThreadTextEncoding() );
+ // asume that this is fine, no further checks
+ }
+ else
+ {
+ ::rtl::OUString sProductDirCandidate;
+ const char* pProfileRegistry = ( _product == MozillaProductType_Mozilla ) ? APP_REGISTRY_NAME : "profiles.ini";
+
+ // check all possible candidates
+ for ( size_t i=0; i<3; ++i )
+ {
+ if ( NULL == DefaultProductDir[ productIndex ][ i ] )
+ break;
+
+ sProductDirCandidate = lcl_getUserDataDirectory() +
+ ::rtl::OUString::createFromAscii( DefaultProductDir[ productIndex ][ i ] );
+
+ // check existence
+ ::osl::DirectoryItem aRegistryItem;
+ ::osl::FileBase::RC result = ::osl::DirectoryItem::get( sProductDirCandidate + ::rtl::OUString::createFromAscii( pProfileRegistry ), aRegistryItem );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ ::osl::FileStatus aStatus( FileStatusMask_Validate );
+ result = aRegistryItem.getFileStatus( aStatus );
+ if ( result == ::osl::FileBase::E_None )
+ {
+ // the registry file exists
+ break;
+ }
+ }
+ }
+
+ ::osl::FileBase::getSystemPathFromFileURL( sProductDirCandidate, sProductPath );
+ }
+
+ s_productDirectories[ productIndex ] = sProductPath;
+ }
+
+ return s_productDirectories[ productIndex ];
+ }
+}
+
+// -----------------------------------------------------------------------
+::rtl::OUString getRegistryDir(MozillaProductType product)
+{
+ if (product == MozillaProductType_Default)
+ return ::rtl::OUString();
+
+ return lcl_guessProfileRoot( product );
+}
+#ifndef MINIMAL_PROFILEDISCOVER
+// -----------------------------------------------------------------------
+::rtl::OUString getRegistryFileName(MozillaProductType product)
+{
+ if (product == MozillaProductType_Default)
+ return ::rtl::OUString();
+
+ return getRegistryDir(product) + ::rtl::OUString::createFromAscii(APP_REGISTRY_NAME);
+}
+#endif
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx
new file mode 100644
index 000000000000..d69a5e3435bf
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSFolders.hxx
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MNSFOLDERS_HXX_
+#define _MNSFOLDERS_HXX_
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+
+#include <rtl/ustring.hxx>
+
+::rtl::OUString getRegistryDir(::com::sun::star::mozilla::MozillaProductType product);
+#ifndef MINIMAL_PROFILEDISCOVER
+::rtl::OUString getRegistryFileName(::com::sun::star::mozilla::MozillaProductType product);
+#endif
+
+#endif
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx
new file mode 100644
index 000000000000..0c8134e69809
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.cxx
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSINIParser.hxx>
+#include <rtl/byteseq.hxx>
+
+IniParser::IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException )
+{
+ OUString iniUrl;
+ if (osl_File_E_None != osl_getFileURLFromSystemPath(rIniName.pData, &iniUrl.pData))
+ return;
+
+
+#if OSL_DEBUG_LEVEL > 0
+ OString sFile = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE(__FILE__" -- parser() - %s\n", sFile.getStr());
+#endif
+ oslFileHandle handle=NULL;
+ oslFileError fileError = osl_File_E_INVAL;
+ try{
+ if (iniUrl.getLength())
+ fileError = osl_openFile(iniUrl.pData, &handle, osl_File_OpenFlag_Read);
+ }
+ catch(::com::sun::star::io::IOException e)
+ {
+#if OSL_DEBUG_LEVEL > 0
+ OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
+#endif
+ }
+
+ if (osl_File_E_None == fileError)
+ {
+ rtl::ByteSequence seq;
+ sal_uInt64 nSize = 0;
+
+ osl_getFileSize(handle, &nSize);
+ OUString sectionName = OUString::createFromAscii("no name section");
+ while (true)
+ {
+ sal_uInt64 nPos;
+ if (osl_File_E_None != osl_getFilePos(handle, &nPos) || nPos >= nSize)
+ break;
+ if (osl_File_E_None != osl_readLine(handle , (sal_Sequence **) &seq))
+ break;
+ OString line( (const sal_Char *) seq.getConstArray(), seq.getLength() );
+ sal_Int32 nIndex = line.indexOf('=');
+ if (nIndex >= 1)
+ {
+ ini_Section *aSection = &mAllSection[sectionName];
+ struct ini_NameValue nameValue;
+ nameValue.sName = OStringToOUString(
+ line.copy(0,nIndex).trim(), RTL_TEXTENCODING_ASCII_US );
+ nameValue.sValue = OStringToOUString(
+ line.copy(nIndex+1).trim(), RTL_TEXTENCODING_UTF8 );
+
+ aSection->lList.push_back(nameValue);
+
+ }
+ else
+ {
+ sal_Int32 nIndexStart = line.indexOf('[');
+ sal_Int32 nIndexEnd = line.indexOf(']');
+ if ( nIndexEnd > nIndexStart && nIndexStart >=0)
+ {
+ sectionName = OStringToOUString(
+ line.copy(nIndexStart + 1,nIndexEnd - nIndexStart -1).trim(), RTL_TEXTENCODING_ASCII_US );
+ if (!sectionName.getLength())
+ sectionName = OUString::createFromAscii("no name section");
+
+ ini_Section *aSection = &mAllSection[sectionName];
+ aSection->sName = sectionName;
+ }
+ }
+ }
+ osl_closeFile(handle);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ {
+ OString file_tmp = OUStringToOString(iniUrl, RTL_TEXTENCODING_ASCII_US);
+ OSL_TRACE( __FILE__" -- couldn't open file: %s", file_tmp.getStr() );
+ }
+#endif
+}
+#if OSL_DEBUG_LEVEL > 0
+void IniParser::Dump()
+{
+ IniSectionMap::iterator iBegin = mAllSection.begin();
+ IniSectionMap::iterator iEnd = mAllSection.end();
+ for(;iBegin != iEnd;iBegin++)
+ {
+ ini_Section *aSection = &(*iBegin).second;
+ OString sec_name_tmp = OUStringToOString(aSection->sName, RTL_TEXTENCODING_ASCII_US);
+ for(NameValueList::iterator itor=aSection->lList.begin();
+ itor != aSection->lList.end();
+ itor++)
+ {
+ struct ini_NameValue * aValue = &(*itor);
+ OString name_tmp = OUStringToOString(aValue->sName, RTL_TEXTENCODING_ASCII_US);
+ OString value_tmp = OUStringToOString(aValue->sValue, RTL_TEXTENCODING_UTF8);
+ OSL_TRACE(
+ " section=%s name=%s value=%s\n",
+ sec_name_tmp.getStr(),
+ name_tmp.getStr(),
+ value_tmp.getStr() );
+
+ }
+ }
+
+}
+#endif
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx
new file mode 100644
index 000000000000..0e36308946ef
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSINIParser.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef __MNSINIPARSER_HXX__
+#define __MNSINIPARSER_HXX__
+
+#include <rtl/ustring.hxx>
+#include <com/sun/star/io/IOException.hpp>
+#include <osl/process.h>
+using namespace rtl;
+
+#include <map>
+#include <list>
+
+#if OSL_DEBUG_LEVEL > 0
+#include <stdio.h>
+#endif
+
+struct ini_NameValue
+{
+ rtl::OUString sName;
+ rtl::OUString sValue;
+
+ inline ini_NameValue() SAL_THROW( () )
+ {}
+ inline ini_NameValue(
+ OUString const & name, OUString const & value ) SAL_THROW( () )
+ : sName( name ),
+ sValue( value )
+ {}
+};
+
+typedef std::list<
+ ini_NameValue
+> NameValueList;
+
+struct ini_Section
+{
+ rtl::OUString sName;
+ NameValueList lList;
+};
+typedef std::map<rtl::OUString,
+ ini_Section
+ >IniSectionMap;
+
+
+class IniParser
+{
+ IniSectionMap mAllSection;
+public:
+ IniSectionMap * getAllSection(){return &mAllSection;};
+ IniParser(OUString const & rIniName) throw(com::sun::star::io::IOException );
+#if OSL_DEBUG_LEVEL > 0
+ void Dump();
+#endif
+
+};
+
+#endif
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx
new file mode 100644
index 000000000000..89a2978ea040
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSInit.cxx
@@ -0,0 +1,347 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSInclude.hxx>
+
+#include "mozilla_nsinit.h"
+
+#include <MNSInit.hxx>
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#include <osl/file.hxx>
+#include <rtl/bootstrap.hxx>
+
+#ifndef CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+#include "MConfigAccess.hxx"
+#endif
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+#include <MNSTerminateListener.hxx>
+
+static nsIServiceManager* sServiceManager = nsnull;
+static sal_Int32 sInitCounter = 0;
+static sal_Bool s_bProfilePresentAfterInitialized = sal_False;
+
+static NS_DEFINE_CID(kProfileCID, NS_PROFILE_CID);
+static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
+
+static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
+static oslThread m_Mozilla_UI_Thread;
+static PRBool aLive=1;
+static ::osl::Condition m_aUI_Thread_Condition;
+
+#define HACK_AROUND_THREADING_ISSUES
+#define HACK_AROUND_NONREENTRANT_INITXPCOM
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+// XXX hack class to clean up XPCOM when this module is unloaded
+static PRBool sXPCOMInitializedFlag = PR_FALSE;
+#endif
+
+
+extern "C" void NS_SetupRegistry();
+
+ const PRUnichar* determineProfile( PRUnichar const* const* _pValidProfiles, const PRUint32 _nValidProfiles )
+{
+ // the fallback for the to-be-used user profile: the first profile
+ const PRUnichar* pUsedProfile = *_pValidProfiles;
+
+ // have a look what the configuration suggests as preferred profile
+ // PRUnichar != sal_Unicode in mingw
+ const PRUnichar* pPreferredProfile = reinterpret_cast_mingw_only< const PRUnichar* >( getUserProfile( ) );
+ if ( pPreferredProfile && *pPreferredProfile )
+ {
+ PRUnichar const* const* pLoop = _pValidProfiles;
+ PRUnichar const* const* pLoopEnd = pLoop + _nValidProfiles;
+ for ( ; pLoop != pLoopEnd; ++pLoop )
+ {
+ // compare the current and the preferred profile
+ // (by looping through the characters)
+ const PRUnichar* pCurrent = *pLoop;
+ const PRUnichar* pPref = pPreferredProfile;
+ while ( *pCurrent && ( *pCurrent == *pPref ) ) // testing one of them against 0 is enough because of the second clause
+ {
+ ++pCurrent;
+ ++pPref;
+ }
+ if ( *pCurrent == *pPref )
+ // the are equal
+ break;
+ }
+
+ if ( pLoop != pLoopEnd )
+ pUsedProfile = *pLoop;
+ return pUsedProfile;
+ }
+ else
+ return NULL;
+}
+
+
+sal_Bool MNS_InitXPCOM(sal_Bool* aProfileExists)
+{
+ nsresult rv;
+ OSL_TRACE( "IN : MNS_InitXPCOM() \n" );
+ // Reentrant calls to this method do nothing except increment a counter
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ // The first time, add another increment so that it'll be left until exit
+ // for the final cleanup to happen
+ sInitCounter++;
+#endif // HACK_AROUND_NONREENTRANT_INITXPCOM
+
+ // Initialise XPCOM
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ // Can't call NS_InitXPCom more than once or things go boom!
+ if (!sXPCOMInitializedFlag)
+#endif
+ {
+ nsCOMPtr<nsILocalFile> binDir;
+ // Note: if path3 construction fails, mozilla will default to using MOZILLA_FIVE_HOME in the NS_InitXPCOM2()
+ rtl::OUString path1(
+#if defined WNT
+ RTL_CONSTASCII_USTRINGPARAM("$BRAND_BASE_DIR/program")
+#else
+ RTL_CONSTASCII_USTRINGPARAM("$OOO_BASE_DIR/program")
+#endif
+ );
+ rtl::Bootstrap::expandMacros(path1);
+ rtl::OString path2;
+ if ((osl::FileBase::getSystemPathFromFileURL(path1, path1) ==
+ osl::FileBase::E_None) &&
+ path1.convertToString(
+ &path2, osl_getThreadTextEncoding(),
+ (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR |
+ RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR)))
+ {
+ nsDependentCString sPath(path2.getStr());
+ rv = NS_NewNativeLocalFile(sPath, PR_TRUE, getter_AddRefs(binDir));
+ if (NS_FAILED(rv))
+ return sal_False;
+ }
+
+
+
+ // Initialise XPCOM
+ NS_InitXPCOM2(&sServiceManager, binDir, NULL);
+
+// if (!sServiceManager)
+// return sal_False;
+
+#ifdef HACK_AROUND_NONREENTRANT_INITXPCOM
+ sXPCOMInitializedFlag = PR_TRUE;
+#endif
+ }
+
+
+ // Create the Event Queue for the UI thread...
+ //
+ // If an event queue already exists for the thread, then
+ // CreateThreadEventQueue(...) will fail...
+ // CreateThread0ueue(...) will fail...
+ nsCOMPtr<nsIEventQueueService> eventQService(
+ do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv));
+ if (NS_FAILED(rv))
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+
+ eventQService->CreateThreadEventQueue();
+
+// nsCOMPtr<nsIObserver> mStartupNotifier = do_CreateInstance(NS_APPSTARTUPNOTIFIER_CONTRACTID, &rv);
+// if(NS_FAILED(rv))
+// return rv;
+// mStartupNotifier->Observe(nsnull, APPSTARTUP_TOPIC, nsnull);
+
+#ifdef HACK_AROUND_THREADING_ISSUES
+ // XXX force certain objects to be created on the main thread
+ nsCOMPtr<nsIStringBundleService> sBundleService;
+ sBundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr<nsIStringBundle> stringBundle;
+ const char* propertyURL = "chrome://necko/locale/necko.properties";
+ rv = sBundleService->CreateBundle(propertyURL,
+ getter_AddRefs(stringBundle));
+ }
+#endif
+
+ // Need to create a Pref Service
+ nsCOMPtr< nsIPref > thePref = do_GetService( kPrefCID, &rv );
+ if (NS_SUCCEEDED(rv) )
+ {
+ OSL_TRACE("Created an nsIPref i/f\n");
+ thePref->ReadUserPrefs( nsnull );
+ *aProfileExists = sal_True ;
+ s_bProfilePresentAfterInitialized = sal_True;
+ }
+ OSL_TRACE( "OUT : MNS_InitXPCOM() - XPCOM Init\n" );
+
+ return sal_True;
+}
+
+void MNS_XPCOM_EventLoop()
+{
+ OSL_TRACE( "IN : MNS_XPCOM_EventLoop() \n" );
+ nsresult rv;
+ nsCOMPtr<nsIEventQueue> eventQ;
+ nsCOMPtr<nsIEventQueueService> eventQService;
+ rv=nsServiceManager::GetService(kEventQueueServiceCID,
+ NS_GET_IID(nsIEventQueueService),
+ getter_AddRefs(eventQService));
+
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD , getter_AddRefs(eventQ));
+ if (NS_FAILED(rv))
+ {
+ rv = eventQService->CreateThreadEventQueue();
+ if (NS_FAILED(rv))
+ return ;
+ else
+ rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));
+ }
+ }
+
+ if (NS_FAILED(rv)) return ;
+
+ PLEvent* event = nsnull;
+ m_aUI_Thread_Condition.set(); //we are ready to recive event
+ do
+ {
+ rv = eventQ->GetEvent(&event);
+ if (NS_FAILED(rv))
+ return ;
+ if (event)
+ eventQ->HandleEvent(event);
+ }while ( PR_SUCCESS == PR_Sleep( PR_MillisecondsToInterval(1)) && aLive );
+
+ eventQ->ProcessPendingEvents();
+ OSL_TRACE( "OUT : MNS_XPCOM_EventLoop() \n" );
+}
+
+extern "C" void MNS_Mozilla_UI_Thread( void *arg )
+{
+ aLive=1;
+ OSL_TRACE( "IN : MNS_Mozilla_UI_Thread() \n" );
+ UI_Thread_ARGS * args = (UI_Thread_ARGS*) arg;
+ sal_Bool* aProfileExists=args->bProfileExists;
+ delete args;
+ args=NULL;
+
+ //Init xpcom
+ if (!MNS_InitXPCOM(aProfileExists))
+ {
+ m_aUI_Thread_Condition.set(); // error happened
+ return;
+ }
+
+ //do the mozilla event loop
+ MNS_XPCOM_EventLoop();
+ //we are interupted
+
+ if (sServiceManager)
+ {
+ NS_RELEASE(sServiceManager);
+
+ // Terminate XPCOM & cleanup
+#ifndef HACK_AROUND_NONREENTRANT_INITXPCOM
+ NS_ShutdownXPCOM(sServiceManager);
+#endif
+ }
+
+ m_aUI_Thread_Condition.set(); //release all blocks
+
+ OSL_TRACE( "OUT : MNS_Mozilla_UI_Thread() \n" );
+
+}
+
+
+sal_Bool MNS_Init(sal_Bool& aProfileExists)
+{
+ aProfileExists = sal_False ;
+
+ OSL_TRACE( "IN : MNS_Init() \n" );
+ // Reentrant calls to this method do nothing except increment a counter
+ sInitCounter++;
+ if (sInitCounter > 1) {
+ OSL_TRACE( "IN : MNS_Init() wait for xpcom to be initted \n" );
+ //wait for xpcom to be initted
+ m_aUI_Thread_Condition.wait();
+
+ OSL_TRACE( "OUT : MNS_Init() : counter = %d\n", sInitCounter );
+ aProfileExists = s_bProfilePresentAfterInitialized;
+ return sal_True;
+ }
+
+ UI_Thread_ARGS * args = new UI_Thread_ARGS;
+ args->bProfileExists = &aProfileExists;
+
+ m_aUI_Thread_Condition.reset();
+ m_Mozilla_UI_Thread=osl_createThread(MNS_Mozilla_UI_Thread,
+ (void*)args);
+ if (!m_Mozilla_UI_Thread)
+ {
+ return sal_False;
+ }
+
+ //wait for xpcom to be initted
+ m_aUI_Thread_Condition.wait();
+
+ //Add Terminate Listener to XDesktop to get application exit event
+ MNSTerminateListener::addTerminateListener();
+
+ OSL_TRACE( "OUT : MNS_Init() - First Init\n" );
+
+ return sal_True;
+}
+
+sal_Bool MNS_Term(sal_Bool aForce)
+{
+ // Reentrant calls to this method do nothing except decrement a counter
+ OSL_TRACE( "IN : MNS_Term() \n" );
+ if (!aForce && sInitCounter > 1)
+ {
+ --sInitCounter;
+ OSL_TRACE( "OUT : MNS_Term() : counter = %d\n", sInitCounter );
+ return sal_True;
+ }
+ sInitCounter = 0;
+
+ aLive=0;
+
+ //wait for xpcom to be finished
+ TimeValue timeValue = { 1, 0 };
+ m_aUI_Thread_Condition.wait(&timeValue);
+
+
+ OSL_TRACE( "OUT : MNS_Term() - Final Term\n" );
+ return sal_True;
+}
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx
new file mode 100644
index 000000000000..22d40cf7379a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSInit.hxx
@@ -0,0 +1,45 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_NS_INIT_HXX_
+#define _CONNECTIVITY_MAB_NS_INIT_HXX_ 1
+#include "MNSDeclares.hxx"
+
+#include <sal/types.h>
+
+sal_Bool MNS_Init(sal_Bool& aProfileExists);
+sal_Bool MNS_Term(sal_Bool aForce=sal_False);
+
+sal_Bool MNS_InitXPCOM(sal_Bool* aProfileExists);
+typedef struct UI_Thread_ARGS
+{
+ sal_Bool* bProfileExists;
+}UI_Thread_ARGS;
+void MNS_XPCOM_EventLoop();
+
+#endif // _CONNECTIVITY_MAB_NS_INIT_HXX_ 1
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx
new file mode 100644
index 000000000000..93e2905c519b
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.cxx
@@ -0,0 +1,631 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfile.hxx"
+#include "MNSProfileDirServiceProvider.hxx"
+
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+using namespace rtl;
+
+// Interfaces Needed
+
+static Reference<XMozillaBootstrap> xMozillaBootstrap;
+
+
+static PRInt32 gInstanceCount = 0;
+
+// Profile database to remember which profile has been
+// created with UILocale and contentLocale on profileManager
+static nsProfileDirServiceProvider *gDirServiceProvider = nsnull;
+
+
+
+
+/*
+ * Constructor/Destructor
+ */
+nsProfile::nsProfile()
+{
+ mStartingUp = PR_FALSE;
+ mCurrentProfileAvailable = PR_FALSE;
+
+ mShutdownProfileToreDownNetwork = PR_FALSE;
+
+ mProfileChangeVetoed = PR_FALSE;
+ mProfileChangeFailed = PR_FALSE;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+
+
+}
+
+nsProfile::~nsProfile()
+{
+}
+
+
+nsresult
+nsProfile::Init()
+{
+ nsresult rv = NS_OK;
+ RegisterProfileManager(this);
+ if (gInstanceCount++ == 0) {
+ rv = NS_NewProfileDirServiceProvider( &gDirServiceProvider);
+ if (NS_SUCCEEDED(rv))
+ rv = gDirServiceProvider->Register();
+ }
+ return rv;
+}
+
+/*
+ * nsISupports Implementation
+ */
+NS_IMPL_THREADSAFE_ADDREF(nsProfile)
+NS_IMPL_THREADSAFE_RELEASE(nsProfile)
+
+NS_INTERFACE_MAP_BEGIN(nsProfile)
+ NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIProfile)
+ NS_INTERFACE_MAP_ENTRY(nsIProfile)
+ NS_INTERFACE_MAP_ENTRY(nsIProfileInternal)
+ NS_INTERFACE_MAP_ENTRY(nsIProfileChangeStatus)
+ NS_INTERFACE_MAP_ENTRY(nsIFactory)
+NS_INTERFACE_MAP_END
+
+/*
+ * nsIProfileChangeStatus Implementation
+ */
+
+NS_IMETHODIMP nsProfile::VetoChange()
+{
+ mProfileChangeVetoed = PR_TRUE;
+ return NS_OK;
+}
+
+NS_IMETHODIMP nsProfile::ChangeFailed()
+{
+ mProfileChangeFailed = PR_TRUE;
+ return NS_OK;
+}
+/*
+ * nsIProfile Implementation
+ */
+
+NS_IMETHODIMP nsProfile::GetProfileCount(PRInt32 *numProfiles)
+{
+ NS_ENSURE_ARG_POINTER(numProfiles);
+
+ *numProfiles = 0;
+
+ *numProfiles = xMozillaBootstrap->getProfileCount(xMozillaBootstrap->getCurrentProduct());
+ return NS_OK;
+}
+NS_IMETHODIMP nsProfile::GetProfileList(PRUint32 *length, PRUnichar ***profileNames)
+{
+ NS_ENSURE_ARG_POINTER(length);
+ NS_ENSURE_ARG_POINTER(profileNames);
+ *profileNames = nsnull;
+
+ ::com::sun::star::uno::Sequence< ::rtl::OUString > list;
+
+ *length = xMozillaBootstrap->getProfileList(xMozillaBootstrap->getCurrentProduct(),list);
+
+ const OUString * pArray = list.getConstArray();
+
+ nsresult rv = NS_OK;
+ PRInt32 count = list.getLength();
+ PRUnichar **outArray, **next;
+
+ next = outArray = (PRUnichar **)nsMemory::Alloc(count * sizeof(PRUnichar *));
+ if (!outArray)
+ return NS_ERROR_OUT_OF_MEMORY;
+
+ for (PRInt32 index=0; index < count; index++)
+ {
+ *next = (PRUnichar *)nsMemory::Clone(pArray[index].getStr(),(pArray[index].getLength()+1) * sizeof(PRUnichar ));
+ if (*next == nsnull)
+ {
+ rv = NS_ERROR_OUT_OF_MEMORY;
+ break;
+ }
+ next++;
+ }
+ *profileNames = outArray;
+ return rv;
+}
+NS_IMETHODIMP nsProfile::ProfileExists(const PRUnichar *profileName, PRBool *exists)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+ NS_ENSURE_ARG_POINTER(exists);
+
+ // PRUnichar != sal_Unicode in mingw
+ *exists = xMozillaBootstrap->getProfileExists(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName));
+ return NS_OK;
+}
+// Returns the name of the current profile i.e., the last used profile
+NS_IMETHODIMP
+nsProfile::GetCurrentProfile(PRUnichar **profileName)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+ *profileName = nsnull;
+
+ if (mCurrentProfileName.Length())
+ *profileName = (PRUnichar *)nsMemory::Clone(mCurrentProfileName.get(),(mCurrentProfileName.Length() + 1) * sizeof(PRUnichar ));
+ else
+ {
+ rtl::OUString profile = xMozillaBootstrap->getDefaultProfile(xMozillaBootstrap->getCurrentProduct());
+ *profileName = (PRUnichar *)nsMemory::Clone(profile.getStr(),( profile.getLength() + 1) * sizeof(PRUnichar ));
+ SetCurrentProfile(*profileName);
+ }
+
+ return (*profileName == nsnull) ? NS_ERROR_FAILURE : NS_OK;
+}
+
+NS_IMETHODIMP
+nsProfile::SetCurrentProfile(const PRUnichar * aCurrentProfile)
+{
+ NS_ENSURE_ARG(aCurrentProfile);
+
+ nsresult rv;
+ nsCOMPtr<nsIFile> profileDir;
+ PRBool exists;
+
+ // Ensure that the profile exists and its directory too.
+ rv = GetProfileDir(aCurrentProfile, getter_AddRefs(profileDir));
+ if (NS_FAILED(rv)) return rv;
+ rv = profileDir->Exists(&exists);
+ if (NS_FAILED(rv)) return rv;
+ if (!exists) return NS_ERROR_FILE_NOT_FOUND;
+
+ PRBool isSwitch = PRBool();
+
+ if (mCurrentProfileAvailable)
+ {
+ nsXPIDLString currProfileName;
+ rv = GetCurrentProfile(getter_Copies(currProfileName));
+ if (NS_FAILED(rv)) return rv;
+ if (nsCRT::strcmp(aCurrentProfile, currProfileName.get()) == 0)
+ return NS_OK;
+ else
+ isSwitch = PR_TRUE;
+ }
+ else
+ isSwitch = PR_FALSE;
+
+
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1", &rv);
+ NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE);
+
+ nsISupports *subject = (nsISupports *)((nsIProfile *)this);
+ NS_NAMED_LITERAL_STRING(switchString, "switch");
+ NS_NAMED_LITERAL_STRING(startupString, "startup");
+ const nsAFlatString& context = isSwitch ? switchString : startupString;
+
+ if (isSwitch)
+ {
+ rv = ShutDownCurrentProfile(nsIProfile::SHUTDOWN_PERSIST);
+ if (NS_FAILED(rv)) return NS_ERROR_ABORT;
+
+ // Phase 1: See if anybody objects to the profile being changed.
+ mProfileChangeVetoed = PR_FALSE;
+ observerService->NotifyObservers(subject, "profile-approve-change", context.get());
+ if (mProfileChangeVetoed)
+ return NS_OK;
+
+ // Phase 2a: Send the network teardown notification
+ observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get());
+ mShutdownProfileToreDownNetwork = PR_TRUE;
+
+ // Phase 2b: Send the "teardown" notification
+ observerService->NotifyObservers(subject, "profile-change-teardown", context.get());
+ if (mProfileChangeVetoed)
+ {
+ // Notify we will not proceed with changing the profile
+ observerService->NotifyObservers(subject, "profile-change-teardown-veto", context.get());
+
+ // Bring network back online and return
+ observerService->NotifyObservers(subject, "profile-change-net-restore", context.get());
+ return NS_OK;
+ }
+
+ // Phase 3: Notify observers of a profile change
+ observerService->NotifyObservers(subject, "profile-before-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ }
+
+//
+// // Do the profile switch
+ gDirServiceProvider->SetProfileDir(profileDir);
+ mCurrentProfileName.Assign(aCurrentProfile);
+// gProfileDataAccess->SetCurrentProfile(aCurrentProfile);
+
+ if (NS_FAILED(rv)) return rv;
+ mCurrentProfileAvailable = PR_TRUE;
+
+ if (!isSwitch)
+ {
+ // Ensure that the prefs service exists so it can respond to
+ // the notifications we're about to send around. It needs to.
+ nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
+ NS_ASSERTION(NS_SUCCEEDED(rv), "Could not get prefs service");
+ }
+
+ if (mShutdownProfileToreDownNetwork)
+ {
+ // Bring network back online
+ observerService->NotifyObservers(subject, "profile-change-net-restore", context.get());
+ mShutdownProfileToreDownNetwork = PR_FALSE;
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+ }
+
+ // Phase 4: Notify observers that the profile has changed - Here they respond to new profile
+ observerService->NotifyObservers(subject, "profile-do-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ // Phase 5: Now observers can respond to something another observer did in phase 4
+ observerService->NotifyObservers(subject, "profile-after-change", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ // Phase 6: One last notification after the new profile is established
+ observerService->NotifyObservers(subject, "profile-initial-state", context.get());
+ if (mProfileChangeFailed)
+ return NS_ERROR_ABORT;
+
+ return NS_OK;
+}
+/* void shutDownCurrentProfile (in unsigned long shutDownType); */
+NS_IMETHODIMP nsProfile::ShutDownCurrentProfile(PRUint32 shutDownType)
+{
+ nsresult rv;
+
+ // if shutDownType is not a well know value, skip the notifications
+ // see DoOnShutdown() in nsAppRunner.cpp for where we use this behaviour to our benefit
+ if (shutDownType == (PRUint32)SHUTDOWN_PERSIST || shutDownType == (PRUint32)SHUTDOWN_CLEANSE ) {
+ nsCOMPtr<nsIObserverService> observerService =
+ do_GetService("@mozilla.org/observer-service;1", &rv);
+ NS_ENSURE_TRUE(observerService, NS_ERROR_FAILURE);
+
+ nsISupports *subject = (nsISupports *)((nsIProfile *)this);
+
+ NS_NAMED_LITERAL_STRING(cleanseString, "shutdown-cleanse");
+ NS_NAMED_LITERAL_STRING(persistString, "shutdown-persist");
+ const nsAFlatString& context = (shutDownType == (PRUint32)SHUTDOWN_CLEANSE) ? cleanseString : persistString;
+
+ // Phase 1: See if anybody objects to the profile being changed.
+ mProfileChangeVetoed = PR_FALSE;
+ observerService->NotifyObservers(subject, "profile-approve-change", context.get());
+ if (mProfileChangeVetoed)
+ return NS_OK;
+
+ // Phase 2a: Send the network teardown notification
+ observerService->NotifyObservers(subject, "profile-change-net-teardown", context.get());
+ mShutdownProfileToreDownNetwork = PR_TRUE;
+
+ // Phase 2b: Send the "teardown" notification
+ observerService->NotifyObservers(subject, "profile-change-teardown", context.get());
+
+
+ // Phase 3: Notify observers of a profile change
+ observerService->NotifyObservers(subject, "profile-before-change", context.get());
+ }
+
+
+ gDirServiceProvider->SetProfileDir(nsnull);
+ mCurrentProfileAvailable = PR_FALSE;
+ mCurrentProfileName.Truncate(0);
+
+ return NS_OK;
+}
+/* void createNewProfile (in wstring profileName, in wstring nativeProfileDir, in wstring langcode, in boolean useExistingDir); */
+NS_IMETHODIMP nsProfile::CreateNewProfile(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*langcode*/, PRBool /*useExistingDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void renameProfile (in wstring oldName, in wstring newName); */
+NS_IMETHODIMP nsProfile::RenameProfile(const PRUnichar* /*oldName*/, const PRUnichar* /*newName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void deleteProfile (in wstring name, in boolean canDeleteFiles); */
+NS_IMETHODIMP nsProfile::DeleteProfile(const PRUnichar* /*name*/, PRBool /*canDeleteFiles*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void cloneProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::CloneProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+//nsIProfileInternal Implementation
+
+/* [noscript] void startupWithArgs (in nsICmdLineService cmdLine, in boolean canInteract); */
+class nsICmdLineService;
+
+NS_IMETHODIMP nsProfile::StartupWithArgs(nsICmdLineService* /*cmdLineArgs*/, PRBool /*canInteract*/)
+{
+ Init();
+ return NS_OK;
+}
+
+/* [noscript] readonly attribute boolean isStartingUp; */
+NS_IMETHODIMP nsProfile::GetIsStartingUp(PRBool *aIsStartingUp)
+{
+ NS_ENSURE_ARG_POINTER(aIsStartingUp);
+ *aIsStartingUp = mStartingUp;
+ return NS_OK;
+}
+
+/* long get4xProfileCount (); */
+NS_IMETHODIMP nsProfile::Get4xProfileCount(PRInt32* /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void getProfileListX (in unsigned long which, out unsigned long length, [array, size_is (length), retval] out wstring profileNames); */
+NS_IMETHODIMP nsProfile::GetProfileListX(PRUint32 /*whichKind*/, PRUint32* /*length*/, PRUnichar*** /*profileNames*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateProfileInfo (); */
+NS_IMETHODIMP nsProfile::MigrateProfileInfo()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateAllProfiles (); */
+NS_IMETHODIMP nsProfile::MigrateAllProfiles()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void migrateProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::MigrateProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void remigrateProfile (in wstring profileName); */
+NS_IMETHODIMP nsProfile::RemigrateProfile(const PRUnichar* /*profileName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void forgetCurrentProfile (); */
+NS_IMETHODIMP nsProfile::ForgetCurrentProfile()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void createDefaultProfile (); */
+NS_IMETHODIMP nsProfile::CreateDefaultProfile()
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsIFile getProfileDir (in wstring profileName); */
+// Gets the profiles directory for a given profile
+// Sets the given profile to be a current profile
+NS_IMETHODIMP nsProfile::GetProfileDir(const PRUnichar *profileName, nsIFile **profileDir)
+{
+ NS_ENSURE_ARG(profileName);
+ NS_ENSURE_ARG_POINTER(profileDir);
+ *profileDir = nsnull;
+
+ nsresult rv = NS_OK;
+
+ // PRUnichar != sal_Unicode in mingw
+ rtl::OUString path = xMozillaBootstrap->getProfilePath(xMozillaBootstrap->getCurrentProduct(),reinterpret_cast_mingw_only<const sal_Unicode *>(profileName));
+
+ nsCOMPtr<nsILocalFile> localFile;
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr()));
+
+ rv = NS_NewLocalFile(filePath, PR_TRUE,
+ getter_AddRefs(localFile));
+ if (localFile && NS_SUCCEEDED(rv))
+ return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)profileDir);
+ return rv;
+}
+
+/* wstring getProfilePath (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetProfilePath(const PRUnichar* /*profileName*/, PRUnichar** /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* nsILocalFile getOriginalProfileDir (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetOriginalProfileDir(const PRUnichar* /*profileName*/, nsILocalFile** /*originalDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* PRInt64 getProfileLastModTime (in wstring profileName); */
+NS_IMETHODIMP nsProfile::GetProfileLastModTime(const PRUnichar* /*profileName*/, PRInt64* /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* attribute boolean automigrate; */
+NS_IMETHODIMP nsProfile::GetAutomigrate(PRBool* /*aAutomigrate*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP nsProfile::SetAutomigrate(PRBool /*aAutomigrate*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute nsIFile defaultProfileParentDir; */
+NS_IMETHODIMP nsProfile::GetDefaultProfileParentDir(nsIFile** /*aDefaultProfileParentDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* readonly attribute wstring firstProfile; */
+NS_IMETHODIMP nsProfile::GetFirstProfile(PRUnichar **profileName)
+{
+ NS_ENSURE_ARG_POINTER(profileName);
+
+ return GetCurrentProfile(profileName);
+}
+
+/* attribute boolean startWithLastUsedProfile; */
+NS_IMETHODIMP nsProfile::GetStartWithLastUsedProfile(PRBool* /*aStartWithLastUsedProfile*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+NS_IMETHODIMP nsProfile::SetStartWithLastUsedProfile(PRBool /*aStartWithLastUsedProfile*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void updateRegistry (in nsIFile regName); */
+NS_IMETHODIMP nsProfile::UpdateRegistry(nsIFile* /*regName*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void getRegStrings (in wstring profileName, out wstring regString, out wstring regName, out wstring regEmail, out wstring regOption); */
+NS_IMETHODIMP nsProfile::GetRegStrings(const PRUnichar* /*profileName*/, PRUnichar** /*regString*/, PRUnichar** /*regName*/, PRUnichar** /*regEmail*/, PRUnichar** /*regOption*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] void setRegStrings (in wstring profileName, in wstring regString, in wstring regName, in wstring regEmail, in wstring regOption); */
+NS_IMETHODIMP nsProfile::SetRegStrings(const PRUnichar* /*profileName*/, const PRUnichar* /*regString*/, const PRUnichar* /*regName*/, const PRUnichar* /*regEmail*/, const PRUnichar* /*regOption*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* [noscript] string isRegStringSet (in wstring profileName); */
+NS_IMETHODIMP nsProfile::IsRegStringSet(const PRUnichar* /*profileName*/, char** /*_retval*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* void createNewProfileWithLocales (in wstring profileName, in wstring nativeProfileDir, in wstring UILocale, in wstring contentLocale, in boolean useExistingDir); */
+NS_IMETHODIMP nsProfile::CreateNewProfileWithLocales(const PRUnichar* /*profileName*/, const PRUnichar* /*nativeProfileDir*/, const PRUnichar* /*UILocale*/, const PRUnichar* /*contentLocale*/, PRBool /*useExistingDir*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+/* boolean isCurrentProfileAvailable (); */
+NS_IMETHODIMP nsProfile::IsCurrentProfileAvailable(PRBool *available)
+{
+ NS_ENSURE_ARG_POINTER(available);
+
+ *available = mCurrentProfileAvailable;
+ return NS_OK;
+}
+
+/* [noscript] void getCurrentProfileDir (out nsIFile profileDir); */
+// Returns the name of the current profile directory
+NS_IMETHODIMP nsProfile::GetCurrentProfileDir(nsIFile **profileDir)
+{
+ NS_ENSURE_ARG_POINTER(profileDir);
+ nsresult rv;
+
+ nsXPIDLString profileName;
+ rv = GetCurrentProfile(getter_Copies(profileName));
+ if (NS_FAILED(rv)) return rv;
+
+ rv = GetProfileDir(profileName, profileDir);
+ if (NS_FAILED(rv)) return rv;
+
+ return NS_OK;
+}
+
+//Implementation nsIFactory
+NS_IMETHODIMP
+nsProfile::LockFactory(PRBool /*aVal*/)
+{
+ return NS_ERROR_NOT_IMPLEMENTED;
+}
+
+NS_IMETHODIMP
+nsProfile::CreateInstance(nsISupports* aOuter, const nsID& aIID,
+ void** aResult)
+{
+ if (aOuter)
+ return NS_ERROR_NO_AGGREGATION;
+ // return this object
+ return QueryInterface(aIID, aResult);
+}
+
+//Register profile manager
+#include "nsIComponentManager.h"
+#include "nsIComponentRegistrar.h"
+
+static const nsCID kProfileManagerCID = NS_PROFILE_CID;
+
+#define NS_PROFILE_CONTRACTID \
+ "@mozilla.org/profile/manager;1"
+
+nsresult
+nsProfile::RegisterProfileManager(nsIProfile* aProfileService)
+{
+ nsCOMPtr<nsIServiceManager> mgr;
+ NS_GetServiceManager(getter_AddRefs(mgr));
+
+ NS_ASSERTION(mgr, "Not initialized!");
+
+ nsCOMPtr<nsIFactory> factory = do_QueryInterface(aProfileService);
+ NS_ASSERTION(factory, "Supposed to be an nsIFactory!");
+
+ nsCOMPtr<nsIComponentRegistrar> reg (do_QueryInterface(mgr));
+ if (!reg)
+ return NS_ERROR_NO_INTERFACE;
+
+ return reg->RegisterFactory(kProfileManagerCID,
+ "Profile Manager",
+ NS_PROFILE_CONTRACTID,
+ factory);
+}
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx
new file mode 100644
index 000000000000..cc3b1ea59a8a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfile.hxx
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "mozilla_nsprofile.h"
+
+#define _MAX_LENGTH 256
+
+class nsProfile: public nsIProfileInternal,
+ public nsIProfileChangeStatus,
+ public nsIFactory
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIPROFILE
+ NS_DECL_NSIPROFILEINTERNAL
+ NS_DECL_NSIPROFILECHANGESTATUS
+ NS_DECL_NSIFACTORY
+
+private:
+ PRBool mStartingUp;
+ PRBool mProfileChangeVetoed;
+ PRBool mProfileChangeFailed;
+
+ nsString mCurrentProfileName;
+ PRBool mCurrentProfileAvailable;
+
+ PRBool mIsContentLocaleSpecified;
+ nsCString mContentLocaleName;
+
+ PRBool mShutdownProfileToreDownNetwork;
+ nsresult Init();
+
+public:
+ nsProfile();
+ virtual ~nsProfile();
+
+public:
+ //We register an factory for Mozilla profile service its CID and CONTRACTID are NS_PROFILE_CID and NS_PROFILE_CONTRACTID
+ //After that, we does not need profile.dll/libprofile.so any more. Our profile service are diffrent from the orginal one in
+ //these areas:
+ //1. We do not lock Mozilla Profile,
+ //2. We do not change Mozilla Profile settings. We do not change default profile, do not create new profiles and
+ // do not write changes back to profile register
+ //3. We support can load both Thunderbird profile and Mozilla profiles
+ static nsresult RegisterProfileManager(nsIProfile* aProfileService);
+
+};
+
+extern nsresult ConvertStringToUnicode(nsCString& aCharset, const char* inString, nsAString& outString);
+extern nsresult GetPlatformCharset(nsCString& aCharset);
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx
new file mode 100644
index 000000000000..2ca0cab4f5ba
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.cxx
@@ -0,0 +1,240 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#if defined _MSC_VER
+ #pragma warning(disable:4710)
+#endif
+
+#include "pre_include_mozilla.h"
+#include "MNSProfileDirServiceProvider.hxx"
+#include "nsIAtom.h"
+#include "nsStaticAtom.h"
+#include "nsILocalFile.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsISupportsUtils.h"
+#include "post_include_mozilla.h"
+
+
+
+#define PREFS_FILE_50_NAME NS_LITERAL_CSTRING("prefs.js")
+
+
+nsIAtom* nsProfileDirServiceProvider::sApp_PrefsDirectory50;
+nsIAtom* nsProfileDirServiceProvider::sApp_PreferencesFile50;
+nsIAtom* nsProfileDirServiceProvider::sApp_UserProfileDirectory50;
+
+
+//*****************************************************************************
+// nsProfileDirServiceProvider::nsProfileDirServiceProvider
+//*****************************************************************************
+
+nsProfileDirServiceProvider::nsProfileDirServiceProvider()
+{
+}
+
+
+nsProfileDirServiceProvider::~nsProfileDirServiceProvider()
+{
+}
+
+nsresult
+nsProfileDirServiceProvider::SetProfileDir(nsIFile* aProfileDir)
+{
+ if (mProfileDir) {
+ PRBool isEqual;
+ if (aProfileDir &&
+ NS_SUCCEEDED(aProfileDir->Equals(mProfileDir, &isEqual)) && isEqual) {
+ NS_WARNING("Setting profile dir to same as current");
+ return NS_OK;
+ }
+ UndefineFileLocations();
+ }
+ mProfileDir = aProfileDir;
+ if (!mProfileDir)
+ return NS_OK;
+
+ nsresult rv = EnsureProfileFileExists(mProfileDir);
+ return rv;
+
+}
+
+nsresult
+nsProfileDirServiceProvider::Register()
+{
+ nsCOMPtr<nsIDirectoryService> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+ if (!directoryService)
+ return NS_ERROR_FAILURE;
+ return directoryService->RegisterProvider(this);
+}
+
+nsresult
+nsProfileDirServiceProvider::Shutdown()
+{
+ nsCOMPtr<nsIDirectoryService> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
+ if (!directoryService)
+ return NS_ERROR_FAILURE;
+ return directoryService->UnregisterProvider(this);
+}
+
+// nsProfileDirServiceProvider::nsISupports
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(nsProfileDirServiceProvider,
+ nsIDirectoryServiceProvider)
+
+// nsProfileDirServiceProvider::nsIDirectoryServiceProvider
+
+NS_IMETHODIMP
+nsProfileDirServiceProvider::GetFile(const char *prop, PRBool *persistant, nsIFile **_retval)
+{
+ NS_ENSURE_ARG(prop);
+ NS_ENSURE_ARG_POINTER(persistant);
+ NS_ENSURE_ARG_POINTER(_retval);
+
+ if (!mProfileDir)
+ return NS_ERROR_FAILURE;
+
+ *persistant = PR_TRUE;
+ nsIFile* domainDir = mProfileDir;
+
+
+ nsCOMPtr<nsIFile> localFile;
+ nsresult rv = NS_ERROR_FAILURE;
+
+ nsIAtom* inAtom = NS_NewAtom(prop);
+ NS_ENSURE_TRUE(inAtom, NS_ERROR_OUT_OF_MEMORY);
+
+ if (inAtom == sApp_PrefsDirectory50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ }
+ else if (inAtom == sApp_PreferencesFile50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ if (NS_SUCCEEDED(rv))
+ rv = localFile->AppendNative(PREFS_FILE_50_NAME);
+ }
+ else if (inAtom == sApp_UserProfileDirectory50) {
+ rv = domainDir->Clone(getter_AddRefs(localFile));
+ }
+
+ NS_RELEASE(inAtom);
+
+ if (localFile && NS_SUCCEEDED(rv))
+ return CallQueryInterface(localFile, _retval);
+
+ return rv;
+}
+
+//*****************************************************************************
+// Protected methods
+//*****************************************************************************
+
+nsresult
+nsProfileDirServiceProvider::Initialize()
+{
+
+ static const nsStaticAtom provider_atoms[] = {
+ { NS_APP_PREFS_50_DIR, &sApp_PrefsDirectory50 },
+ { NS_APP_PREFS_50_FILE, &sApp_PreferencesFile50 },
+ { NS_APP_USER_PROFILE_50_DIR, &sApp_UserProfileDirectory50 },
+ { NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, nsnull },
+ };
+
+ // Register our directory atoms
+ NS_RegisterStaticAtoms(provider_atoms, NS_ARRAY_LENGTH(provider_atoms));
+
+ return NS_OK;
+}
+
+nsresult
+nsProfileDirServiceProvider::EnsureProfileFileExists(nsIFile *aFile)
+{
+ nsresult rv;
+ PRBool exists;
+
+ rv = aFile->Exists(&exists);
+ if (NS_FAILED(rv))
+ return rv;
+ if (exists)
+ return NS_OK;
+
+ nsCOMPtr<nsIFile> defaultsFile;
+
+ // Attempt first to get the localized subdir of the defaults
+ rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_50_DIR, getter_AddRefs(defaultsFile));
+ if (NS_FAILED(rv)) {
+ // If that has not been defined, use the top level of the defaults
+ rv = NS_GetSpecialDirectory(NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR, getter_AddRefs(defaultsFile));
+ if (NS_FAILED(rv))
+ return rv;
+ }
+
+ mProfileDir = defaultsFile;
+ return rv;
+}
+
+
+nsresult
+nsProfileDirServiceProvider::UndefineFileLocations()
+{
+ nsresult rv;
+
+ nsCOMPtr<nsIProperties> directoryService =
+ do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
+ NS_ENSURE_TRUE(directoryService, NS_ERROR_FAILURE);
+
+ (void) directoryService->Undefine(NS_APP_PREFS_50_DIR);
+ (void) directoryService->Undefine(NS_APP_PREFS_50_FILE);
+ (void) directoryService->Undefine(NS_APP_USER_PROFILE_50_DIR);
+
+ return NS_OK;
+}
+
+//*****************************************************************************
+// Global creation function
+//*****************************************************************************
+
+nsresult NS_NewProfileDirServiceProvider(nsProfileDirServiceProvider** aProvider)
+{
+ NS_ENSURE_ARG_POINTER(aProvider);
+ *aProvider = nsnull;
+
+ nsProfileDirServiceProvider *prov = new nsProfileDirServiceProvider();
+ if (!prov)
+ return NS_ERROR_OUT_OF_MEMORY;
+ nsresult rv = prov->Initialize();
+ if (NS_FAILED(rv)) {
+ delete prov;
+ return rv;
+ }
+ NS_ADDREF(*aProvider = prov);
+ return NS_OK;
+}
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx
new file mode 100644
index 000000000000..c9f00c3249c7
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDirServiceProvider.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#include "mozilla_nsprofiledirserviceprovider.h"
+
+// Forward Declarations
+class nsIAtom;
+
+// --------------------------------------------------------------------------------------
+// nsProfileDirServiceProvider - The nsIDirectoryServiceProvider implementation used for
+// profile-relative file locations.
+// --------------------------------------------------------------------------------------
+
+class nsProfileDirServiceProvider: public nsIDirectoryServiceProvider
+{
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
+
+ friend nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider**);
+
+public:
+
+ virtual nsresult SetProfileDir(nsIFile* aProfileDir);
+ virtual nsresult Register();
+ virtual nsresult Shutdown();
+
+protected:
+ nsProfileDirServiceProvider();
+ virtual ~nsProfileDirServiceProvider();
+
+ nsresult Initialize();
+ nsresult EnsureProfileFileExists(nsIFile* profileDir);
+ nsresult UndefineFileLocations();
+
+protected:
+
+ // Atoms for file locations
+ static nsIAtom* sApp_PrefsDirectory50;
+ static nsIAtom* sApp_PreferencesFile50;
+ static nsIAtom* sApp_UserProfileDirectory50;
+
+ nsCOMPtr<nsIFile> mProfileDir;
+
+};
+
+
+// --------------------------------------------------------------------------------------
+
+/**
+ * Global method to create an instance of nsProfileDirServiceProvider
+ *
+ * @param aNotifyObservers If true, will send out profile startup
+ * notifications when the profile directory is set.
+ * See nsIProfileChangeStatus.
+ */
+
+nsresult NS_NewProfileDirServiceProvider( nsProfileDirServiceProvider** aProvider);
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
new file mode 100644
index 000000000000..aa20fb04a089
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.cxx
@@ -0,0 +1,535 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfileDiscover.hxx"
+#ifndef MINIMAL_PROFILEDISCOVER
+#include "MNSProfile.hxx"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIEnumerator.h"
+#include "prprf.h"
+#include "nsCOMPtr.h"
+#include "nsIComponentManager.h"
+#include "nsEscape.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsILocalFile.h"
+#include "nsReadableUtils.h"
+
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#include <Processes.h>
+#include <CFBundle.h>
+#include "nsILocalFileMac.h"
+#endif
+
+#ifdef XP_UNIX
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include "prnetdb.h"
+#include "prsystem.h"
+#endif
+
+#ifdef VMS
+#include <rmsdef.h>
+#endif
+
+#include "nsICharsetConverterManager.h"
+#include "nsIPlatformCharset.h"
+
+
+#if defined (XP_UNIX)
+#define USER_ENVIRONMENT_VARIABLE "USER"
+#define LOGNAME_ENVIRONMENT_VARIABLE "LOGNAME"
+#define HOME_ENVIRONMENT_VARIABLE "HOME"
+#define PROFILE_NAME_ENVIRONMENT_VARIABLE "PROFILE_NAME"
+#define PROFILE_HOME_ENVIRONMENT_VARIABLE "PROFILE_HOME"
+#define DEFAULT_UNIX_PROFILE_NAME "default"
+#ifndef XP_MACOSX /* Don't use symlink-based locking on OS X */
+#define USE_SYMLINK_LOCKING
+#endif
+#elif defined (XP_BEOS)
+#endif
+
+// IID and CIDs of all the services needed
+static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID);
+#endif
+
+// Registry Keys
+
+static ::rtl::OUString szProfileSubtreeString=::rtl::OUString::createFromAscii("Profiles");
+static ::rtl::OUString szCurrentProfileString= ::rtl::OUString::createFromAscii("CurrentProfile");
+static ::rtl::OUString szDirectoryString =::rtl::OUString::createFromAscii("directory");
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#include <MNSFolders.hxx>
+#include <MNSINIParser.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ ProfileStruct::ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ const ::rtl::OUString& aProfilePath
+#else
+ nsILocalFile * aProfilePath
+#endif
+ )
+ {
+ product=aProduct;
+ profileName = aProfileName;
+ profilePath = aProfilePath;
+ }
+ ::rtl::OUString ProfileStruct::getProfilePath()
+ {
+#ifdef MINIMAL_PROFILEDISCOVER
+ return profilePath;
+#else
+ if (profilePath)
+ {
+ nsAutoString path;
+ nsresult rv = profilePath->GetPath(path);
+ NS_ENSURE_SUCCESS(rv, ::rtl::OUString());
+ // PRUnichar != sal_Unicode in mingw
+ return ::rtl::OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(path.get()));
+ }
+ else
+ return ::rtl::OUString();
+#endif
+ }
+
+ ProfileAccess::~ProfileAccess()
+ {
+ }
+ ProfileAccess::ProfileAccess()
+ {
+ LoadProductsInfo();
+ }
+
+ sal_Int32 ProfileAccess::LoadProductsInfo()
+ {
+#ifndef MINIMAL_PROFILEDISCOVER
+ //load mozilla profiles to m_ProductProfileList
+ LoadMozillaProfiles();
+#endif
+ sal_Int32 count=static_cast<sal_Int32>(m_ProductProfileList[MozillaProductType_Mozilla].mProfileList.size());
+
+ //load thunderbird profiles to m_ProductProfileList
+ count += LoadXPToolkitProfiles(MozillaProductType_Thunderbird);
+
+ //load firefox profiles to m_ProductProfileList
+ //firefox profile does not containt address book, but maybe others need them
+ count += LoadXPToolkitProfiles(MozillaProductType_Firefox);
+ return count;
+ }
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult ProfileAccess::LoadMozillaProfiles()
+ {
+ sal_Int32 index=MozillaProductType_Mozilla;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ nsresult rv = NS_OK;
+
+ //step 1 : get mozilla registry file
+ nsCOMPtr<nsILocalFile> localFile;
+ ::rtl::OUString regDir( getRegistryFileName( MozillaProductType_Mozilla ) );
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString registryDir(reinterpret_cast_mingw_only<const PRUnichar *>(regDir.getStr()));
+ rv = NS_NewLocalFile(registryDir, PR_TRUE,
+ getter_AddRefs(localFile));
+ NS_ENSURE_SUCCESS(rv,rv);
+ PRBool bExist;
+ rv = localFile->Exists(&bExist);
+ NS_ENSURE_SUCCESS(rv,rv);
+ if (!bExist)
+ return rv;
+ nsCOMPtr<nsIRegistry> registry(do_CreateInstance(NS_REGISTRY_CONTRACTID, &rv));
+ NS_ENSURE_SUCCESS(rv,rv);
+ //step 2: open mozilla registry file
+ rv = registry->Open(localFile);
+ NS_ENSURE_SUCCESS(rv,rv);
+
+ nsCOMPtr<nsIEnumerator> enumKeys;
+ nsRegistryKey profilesTreeKey;
+
+ //step 3:Enumerator it
+ rv = registry->GetKey(nsIRegistry::Common,
+ // PRUnichar != sal_Unicode in mingw
+ reinterpret_cast_mingw_only<const PRUnichar *>(szProfileSubtreeString.getStr()),
+ &profilesTreeKey);
+ if (NS_FAILED(rv)) return rv;
+
+ nsXPIDLString tmpCurrentProfile;
+
+ // Get the current profile
+ rv = registry->GetString(profilesTreeKey,
+ // PRUnichar != sal_Unicode in mingw
+ reinterpret_cast_mingw_only<const PRUnichar *>(szCurrentProfileString.getStr()),
+ getter_Copies(tmpCurrentProfile));
+
+ if (tmpCurrentProfile)
+ {
+ // PRUnichar != sal_Unicode in mingw
+ m_Product.setCurrentProfile ( reinterpret_cast_mingw_only<const sal_Unicode *>(NS_STATIC_CAST(const PRUnichar*, tmpCurrentProfile)));
+ }
+
+
+ rv = registry->EnumerateSubtrees( profilesTreeKey, getter_AddRefs(enumKeys));
+ NS_ENSURE_SUCCESS(rv,rv);
+
+ rv = enumKeys->First();
+ NS_ENSURE_SUCCESS(rv,rv);
+
+ while (NS_OK != enumKeys->IsDone())
+ {
+ nsCOMPtr<nsISupports> base;
+
+ rv = enumKeys->CurrentItem( getter_AddRefs(base) );
+ NS_ENSURE_SUCCESS(rv,rv);
+ rv = enumKeys->Next();
+ NS_ENSURE_SUCCESS(rv,rv);
+
+ // Get specific interface.
+ nsCOMPtr <nsIRegistryNode> node;
+ nsIID nodeIID = NS_IREGISTRYNODE_IID;
+
+ rv = base->QueryInterface( nodeIID, getter_AddRefs(node));
+ if (NS_FAILED(rv)) continue;
+
+ // Get node name.
+ nsXPIDLString profile;
+ rv = node->GetName(getter_Copies(profile));
+ if (NS_FAILED(rv)) continue;
+
+ nsRegistryKey profKey;
+ rv = node->GetKey(&profKey);
+ if (NS_FAILED(rv)) continue;
+
+
+ nsCOMPtr<nsILocalFile> tempLocal;
+
+ nsXPIDLString regData;
+ rv = registry->GetString(profKey,
+ // PRUnichar != sal_Unicode in mingw
+ reinterpret_cast_mingw_only<const PRUnichar *>(szDirectoryString.getStr()),
+ getter_Copies(regData));
+ if (NS_FAILED(rv)) continue;
+
+#if defined(XP_MAC) || defined(XP_MACOSX) || defined(MACOSX)
+ rv = NS_NewNativeLocalFile(nsCString(), PR_TRUE, getter_AddRefs(tempLocal));
+ if (NS_SUCCEEDED(rv))
+ rv = tempLocal->SetPersistentDescriptor(NS_LossyConvertUCS2toASCII(regData));
+#else
+ rv = NS_NewLocalFile(regData, PR_TRUE, getter_AddRefs(tempLocal));
+#endif
+ //Add found profile to profile lists
+ if (NS_SUCCEEDED(rv) && tempLocal)
+ {
+ // PRUnichar != sal_Unicode in mingw
+ ProfileStruct* profileItem = new ProfileStruct(MozillaProductType_Mozilla,reinterpret_cast_mingw_only<const sal_Unicode *>(NS_STATIC_CAST(const PRUnichar*, profile)),tempLocal);
+ m_Product.mProfileList[profileItem->getProfileName()] = profileItem;
+ }
+
+ }
+ return rv;
+ }
+#endif
+ //Thunderbird and firefox profiles are saved in profiles.ini
+ sal_Int32 ProfileAccess::LoadXPToolkitProfiles(MozillaProductType product)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult rv;
+#endif
+ ::rtl::OUString regDir = getRegistryDir(product);
+ ::rtl::OUString profilesIni( regDir );
+ profilesIni += ::rtl::OUString::createFromAscii( "profiles.ini" );
+ IniParser parser( profilesIni );
+ IniSectionMap &mAllSection = *(parser.getAllSection());
+
+ IniSectionMap::iterator iBegin = mAllSection.begin();
+ IniSectionMap::iterator iEnd = mAllSection.end();
+ for(;iBegin != iEnd;iBegin++)
+ {
+ ini_Section *aSection = &(*iBegin).second;
+ ::rtl::OUString profileName;
+ ::rtl::OUString profilePath;
+ ::rtl::OUString sIsRelative;
+ ::rtl::OUString sIsDefault;
+
+ for(NameValueList::iterator itor=aSection->lList.begin();
+ itor != aSection->lList.end();
+ itor++)
+ {
+ struct ini_NameValue * aValue = &(*itor);
+ if (aValue->sName.equals(::rtl::OUString::createFromAscii("Name")))
+ {
+ profileName = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString::createFromAscii("IsRelative")))
+ {
+ sIsRelative = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString::createFromAscii("Path")))
+ {
+ profilePath = aValue->sValue;
+ }
+ else if (aValue->sName.equals(::rtl::OUString::createFromAscii("Default")))
+ {
+ sIsDefault = aValue->sValue;
+ }
+ }
+ if (profileName.getLength() != 0 || profilePath.getLength() != 0)
+ {
+ sal_Int32 isRelative = 0;
+ if (sIsRelative.getLength() != 0)
+ {
+ isRelative = sIsRelative.toInt32();
+ }
+
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsCOMPtr<nsILocalFile> rootDir;
+ rv = NS_NewLocalFile(EmptyString(), PR_TRUE,
+ getter_AddRefs(rootDir));
+ if (NS_FAILED(rv)) continue;
+
+ OString sPath = OUStringToOString(profilePath, RTL_TEXTENCODING_UTF8);
+ nsCAutoString filePath(sPath.getStr());
+
+ if (isRelative) {
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString registryDir( reinterpret_cast_mingw_only<const PRUnichar *>(regDir.getStr()) );
+ nsCOMPtr<nsILocalFile> mAppData;
+ rv = NS_NewLocalFile(registryDir, PR_TRUE,
+ getter_AddRefs(mAppData));
+ if (NS_FAILED(rv)) continue;
+ rv = rootDir->SetRelativeDescriptor(mAppData, filePath);
+ } else {
+ rv = rootDir->SetPersistentDescriptor(filePath);
+ }
+ if (NS_FAILED(rv)) continue;
+#endif
+
+ ProfileStruct* profileItem = new ProfileStruct(product,profileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ regDir + profilePath
+#else
+ rootDir
+#endif
+ );
+ m_Product.mProfileList[profileName] = profileItem;
+
+ sal_Int32 isDefault = 0;
+ if (sIsDefault.getLength() != 0)
+ {
+ isDefault = sIsDefault.toInt32();
+ }
+ if (isDefault)
+ m_Product.mCurrentProfileName = profileName;
+
+ }
+
+ }
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ //Profile not found
+ return ::rtl::OUString();
+ }
+ else
+ return m_Product.mProfileList[profileName]->getProfilePath();
+ }
+
+ ::sal_Int32 ProfileAccess::getProfileCount( ::com::sun::star::mozilla::MozillaProductType product) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+ ::sal_Int32 ProfileAccess::getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ list.realloc(static_cast<sal_Int32>(m_Product.mProfileList.size()));
+ sal_Int32 i=0;
+ for(ProfileList::iterator itor=m_Product.mProfileList.begin();
+ itor != m_Product.mProfileList.end();
+ itor++)
+ {
+ ProfileStruct * aProfile = (*itor).second;
+ list[i] = aProfile->getProfileName();
+ i++;
+ }
+
+ return static_cast< ::sal_Int32 >(m_Product.mProfileList.size());
+ }
+
+ ::rtl::OUString ProfileAccess::getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (m_Product.mCurrentProfileName.getLength() != 0)
+ {
+ //default profile setted in mozilla registry
+ return m_Product.mCurrentProfileName;
+ }
+ if (m_Product.mProfileList.size() == 0)
+ {
+ //there are not any profiles
+ return ::rtl::OUString();
+ }
+ ProfileStruct * aProfile = (*m_Product.mProfileList.begin()).second;
+ return aProfile->getProfileName();
+ }
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult ProfileAccess::isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist)
+ {
+ nsresult rv;
+ nsAutoString path;
+ aFile->GetPath(path);
+ rv = aFile->Exists(bExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!*bExist)
+ {
+ rv = aFile->IsSymlink(bExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+ }
+ nsresult ProfileAccess::isLockExist(nsILocalFile* aFile)
+ {
+#if defined (XP_MACOSX)
+ NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, ".parentlock");
+ NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock");
+#elif defined (XP_UNIX)
+ NS_ConvertASCIItoUTF16 OLD_LOCKFILE_NAME("lock");
+ NS_ConvertASCIItoUTF16 LOCKFILE_NAME(".parentlock");
+#else
+ NS_NAMED_LITERAL_STRING(OLD_LOCKFILE_NAME, "parent.lock");
+ NS_NAMED_LITERAL_STRING(LOCKFILE_NAME, "parent.lock");
+#endif
+
+ nsresult rv;
+
+ PRBool isDir;
+ rv = aFile->IsDirectory(&isDir);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!isDir)
+ return NS_ERROR_FILE_NOT_DIRECTORY;
+
+ nsCOMPtr<nsILocalFile> lockFile;
+ rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(lockFile)));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = lockFile->Append(LOCKFILE_NAME);
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRBool nExist=PR_FALSE;
+ rv = isExistFileOrSymlink(lockFile,&nExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!nExist) // Check OLD_LOCKFILE_NAME
+ {
+ nsCOMPtr<nsILocalFile> oldlockFile;
+ rv = aFile->Clone((nsIFile **)((void **)getter_AddRefs(oldlockFile)));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = oldlockFile->Append(OLD_LOCKFILE_NAME);
+ NS_ENSURE_SUCCESS(rv, rv);
+ rv = isExistFileOrSymlink(oldlockFile,&nExist);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return nExist;
+ }
+
+#endif
+ ::sal_Bool ProfileAccess::isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+#ifdef MINIMAL_PROFILEDISCOVER
+ (void)product; /* avoid warning about unused parameter */
+ (void)profileName; /* avoid warning about unused parameter */
+ return sal_True;
+#else
+ ::rtl::OUString path = getProfilePath(product,profileName);
+ if (!path.getLength())
+ return sal_True;
+
+ // PRUnichar != sal_Unicode in mingw
+ nsAutoString filePath(reinterpret_cast_mingw_only<const PRUnichar *>(path.getStr()));
+
+ nsresult rv;
+ nsCOMPtr<nsILocalFile> localFile;
+ rv = NS_NewLocalFile(filePath, PR_TRUE,
+ getter_AddRefs(localFile));
+ NS_ENSURE_SUCCESS(rv,sal_True);
+
+ PRBool exists = PR_FALSE;
+ rv = localFile->Exists(&exists);
+ NS_ENSURE_SUCCESS(rv, sal_True);
+ if (!exists)
+ return sal_True;
+
+ // If the profile is locked, we return true
+ rv = isLockExist(localFile);
+ if (rv)
+ return sal_True;
+ return sal_False;
+#endif
+ }
+
+ ::sal_Bool ProfileAccess::getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ sal_Int32 index=product;
+ ProductStruct &m_Product = m_ProductProfileList[index];
+ if (!m_Product.mProfileList.size() || m_Product.mProfileList.find(profileName) == m_Product.mProfileList.end())
+ {
+ return sal_False;
+ }
+ else
+ return sal_True;
+ }
+ }
+}
+
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
new file mode 100644
index 000000000000..9358cd65e650
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileDiscover.hxx
@@ -0,0 +1,134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MNSProfileDiscover_h___
+#define __MNSProfileDiscover_h___
+
+#ifndef MINIMAL_PROFILEDISCOVER
+#include "mozilla_profile_discover.h"
+#endif
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <rtl/ustring.hxx>
+
+#include <vector>
+#include <map>
+
+#ifdef XP_OS2
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#include <os2.h>
+#endif
+
+using namespace com::sun::star::mozilla;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileStruct;
+ }
+}
+typedef ::std::map < ::rtl::OUString, ::connectivity::mozab::ProfileStruct* > ProfileList;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileStruct
+ {
+ public:
+ ProfileStruct(MozillaProductType aProduct,::rtl::OUString aProfileName,
+#ifdef MINIMAL_PROFILEDISCOVER
+ const ::rtl::OUString &aProfilePath
+#else
+ nsILocalFile * aProfilePath
+#endif
+ );
+ MozillaProductType getProductType() { return product;}
+ ::rtl::OUString getProfileName(){ return profileName;}
+ ::rtl::OUString getProfilePath() ;
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsILocalFile *getProfileLocal(){ return profilePath;}
+#endif
+ protected:
+ MozillaProductType product;
+ ::rtl::OUString profileName;
+#ifdef MINIMAL_PROFILEDISCOVER
+ ::rtl::OUString profilePath;
+#else
+ nsCOMPtr<nsILocalFile> profilePath;
+#endif
+ };
+
+ class ProductStruct
+ {
+ public:
+ void setCurrentProfile(::rtl::OUString aProfileName){mCurrentProfileName = aProfileName;}
+
+ ::rtl::OUString mCurrentProfileName;
+
+ ProfileList mProfileList;
+ };
+
+ //Used to query profiles information
+ class ProfileAccess
+ {
+ public:
+
+ virtual ~ProfileAccess();
+ ProfileAccess();
+ ::rtl::OUString getProfilePath( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileCount( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Int32 getProfileList( ::com::sun::star::mozilla::MozillaProductType product, ::com::sun::star::uno::Sequence< ::rtl::OUString >& list ) throw (::com::sun::star::uno::RuntimeException);
+ ::rtl::OUString getDefaultProfile( ::com::sun::star::mozilla::MozillaProductType product ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL isProfileLocked( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ ::sal_Bool SAL_CALL getProfileExists( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException);
+ protected:
+ ProductStruct m_ProductProfileList[4];
+ sal_Int32 LoadProductsInfo();
+#ifndef MINIMAL_PROFILEDISCOVER
+ nsresult LoadMozillaProfiles();
+#endif
+ sal_Int32 LoadXPToolkitProfiles(MozillaProductType product);
+#ifndef MINIMAL_PROFILEDISCOVER
+ //used by isProfileLocked
+ nsresult isExistFileOrSymlink(nsILocalFile* aFile,PRBool *bExist);
+ nsresult isLockExist(nsILocalFile* aFile);
+#endif
+ };
+
+ }
+}
+
+#endif // __MNSProfileDiscover_h___
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx
new file mode 100644
index 000000000000..1e513a7315d2
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.cxx
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MNSProfileManager.hxx"
+#include "MNSProfile.hxx"
+
+#ifndef MAXPATHLEN
+#define MAXPATHLEN 1024
+#endif
+#include <MNSFolders.hxx>
+#include <MNSINIParser.hxx>
+
+static ::sal_Int32 nInitCounter=0;
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ ProfileManager::~ProfileManager()
+ {
+ }
+ ProfileManager::ProfileManager()
+ :m_CurrentProduct(MozillaProductType_Mozilla)
+ ,aProfile(NULL)
+ {
+ }
+ ::sal_Int32 ProfileManager::bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ if (!aProfile)
+ {
+ aProfile=new nsProfile();
+ aProfile->StartupWithArgs(NULL,sal_False);
+ }
+
+ setCurrentProfile(product,profileName);
+ return ++nInitCounter;
+ }
+ ::sal_Int32 ProfileManager::shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return --nInitCounter;
+ }
+ ::com::sun::star::mozilla::MozillaProductType ProfileManager::getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ return m_CurrentProduct;
+ }
+ ::rtl::OUString ProfileManager::getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ nsresult rv;
+ nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv));
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+ nsXPIDLString currentProfileStr;
+ //call GetCurrentProfile before call SetCurrentProfile will get the default profile
+ rv = theProfile->GetCurrentProfile(getter_Copies(currentProfileStr));
+ if (NS_FAILED(rv) || currentProfileStr.get() == nsnull)
+ return ::rtl::OUString();
+ // PRUnichar != sal_Unicode in mingw
+ return ::rtl::OUString(reinterpret_cast_mingw_only<const sal_Unicode *>(currentProfileStr.get()));
+ }
+ ::rtl::OUString ProfileManager::setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException)
+ {
+ ::rtl::OUString currentProfile = getCurrentProfile();
+ //if profileName not given, then skip and return curernt profile
+ if (!profileName.getLength() && m_CurrentProduct == product)
+ return currentProfile;
+
+ if (m_CurrentProduct == product && profileName.equals(currentProfile))
+ return currentProfile;
+ //set current product
+ m_CurrentProduct = product;
+
+ //get profile mozilla profile service
+ nsresult rv;
+ nsCOMPtr<nsIProfile> theProfile(do_GetService(NS_PROFILE_CONTRACTID,&rv));
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+
+ // PRUnichar != sal_Unicode in mingw
+ const PRUnichar* pUsedProfile = reinterpret_cast_mingw_only<const PRUnichar *>(profileName.getStr());
+ //set current profile
+ rv = theProfile->SetCurrentProfile( pUsedProfile );
+ if (NS_FAILED(rv)) return ::rtl::OUString();
+ return currentProfile;
+ }
+
+
+ }
+}
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx
new file mode 100644
index 000000000000..562efc6ba0f9
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSProfileManager.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef __MNSProfileManager_h___
+#define __MNSProfileManager_h___
+
+#include "mozilla_profilemanager.h"
+
+#include <sal/types.h>
+#include <osl/diagnose.h>
+#include <osl/conditn.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+#include <com/sun/star/uno/RuntimeException.hpp>
+#include <com/sun/star/uno/Sequence.hxx>
+
+#include <rtl/ustring.hxx>
+#include <vector>
+#include <map>
+
+#ifdef XP_OS2
+#define INCL_DOSERRORS
+#define INCL_DOSFILEMGR
+#include <os2.h>
+#endif
+
+using namespace com::sun::star::mozilla;
+class nsProfile;
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ProfileManager
+ {
+ public:
+
+ virtual ~ProfileManager();
+ ProfileManager();
+
+ ::sal_Int32 SAL_CALL bootupProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::sal_Int32 SAL_CALL shutdownProfile( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::com::sun::star::mozilla::MozillaProductType SAL_CALL getCurrentProduct( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::rtl::OUString SAL_CALL getCurrentProfile( ) throw (::com::sun::star::uno::RuntimeException) ;
+ ::rtl::OUString SAL_CALL setCurrentProfile( ::com::sun::star::mozilla::MozillaProductType product, const ::rtl::OUString& profileName ) throw (::com::sun::star::uno::RuntimeException) ;
+
+ protected:
+ ::com::sun::star::mozilla::MozillaProductType m_CurrentProduct;
+ nsProfile *aProfile;
+ };
+
+ }
+}
+
+#endif // __MNSProfileManager_h___
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx
new file mode 100644
index 000000000000..bf1d34ba8c7d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.cxx
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MNSRunnable.hxx"
+#include "MDatabaseMetaDataHelper.hxx"
+#include "MQuery.hxx"
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include "pre_include_mozilla.h"
+#include <nsIProxyObjectManager.h>
+// More Mozilla includes for LDAP Connection Test
+#include "prprf.h"
+#include "nsILDAPURL.h"
+#include "nsILDAPMessage.h"
+#include "nsILDAPMessageListener.h"
+#include "nsILDAPErrors.h"
+#include "nsILDAPConnection.h"
+#include "nsILDAPOperation.h"
+#include "post_include_mozilla.h"
+
+using namespace connectivity::mozab;
+
+/* Implementation file */
+NS_IMPL_ISUPPORTS1(MNSRunnable, nsIRunnable)
+
+static ::osl::Mutex m_aThreadMutex;
+
+nsIRunnable * MNSRunnable::ProxiedObject()
+{
+ if (!_ProxiedObject)
+ {
+
+ nsresult rv = NS_GetProxyForObject(NS_UI_THREAD_EVENTQ,
+ NS_GET_IID(nsIRunnable),
+ this,
+ PROXY_SYNC,
+ (void**)&_ProxiedObject);
+ (void)rv;
+
+ _ProxiedObject->AddRef();
+ }
+ return _ProxiedObject;
+}
+
+MNSRunnable::MNSRunnable()
+{
+ NS_INIT_ISUPPORTS();
+ _ProxiedObject=NULL;
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+ AddRef();
+}
+
+MNSRunnable::~MNSRunnable()
+{
+}
+sal_Int32 MNSRunnable::StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode)
+{
+ OSL_TRACE( "IN : MNSRunnable::StartProxy() \n" );
+ ::osl::MutexGuard aGuard(m_aThreadMutex);
+ xCode = aCode;
+ return ProxiedObject()->Run();
+}
+
+
+NS_IMETHODIMP MNSRunnable::Run()
+{
+ return static_cast<nsresult>(xCode->run());
+}
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx
new file mode 100644
index 000000000000..b0bc3ad65323
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/MNSRunnable.hxx
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_MOZAB_RUNNABLE_HXX_
+#define _CONNECTIVITY_MAB_MOZAB_RUNNABLE_HXX_
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+
+#include <MNSInclude.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_XCODEPROXY_HDL_
+#include <com/sun/star/mozilla/XCodeProxy.hpp>
+#endif
+
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::mozilla;
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MNSRunnable : public nsIRunnable
+ {
+ public:
+ nsIRunnable * ProxiedObject();
+ MNSRunnable();
+ virtual ~MNSRunnable();
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIRUNNABLE
+
+ public:
+ sal_Int32 StartProxy(const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy >& aCode); //Call this to start proxy
+
+ private:
+ nsIRunnable* _ProxiedObject;
+ Reference<XCodeProxy> xCode;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+ };
+ }
+}
+#endif //_CONNECTIVITY_MAB_MOZABHELPER_HXX_
diff --git a/connectivity/source/drivers/mozab/bootstrap/makefile.mk b/connectivity/source/drivers/mozab/bootstrap/makefile.mk
new file mode 100644
index 000000000000..6a4172da205d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+CALL_CDECL=TRUE
+
+PRJ=..$/..$/..$/..
+PRJINC=..$/..$/..
+PRJNAME=connectivity
+TARGET=mozbootstrap
+
+.IF "$(OS)" == "OS2"
+all:
+ @echo " Not building under OS/2"
+.ENDIF
+
+# --- Settings ----------------------------------
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- begin of mozilla specific stuff
+MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT)
+MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
+# --- end of mozilla specific stuff
+
+.INCLUDE : settings.mk
+
+.INCLUDE : $(PRJ)$/version.mk
+
+.INCLUDE : ../makefile_mozab.mk
+
+INCPRE += -I../mozillasrc
+
+# --- Files -------------------------------------
+
+SLOFILES += \
+ $(SLO)$/MNSINIParser.obj \
+ $(SLO)$/MNSProfileDiscover.obj \
+ $(SLO)$/MMozillaBootstrap.obj \
+ $(SLO)$/MNSFolders.obj
+
+.IF ( "$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES" ) || ( "$(WITH_MOZILLA)" == "NO" ) || ( "$(OS)" == "MACOSX" )
+CDEFS+=-DMINIMAL_PROFILEDISCOVER
+
+SHL1TARGET=$(TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1OBJS=$(SLOFILES)
+SHL1DEF=$(MISC)$/$(SHL1TARGET).def
+DEF1NAME=$(SHL1TARGET)
+
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(COMPHELPERLIB)
+
+.ELSE
+SLOFILES += \
+ $(SLO)$/MNSInit.obj \
+ $(SLO)$/MNSProfileManager.obj \
+ $(SLO)$/MNSRunnable.obj \
+ $(SLO)$/MNSProfile.obj \
+ $(SLO)$/MNSProfileDirServiceProvider.obj
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h
new file mode 100644
index 000000000000..f936167438f0
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsinit.h
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsIServiceManager.h"
+#include "nsIEventQueueService.h"
+#include "nsIChromeRegistry.h"
+
+#include "nsIStringBundle.h"
+
+#include "nsIDirectoryService.h"
+#include "nsIProfile.h"
+#include "nsIProfileInternal.h"
+#include "nsIPref.h"
+#include "nsXPIDLString.h"
+
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsEmbedAPI.h"
+
+#include "nsDirectoryService.h"
+
+#include "post_include_mozilla.h"
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h
new file mode 100644
index 000000000000..4486add0976c
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofile.h
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nscore.h"
+#include "nsIPrefService.h"
+#include "nsIPrefBranch.h"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIFactory.h"
+#include "nsIComponentManager.h"
+#include "nsIEnumerator.h"
+#include "nsXPIDLString.h"
+#include "nsEscape.h"
+#include "nsIURL.h"
+
+#include "prprf.h"
+
+#include "nsIProfile.h"
+#include "nsIProfileInternal.h"
+#include "nsIProfileStartupListener.h"
+#include "nsIProfileChangeStatus.h"
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsIRegistry.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIInterfaceRequestor.h"
+#include "nsIInterfaceRequestorUtils.h"
+#include "nsIDirectoryService.h"
+#include "nsIFactory.h"
+
+#include "nsIIOService.h"
+#include "nsNetUtil.h"
+#include "nsFileStream.h"
+#include "nsIStreamListener.h"
+#include "nsIServiceManager.h"
+#include "nsCOMPtr.h"
+#include "nsIModule.h"
+#include "nsIGenericFactory.h"
+#include "nsICategoryManager.h"
+#include "nsXPCOM.h"
+#include "nsISupportsPrimitives.h"
+#include "nsIDirectoryService.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsIChromeRegistry.h" // chromeReg
+#include "nsIStringBundle.h"
+#include "nsIObserverService.h"
+#include "nsHashtable.h"
+#include "nsIAtom.h"
+#include "nsCRT.h"
+
+#include "post_include_mozilla.h"
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h
new file mode 100644
index 000000000000..2970155a4063
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_nsprofiledirserviceprovider.h
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsIDirectoryService.h"
+#include "nsILocalFile.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+
+#include "post_include_mozilla.h"
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h
new file mode 100644
index 000000000000..3a63d3142fc1
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_profile_discover.h
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIRegistry.h"
+#include "nsXPIDLString.h"
+#include "nsVoidArray.h"
+#include "nsIFile.h"
+#include "nsILocalFile.h"
+
+#include "post_include_mozilla.h"
diff --git a/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h b/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h
new file mode 100644
index 000000000000..539baec0f60f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/mozilla_profilemanager.h
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include "nsCOMPtr.h"
+#include "nsISupports.h"
+#include "nsString.h"
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include "nsIRegistry.h"
+#include "nsXPIDLString.h"
+#include "nsVoidArray.h"
+#include "nsIFile.h"
+#include "nsILocalFile.h"
+
+#include "pratom.h"
+#include "prmem.h"
+#include "plstr.h"
+#include "prenv.h"
+
+#include "nsIEnumerator.h"
+#include "prprf.h"
+#include "nsCOMPtr.h"
+#include "nsIComponentManager.h"
+#include "nsEscape.h"
+#include "nsDirectoryServiceDefs.h"
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsILocalFile.h"
+#include "nsReadableUtils.h"
+
+
+#if defined(XP_MAC) || defined(XP_MACOSX)
+#include <Processes.h>
+#include <CFBundle.h>
+#include "nsILocalFileMac.h"
+#endif
+
+#ifdef XP_UNIX
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <signal.h>
+#include "prnetdb.h"
+#include "prsystem.h"
+#endif
+
+#ifdef VMS
+#include <rmsdef.h>
+#endif
+
+#include "nsIPlatformCharset.h"
+#include <MNSInit.hxx>
+
+#include "post_include_mozilla.h"
diff --git a/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h
new file mode 100644
index 000000000000..cd586ce0f574
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/post_include_windows.h
@@ -0,0 +1,30 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+ #pragma warning(pop)
+#endif
diff --git a/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h b/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h
new file mode 100644
index 000000000000..6ff8de285ad0
--- /dev/null
+++ b/connectivity/source/drivers/mozab/bootstrap/pre_include_windows.h
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifdef _MSC_VER
+ #pragma warning(push,1)
+ #pragma warning(disable:4668 4917)
+#endif
diff --git a/connectivity/source/drivers/mozab/exports.dxp b/connectivity/source/drivers/mozab/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/mozab/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/mozab/makefile.mk b/connectivity/source/drivers/mozab/makefile.mk
new file mode 100644
index 000000000000..b1e12fde6f8a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/makefile.mk
@@ -0,0 +1,186 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=mozab
+TARGET2=$(TARGET)drv
+VISIBILITY_HIDDEN=TRUE
+
+.IF ( "$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || "$(WITH_MOZILLA)" == "NO" || ( "$(OS)" == "MACOSX" ) || ( "$(OS)" == "OS2" )
+all:
+ @echo " Not building the mozilla address book driver"
+ @echo " dependency to Mozilla developer snapshots not feasable at the moment"
+ @echo " see http://bugzilla.mozilla.org/show_bug.cgi?id=135137"
+ @echo " see http://www.mozilla.org/issues/show_bug.cgi?id=91209"
+.ENDIF
+
+# --- begin of mozilla specific stuff
+MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT)
+MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
+
+.IF "$(OS)"=="WNT"
+ MOZ_EMBED_LIB := $(shell @-test -f $(MOZ_LIB)$/embed_base_s.lib && echo $(MOZ_LIB)$/embed_base_s.lib )
+ MOZ_REG_LIB := $(shell @-test -f $(MOZ_LIB)$/mozreg_s.lib && echo $(MOZ_LIB)$/mozreg_s.lib )
+
+ MOZ_EMBED_LIB *:= $(MOZ_LIB)$/baseembed_s.lib
+ MOZ_REG_LIB *:= $(MOZ_LIB)$/mozreg.lib
+
+ .IF "$(COM)"=="GCC"
+ MOZ_LIB_XPCOM= -L$(MOZ_LIB) -lembed_base_s -lnspr4 -lmozreg_s -lxpcom -lxpcom_core
+ .ELSE
+ LIB += $(MOZ_LIB)
+ MOZ_LIB_XPCOM= $(MOZ_EMBED_LIB) $(MOZ_LIB)$/nspr4.lib $(MOZ_REG_LIB) $(MOZ_LIB)$/xpcom.lib $(MOZ_LIB)$/xpcom_core.lib
+ .ENDIF
+
+.ELSE "$(OS)"=="WNT"
+ MOZ_LIB_XPCOM = -L$(MOZ_LIB) -lnspr4 -lxpcom_core -lmozreg_s -lembed_base_s
+.ENDIF
+# --- end of mozilla specific stuff
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+.IF "$(OS)"!="WNT"
+COMPONENT_CONFIG_DATA=$(TARGET)2.xcu
+COMPONENT_CONFIG_SCHEMA=$(TARGET)2.xcs
+.ENDIF
+
+# --- Settings ----------------------------------
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+
+.INCLUDE : $(PRJ)$/version.mk
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/MDriver.obj \
+ $(SLO)$/MServices.obj
+
+# --- MOZAB BASE Library -----------------------------------
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+SHL1TARGET= $(TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(TARGET)$(DLLPOSTFIX)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \
+ $(SLB)$/$(TARGET).lib
+DEFLIB1NAME=$(TARGET)
+
+
+# --- Files -------------------------------------
+MOZSLOFILES=\
+ $(SLO)$/MNSInit.obj \
+ $(SLO)$/MQueryHelper.obj \
+ $(SLO)$/MDatabaseMetaDataHelper.obj \
+ $(SLO)$/MQuery.obj \
+ $(SLO)$/MTypeConverter.obj \
+ $(SLO)$/MNameMapper.obj \
+ $(SLO)$/MNSMozabProxy.obj \
+ $(SLO)$/MNSTerminateListener.obj \
+ $(SLO)$/MMozillaBootstrap.obj \
+ $(SLO)$/MNSFolders.obj \
+ $(SLO)$/MNSProfileDiscover.obj \
+ $(SLO)$/MNSProfileManager.obj \
+ $(SLO)$/MNSINIParser.obj \
+ $(SLO)$/MNSRunnable.obj \
+ $(SLO)$/MNSProfile.obj \
+ $(SLO)$/MNSProfileDirServiceProvider.obj \
+ $(SLO)$/MLdapAttributeMap.obj
+
+
+SLO2FILES=\
+ $(SLO)$/MConfigAccess.obj \
+ $(SLO)$/MCatalog.obj \
+ $(SLO)$/MColumns.obj \
+ $(SLO)$/MTable.obj \
+ $(SLO)$/MTables.obj \
+ $(SLO)$/MColumnAlias.obj \
+ $(SLO)$/MPreparedStatement.obj \
+ $(SLO)$/MStatement.obj \
+ $(SLO)$/MResultSetMetaData.obj \
+ $(SLO)$/MResultSet.obj \
+ $(SLO)$/MDatabaseMetaData.obj \
+ $(SLO)$/MConnection.obj \
+ $(MOZSLOFILES)
+
+DEPOBJFILES=$(SLO2FILES)
+
+# --- MOZAB BASE Library -----------------------------------
+
+SHL2VERSIONMAP= $(TARGET2).map
+SHL2NOCHECK=TRUE
+SHL2TARGET= $(TARGET2)$(DLLPOSTFIX)
+SHL2OBJS=$(SLO2FILES)
+SHL2STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(VOSLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(MOZ_LIB_XPCOM)
+
+.IF "$(GUI)"=="WNT"
+ SHL2STDLIBS += \
+ $(SHELL32LIB)
+.ENDIF # "$(GUI)"=="WNT"
+
+SHL2DEPN=
+SHL2IMPLIB= i$(TARGET2)
+SHL2DEF= $(MISC)$/$(SHL2TARGET).def
+DEF2NAME= $(SHL2TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+# --- filter file ------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo _TI >$@
+ @echo _real >>$@
+
+$(MISC)$/$(SHL2TARGET).flt: makefile.mk
+ @echo ------------------------------
+ @echo _TI >$@
+ @echo _real >>$@
+
diff --git a/connectivity/source/drivers/mozab/makefile_mozab.mk b/connectivity/source/drivers/mozab/makefile_mozab.mk
new file mode 100644
index 000000000000..bf1ed5b8aee1
--- /dev/null
+++ b/connectivity/source/drivers/mozab/makefile_mozab.mk
@@ -0,0 +1,128 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+CDEFS += -DMOZILLA_INTERNAL_API
+
+.IF "$(GUI)"=="UNX"
+ .IF "$(COMNAME)"=="sunpro5"
+ CFLAGS += -features=tmplife
+ #This flag is needed to build mozilla 1.7 code
+ .ENDIF # "$(COMNAME)"=="sunpro5"
+.ENDIF
+
+MOZINC = . \
+ -I.. \
+ -I$(MOZ_INC) \
+ -I$(MOZ_INC)$/nspr \
+ -I$(MOZ_INC)$/xpcom \
+ -I$(MOZ_INC)$/string \
+ -I$(MOZ_INC)$/rdf \
+ -I$(MOZ_INC)$/msgbase \
+ -I$(MOZ_INC)$/addrbook \
+ -I$(MOZ_INC)$/mork \
+ -I$(MOZ_INC)$/locale \
+ -I$(MOZ_INC)$/pref \
+ -I$(MOZ_INC)$/mime \
+ -I$(MOZ_INC)$/chrome \
+ -I$(MOZ_INC)$/necko \
+ -I$(MOZ_INC)$/intl \
+ -I$(MOZ_INC)$/profile \
+ -I$(MOZ_INC)$/embed_base \
+ -I$(MOZ_INC)$/mozldap \
+ -I$(MOZ_INC)$/uconv \
+ -I$(MOZ_INC)$/xpcom_obsolete \
+ -I$(MOZ_INC)$/content
+
+.IF "$(GUI)" == "WNT"
+ CDEFS += \
+ -DMOZILLA_CLIENT \
+ -DXP_PC \
+ -DXP_WIN \
+ -DXP_WIN32 \
+ -DOJI \
+ -DWIN32 \
+ -D_X86_ \
+ -D_WINDOWS \
+ -DMOZ_XUL \
+ -DMOZ_REFLOW_PERF \
+ -DMOZ_REFLOW_PERF_DSP
+ .IF "$(COM)" == "GCC"
+ INCPOST += $(MOZINC)
+ CFLAGSCXX += \
+ -fno-rtti \
+ -Wall \
+ -Wconversion \
+ -Wpointer-arith \
+ -Wcast-align \
+ -Woverloaded-virtual \
+ -Wsynth \
+ -Wno-long-long
+ .ELSE # .IF "$(COM)" == "GCC"
+ INCPRE += $(MOZINC)
+ .IF "$(DBG_LEVEL)" != "0"
+ .IF "$(CCNUMVER)" >= "001399999999"
+ CDEFS += -D_STL_NOFORCE_MANIFEST
+ .ENDIF # .IF "$(CCNUMVER)" >= "001399999999"
+ .ENDIF # .IF "$(DBG_LEVEL)" != "0"
+ .ENDIF # .IF "$(COM)" == "GCC"
+.ENDIF # .IF "$(GUI)" == "WNT"
+
+.IF "$(GUI)" == "UNX"
+ INCPOST += $(MOZINC)
+ CDEFS+= -DMOZILLA_CLIENT \
+ -DXP_UNIX
+ .IF "$(OS)" == "LINUX"
+ CFLAGS += -fPIC -g
+ CDEFS += -DOJI
+ CFLAGSCXX += \
+ -fno-rtti \
+ -Wconversion \
+ -Wpointer-arith \
+ -Wcast-align \
+ -Woverloaded-virtual \
+ -Wsynth \
+ -Wno-long-long \
+ -pthread
+ CDEFS += -DTRACING
+ .ELIF "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX"
+ CFLAGS += -fPIC
+ CFLAGSCXX += \
+ -fno-rtti \
+ -Wconversion \
+ -Wpointer-arith \
+ -Wcast-align \
+ -Woverloaded-virtual \
+ -Wsynth \
+ -Wno-long-long \
+ -Wno-deprecated
+ CDEFS += -DTRACING
+ .ENDIF # "$(OS)" == "NETBSD" || "$(OS)" == "MACOSX"
+
+ SHL1TARGET_NAME=$(TARGET)$(MOZAB_MAJOR)
+
+.ENDIF # "$(GUI)" == "UNX"
+
diff --git a/connectivity/source/drivers/mozab/mozab.xcu b/connectivity/source/drivers/mozab/mozab.xcu
new file mode 100755
index 000000000000..c92209e09e5a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozab.xcu
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:outlook" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Microsoft Outlook Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:outlookexp" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Microsoft Windows Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:mozilla:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Mozilla Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:thunderbird:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Thunderbird Address Book</value>
+ </prop>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:ldap:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">LDAP Address Book</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="BaseDN" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="MaxRowCount" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>100</value>
+ </prop>
+ </node>
+ <node oor:name="PortNumber" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>389</value>
+ </prop>
+ </node>
+ <node oor:name="UseSSL" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/mozab/mozab.xml b/connectivity/source/drivers/mozab/mozab.xml
new file mode 100644
index 000000000000..30ec41f7263a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozab.xml
@@ -0,0 +1,82 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE COMPONENTDESCRIPTION PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name> mozabdrv2 </module-name>
+ <component-description>
+ <Author>Your name</Author>
+ <Name>com.sun.star.comp.sdbc.MozabDriver</Name>
+ <Description>
+ This is the implementation of the sdbc-mozab bridge.
+ </Description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.sdbc.Driver </supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <component-description>
+ <Author>Wind Li</Author>
+ <Name>com.sun.star.comp.mozilla.MozillaBootstrap</Name>
+ <Description>
+ This is the implementation of the MozillaBootstrap for sdbc-mozab bridge and xmlsec.
+ </Description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service> com.sun.star.mozilla.MozillaBootstrap</supported-service>
+ <service-dependency> ... </service-dependency>
+ </component-description>
+ <project-build-dependency> cppuhelper </project-build-dependency>
+ <project-build-dependency> cppu </project-build-dependency>
+ <project-build-dependency> sal </project-build-dependency>
+ <project-build-dependency> vos </project-build-dependency>
+
+ <runtime-module-dependency> cppuhelper </runtime-module-dependency>
+ <runtime-module-dependency> cppu1 </runtime-module-dependency>
+ <runtime-module-dependency> sal1 </runtime-module-dependency>
+ <runtime-module-dependency> vos </runtime-module-dependency>
+
+
+
+ <type> com.sun.star.util.XCancellable </type>
+ <type> com.sun.star.util.XNumberFormatter </type>
+ <type> com.sun.star.uno.TypeClass </type>
+ <type> com.sun.star.uno.XWeak </type>
+ <type> com.sun.star.uno.XAggregation </type>
+ <type> com.sun.star.beans.XPropertyState </type>
+ <type> com.sun.star.beans.XPropertySet </type>
+ <type> com.sun.star.beans.PropertyValue </type>
+ <type> com.sun.star.beans.XMultiPropertySet </type>
+ <type> com.sun.star.beans.XFastPropertySet </type>
+ <type> com.sun.star.lang.XTypeProvider </type>
+ <type> com.sun.star.lang.EventObject </type>
+ <type> com.sun.star.lang.XComponent </type>
+ <type> com.sun.star.lang.IllegalArgumentException </type>
+ <type> com.sun.star.lang.XMultiServiceFactory </type>
+ <type> com.sun.star.java.XJavaThreadRegister_11 </type>
+ <type> com.sun.star.java.XJavaVM </type>
+ <type> com.sun.star.sdbc.XConnection </type>
+ <type> com.sun.star.sdbc.XStatement </type>
+ <type> com.sun.star.sdbc.XResultSet </type>
+ <type> com.sun.star.sdbc.XResultSetMetaDataSupplier</type>
+ <type> com.sun.star.sdbc.XColumnLocate </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XWarningsSupplier </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbc.XMultipleResults </type>
+ <type> com.sun.star.sdbc.XBatchExecution </type>
+ <type> com.sun.star.sdbc.XPreparedBatchExecution </type>
+ <type> com.sun.star.sdbc.XParameters </type>
+ <type> com.sun.star.sdbc.XOutParameters </type>
+ <type> com.sun.star.sdbc.DriverPropertyInfo </type>
+ <type> com.sun.star.sdbc.XRow </type>
+ <type> com.sun.star.sdb.XColumnUpdate </type>
+ <type> com.sun.star.sdb.XColumn </type>
+ <type> com.sun.star.sdbc.XResultSetUpdate </type>
+ <type> com.sun.star.sdbc.XRowUpdate </type>
+ <type> com.sun.star.sdbcx.XRowLocate </type>
+ <type> com.sun.star.sdbcx.XDeleteRows </type>
+
+</module-description>
+
+
diff --git a/connectivity/source/drivers/mozab/mozab2.xcu b/connectivity/source/drivers/mozab/mozab2.xcu
new file mode 100755
index 000000000000..e7c24143f5a1
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozab2.xcu
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:address:mozilla:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Mozilla Address Book</value>
+ </prop>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:thunderbird:" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">Thunderbird Address Book</value>
+ </prop>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:address:ldap:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.MozabDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">LDAP Address Book</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="BaseDN" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="MaxRowCount" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>100</value>
+ </prop>
+ </node>
+ <node oor:name="PortNumber" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:int">
+ <value>389</value>
+ </prop>
+ </node>
+ <node oor:name="UseSSL" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/mozab/mozabdrv.map b/connectivity/source/drivers/mozab/mozabdrv.map
new file mode 100644
index 000000000000..a431a0737754
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozabdrv.map
@@ -0,0 +1,8 @@
+UDK_3_0_0 {
+ global:
+ OMozabConnection_CreateInstance;
+ OMozillaBootstrap_CreateInstance;
+ setMozabServiceFactory;
+ local:
+ *;
+};
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx
new file mode 100644
index 000000000000..ae143d7c4d0f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.cxx
@@ -0,0 +1,806 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+// Mozilla includes.
+#include <MNSInclude.hxx>
+
+#include "resource/mozab_res.hrc"
+#include "MDatabaseMetaDataHelper.hxx"
+#ifndef _CONNECTIVITY_MAB_CONVERSIONS_HXX_
+#include "MTypeConverter.hxx"
+#endif
+#ifndef CONNECTIVITY_MOZAB_MCONFIGACCESS_HXX
+#include "MConfigAccess.hxx"
+#endif
+#include <connectivity/dbexception.hxx>
+#include <comphelper/uno3.hxx>
+#include <comphelper/sequence.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include <nsIAbDirFactoryService.h>
+#include <MNSInit.hxx>
+#include <MNameMapper.hxx>
+#include "MNSMozabProxy.hxx"
+#include <MNSDeclares.hxx>
+
+static ::osl::Mutex m_aMetaMutex;
+
+#include <osl/diagnose.h>
+#include <com/sun/star/uno/Reference.hxx>
+#include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/uno/XInterface.hpp>
+#include <com/sun/star/uno/Exception.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/beans/Property.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/beans/XPropertySetInfo.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdb/ErrorCondition.hpp>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+static NS_DEFINE_CID(kAbDirFactoryServiceCID, NS_ABDIRFACTORYSERVICE_CID);
+static NS_DEFINE_CID(kAddrBookSessionCID, NS_ADDRBOOKSESSION_CID);
+
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace com::sun::star::mozilla;
+using namespace com::sun::star::sdb;
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ static const char * const s_pADDRESSBOOKROOTDIR = "moz-abdirectory://";
+ }
+}
+
+extern sal_Bool MNS_Init(sal_Bool& aProfileExists);
+
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()
+ :m_bProfileExists(sal_False)
+{
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()\n" );
+
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::MDatabaseMetaDataHelper()\n" );
+
+}
+// -------------------------------------------------------------------------
+MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()
+{
+ m_aTableNames.clear();
+ m_aTableTypes.clear();
+
+ if (m_bProfileExists)
+ {
+ Reference<XMozillaBootstrap> xMozillaBootstrap;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+ m_bProfileExists = xMozillaBootstrap->shutdownProfile() > 0;
+ }
+
+ OSL_TRACE( "IN/OUT MDatabaseMetaDataHelper::~MDatabaseMetaDataHelper()\n" );
+}
+
+static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array);
+//enum all sub folders
+static nsresult enumSubs(nsIAbDirectory * parentDir,nsISupportsArray * array)
+{
+ nsresult rv = NS_OK ;
+ nsCOMPtr<nsISimpleEnumerator> subDirectories;
+ rv = parentDir->GetChildNodes(getter_AddRefs(subDirectories));
+ if (NS_FAILED(rv)) { return rv; }
+
+ rv = enumSubs(subDirectories,array);
+ return rv;
+}
+
+#include <prmem.h> //need for PR_FREEIF
+static nsresult insertPABDescription()
+{
+ nsresult rv = NS_OK ;
+ // mozilla loads the descriptions of pab and history from a file named addressbook.properties
+ // we never deliver it with OOo,so mozab does not auot load personal addressbook and Collected addresses
+ // If we want to deliver addressbook.properties with OOo,we have to deal with hole mozilla chrome mechanism.
+ // So I insert the descriptiones as user prefes,they will cover the default value.
+
+ //"Personal Address Book" "Collected Addresses" are loaded from officecfg
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString pabPrefName(NS_LITERAL_CSTRING("ldap_2.servers.pab.description"));
+
+ sal_Bool bSetted=sal_False;
+ char *value = nsnull;
+ if (0 == prefs->CopyCharPref(pabPrefName.get(), &value))
+ {
+ if (!(value == nsnull || value[0] == 0))
+ {
+ bSetted = sal_True;
+ }
+ }
+ PR_FREEIF (value);
+ value=nsnull;
+ if (bSetted == sal_True)
+ {
+ const char* pPabDescription = static_cast< const char* >( getPabDescription( ) );
+ rv = prefs->SetCharPref (pabPrefName.get(), pPabDescription);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+
+ nsCAutoString hisPrefName(NS_LITERAL_CSTRING("ldap_2.servers.history.description"));
+
+ bSetted=sal_False;
+ if (0 == prefs->CopyCharPref(hisPrefName.get(), &value))
+ {
+ if (!(value == nsnull || value[0] == 0))
+ {
+ bSetted = sal_True;
+ }
+ }
+ PR_FREEIF (value);
+ value=nsnull;
+ if (bSetted == sal_True)
+ {
+ const char* pHisDescription = static_cast< const char* >( getHisDescription( ) );
+
+ rv = prefs->SetCharPref (hisPrefName.get(), pHisDescription);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+}
+//
+// nsAbDirectoryDataSource
+//
+#define NS_RDF_CONTRACTID "@mozilla.org/rdf"
+#define NS_RDF_DATASOURCE_CONTRACTID NS_RDF_CONTRACTID "/datasource;1"
+#define NS_RDF_DATASOURCE_CONTRACTID_PREFIX NS_RDF_DATASOURCE_CONTRACTID "?name="
+#define NS_ABDIRECTORYDATASOURCE_CONTRACTID \
+ NS_RDF_DATASOURCE_CONTRACTID_PREFIX "addressdirectory"
+#define database_uri "@mozilla.org/rdf/datasource;1?name=addressdirectory"
+#define NS_ABDIRECTORYDATASOURCE_CID \
+{ /* 0A79186D-F754-11d2-A2DA-001083003D0C */ \
+ 0xa79186d, 0xf754, 0x11d2, \
+ {0xa2, 0xda, 0x0, 0x10, 0x83, 0x0, 0x3d, 0xc} \
+}
+
+// -------------------------------------------------------------------------
+// Case where we get a parent uri, and need to list its children.
+static nsresult getSubsFromParent(const rtl::OString& aParent, nsIEnumerator **aSubs)
+{
+
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+
+ retCode = insertPABDescription();
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIRDFResource> rdfResource ;
+
+ nsCOMPtr<nsIRDFDataSource> rdfDirectory ;
+
+ rtl::OString dir("rdf:addressdirectory");
+ retCode = rdfService->GetDataSource(dir.getStr(),getter_AddRefs(rdfDirectory)) ;
+
+
+
+ OSL_TRACE("uri: %s\n", aParent.getStr()) ;
+ retCode = rdfService->GetResource(nsDependentCString(aParent.getStr(),aParent.getLength()), getter_AddRefs(rdfResource)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ;
+ nsCOMPtr<nsISimpleEnumerator> tempEnum ;
+
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ retCode = directory->GetChildNodes(getter_AddRefs(tempEnum)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ PRBool hasMore = PR_TRUE ;
+ while (NS_SUCCEEDED(tempEnum->HasMoreElements(&hasMore)) && hasMore) {
+ nsCOMPtr<nsIAbDirectory> element ;
+ retCode = tempEnum->GetNext(getter_AddRefs(element)) ;
+ if (NS_SUCCEEDED(retCode))
+ {
+ array->AppendElement(element) ;
+ enumSubs(element,array);
+ }
+ }
+
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+static nsresult enumSubs(nsISimpleEnumerator * subDirs,nsISupportsArray * array)
+{
+ PRBool hasMore = PR_TRUE ;
+ nsresult rv = NS_OK ;
+ while (NS_SUCCEEDED(subDirs->HasMoreElements(&hasMore)) && hasMore) {
+ nsCOMPtr<nsISupports> newDirSupports ;
+
+ rv = subDirs->GetNext(getter_AddRefs(newDirSupports)) ;
+ NS_ENSURE_SUCCESS(rv, rv);
+ nsCOMPtr<nsIAbDirectory> childDir = do_QueryInterface(newDirSupports, &rv) ;
+ NS_ENSURE_SUCCESS(rv, rv);
+ array->AppendElement(childDir);
+
+ rv = enumSubs(childDir,array);
+ }
+ return rv;
+}
+
+// Case where we get a factory uri and need to have it build the directories.
+static nsresult getSubsFromFactory(const rtl::OString& aFactory, nsIEnumerator **aSubs)
+{
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+
+ nsCOMPtr<nsIAbDirFactoryService> dirFactoryService = do_GetService(NS_ABDIRFACTORYSERVICE_CONTRACTID, &retCode);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIAbDirFactory> dirFactory ;
+
+ retCode = dirFactoryService->GetDirFactory(aFactory.getStr(), getter_AddRefs(dirFactory)) ;
+ NS_ENSURE_SUCCESS (retCode, retCode) ;
+ nsCOMPtr <nsIAbDirectoryProperties> properties;
+ properties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &retCode);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ retCode = properties->SetURI(aFactory.getStr());
+ NS_ENSURE_SUCCESS(retCode,retCode);
+
+ nsCOMPtr<nsISimpleEnumerator> subDirs ;
+ retCode = dirFactory->CreateDirectory(properties, getter_AddRefs(subDirs));
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+ retCode = enumSubs(subDirs,array);
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+// Case where the uri itself is the directory we're looking for.
+static nsresult getSubsFromURI(const rtl::OString& aUri, nsIEnumerator **aSubs)
+{
+ if (aSubs == nsnull) { return NS_ERROR_NULL_POINTER ; }
+ *aSubs = nsnull ;
+ nsresult retCode = NS_OK ;
+
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &retCode)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsCOMPtr<nsIRDFResource> rdfResource ;
+
+ retCode = rdfService->GetResource(nsDependentCString(aUri.getStr(),aUri.getLength()), getter_AddRefs(rdfResource)) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ retCode = rdfService->UnregisterResource(rdfResource) ;
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(rdfResource, &retCode) ;
+
+ NS_ENSURE_SUCCESS(retCode, retCode) ;
+ nsAutoString nameAB ;
+
+ nameAB.AssignWithConversion("LDAP Directory") ;
+ directory->SetDirName(nameAB.get()) ;
+ nsCOMPtr<nsISupportsArray> array ;
+
+ NS_NewISupportsArray(getter_AddRefs(array)) ;
+ array->AppendElement(directory) ;
+ array->Enumerate(aSubs) ;
+ return retCode ;
+}
+
+namespace
+{
+ static void lcl_setNoAddressBookFoundError( ErrorDescriptor& _rError, OConnection& _rCon, MozillaProductType _eProductType,
+ sal_Bool bGivenURI )
+ {
+ sal_uInt16 nAddressBookNameRes = 0;
+ if ( !bGivenURI && _eProductType == MozillaProductType_Mozilla)
+ {
+ nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS;
+ }
+ else
+ {
+ if ( _eProductType == MozillaProductType_Thunderbird )
+ {
+ nAddressBookNameRes = STR_THUNDERBIRD_ADDRESSBOOKS;
+ }
+ else
+ {
+ if ( _rCon.usesFactory() )
+ {
+ if ( _rCon.isOutlookExpress() )
+ {
+ nAddressBookNameRes = STR_OE_ADDRESSBOOK;
+ }
+ else
+ {
+ nAddressBookNameRes = STR_OUTLOOK_MAPI_ADDRESSBOOK;
+ }
+ }
+ else
+ {
+ OSL_ENSURE( !_rCon.isLDAP(), "lcl_setNoAddressBookFoundError: not to be called for LDAP connections!" );
+ nAddressBookNameRes = STR_MOZILLA_ADDRESSBOOKS;
+ }
+ }
+ }
+ _rError.set( 0, ErrorCondition::AB_ADDRESSBOOK_NOT_FOUND, _rCon.getResources().getResourceString( nAddressBookNameRes ) );
+ }
+}
+
+nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap,
+ ::std::vector< ::rtl::OUString >* _rStrings,
+ ::std::vector< ::rtl::OUString >* _rTypes,
+ sal_Int32* pErrorId )
+{
+ if (!sAbURI || !nmap || !_rStrings || !_rTypes || !pErrorId)
+ {
+ return NS_ERROR_NULL_POINTER;
+ }
+ OSL_TRACE("Using URI %s to getTables()\n",sAbURI );
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIEnumerator> subDirectories;
+
+ switch(*nDirectoryType)
+ {
+ case SDBCAddress::Mozilla:
+ rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ case SDBCAddress::Outlook:
+ case SDBCAddress::OutlookExp:
+ rv = getSubsFromFactory(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ case SDBCAddress::LDAP:
+ rv = getSubsFromURI(sAbURI, getter_AddRefs(subDirectories)) ;
+ break;
+ default:
+ rv = getSubsFromParent(sAbURI, getter_AddRefs(subDirectories));
+ }
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // At this point we have a list containing the nsIAbDirectory we need to map as tables
+ rv = subDirectories -> First();
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ PRUnichar *name = nsnull;
+ PRBool bIsMailList = PR_FALSE;
+
+ ::rtl::OUString aTableName;
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ;
+ NS_ENSURE_SUCCESS(rv, rv) ;
+
+ nmap->reset();
+ do {
+ nsCOMPtr<nsIAbDirectory> subDirectory;
+
+ nsCOMPtr<nsISupports> item;
+ rv = subDirectories -> CurrentItem(getter_AddRefs(item));
+ if ( NS_FAILED( rv ) )
+ {
+ *pErrorId = STR_COULD_NOT_RETRIEVE_AB_ENTRY;
+ return NS_ERROR_FAILURE;
+ }
+
+ subDirectory = do_QueryInterface(item, &rv);
+
+ subDirectory -> GetIsMailList(&bIsMailList);
+ // For now we're not interested in mailing lists.
+ rv = subDirectory -> GetDirName(&name);
+ if ( NS_FAILED( rv ) ) {
+ *pErrorId = STR_COULD_NOT_GET_DIRECTORY_NAME;
+ return NS_ERROR_FAILURE;
+ }
+ MTypeConverter::prUnicharToOUString(name, aTableName);
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+
+ // Insert table into map
+ if ( aTableName.getLength() == 0 )
+ aTableName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AddressBook"));
+
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+ rv = nmap->add( aTableName, subDirectory);
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface(subDirectory, &rv) ;
+ if (!NS_FAILED(rv))
+ rdfService->UnregisterResource(rdfResource);
+
+ if (!NS_FAILED(rv)) //failed means we have added this directory
+ {
+ //map mailing lists as views
+ _rStrings->push_back( aTableName ); // Table name
+ if (!bIsMailList) {
+ ::rtl::OUString aTableType(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("TABLE")));
+ _rTypes->push_back( aTableType ); // Table type
+ }
+ else
+ {
+ ::rtl::OUString aTableType(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("VIEW")));
+ _rTypes->push_back( aTableType ); // Table type
+ }
+ }
+ rv = subDirectories -> Next();
+ } while ( rv == NS_OK);
+
+ return( NS_OK );
+}
+sal_Bool MDatabaseMetaDataHelper::getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings,
+ ::std::vector< ::rtl::OUString >& _rTypes)
+{
+ sal_Bool bGivenURI;
+ ::rtl::OUString sAbURI;
+ ::rtl::OString sAbURIString;
+
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::getTableStrings( 0x%08X, %s)\n", _pCon, _pCon->getForceLoadTables()?"True":"False" );
+
+ ::osl::MutexGuard aGuard( m_aMetaMutex );
+ // Only do the query if we have to - performance degrades otherwise
+ if ( ! _pCon->getForceLoadTables() && m_aTableNames.size() > 0 ) {
+ _rStrings = m_aTableNames;
+ _rTypes = m_aTableTypes;
+ return( sal_True );
+ }
+
+ m_aTableNames.clear();
+ m_aTableTypes.clear();
+
+ sAbURI = _pCon->getMozURI();
+
+ OSL_TRACE("AbURI = %s\n", OUtoCStr( sAbURI ) );
+ if ( sAbURI.getLength() == 0 )
+ bGivenURI = sal_False;
+ else {
+ sAbURIString = ::rtl::OUStringToOString( sAbURI,
+ RTL_TEXTENCODING_ASCII_US);
+ bGivenURI = sal_True;
+ }
+
+ if ( bGivenURI )
+ OSL_TRACE("Using URI %s to getTables()\n", sAbURIString.getStr() );
+ else
+ OSL_TRACE("Using URI of ROOTDIR to getTables()\n");
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+ nsCOMPtr<nsIEnumerator> subDirectories;
+ sal_Int32 nDirectoryType=0;
+ m_ProductType = MozillaProductType_Mozilla;
+ m_ProfileName = _pCon->getMozProfile();
+
+
+ if (_pCon->isThunderbird())
+ {
+ if (!bGivenURI)
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::ThunderBird;
+ m_ProductType = MozillaProductType_Thunderbird;
+ }
+ else if (!bGivenURI)
+ {
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::Mozilla;
+ }
+ else
+ {
+ if (_pCon->usesFactory())
+ {
+ nDirectoryType = SDBCAddress::Outlook;
+ }
+ else
+ {
+ if (_pCon->isLDAP())
+ {
+ nDirectoryType = SDBCAddress::LDAP;
+ }
+ else
+ {
+ sAbURIString = s_pADDRESSBOOKROOTDIR;
+ nDirectoryType = SDBCAddress::Mozilla;
+ }
+ }
+ }
+
+ if ( !_pCon->isLDAP() && !m_bProfileExists )
+ { // no need to boot up a Mozilla profile for an LDAP connection
+ Reference<XMozillaBootstrap> xMozillaBootstrap;
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+ Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = Reference<XMozillaBootstrap>(xInstance,UNO_QUERY);
+ m_bProfileExists = sal_False;
+ //If there are no profiles for this product
+ //Or the given profile name does not found
+ //We will reaise a "No Addressbook Directories Exist" error
+ if ( xMozillaBootstrap->getProfileCount(m_ProductType) == 0 ||
+ ( m_ProfileName.getLength() && !(xMozillaBootstrap->getProfilePath(m_ProductType,m_ProfileName).getLength())))
+ m_bProfileExists = sal_False;
+ else
+ if (xMozillaBootstrap->bootupProfile(m_ProductType,m_ProfileName) > 0)
+ m_bProfileExists = sal_True;
+
+ }
+ if ( !m_bProfileExists
+ && !_pCon->isLDAP()
+ && ( ( nDirectoryType == SDBCAddress::Mozilla )
+ || ( nDirectoryType == SDBCAddress::ThunderBird )
+ )
+ )
+ {
+ lcl_setNoAddressBookFoundError( m_aError, *_pCon, m_ProductType, bGivenURI );
+ return sal_False;
+ }
+
+ MNameMapper *nmap = _pCon->getNameMapper();
+ nmap->reset();
+
+ sal_Int32 nErrorResourceId( 0 );
+
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_GET_TABLE_STRINGS;
+ args.argCount = 6;
+ args.arg1 = (void*)sAbURIString.getStr();
+ args.arg2 = (void*)&nDirectoryType;
+ args.arg3 = (void*)nmap;
+ args.arg4 = (void*)&m_aTableNames;
+ args.arg5 = (void*)&m_aTableTypes;
+ args.arg6 = (void*)&nErrorResourceId;
+ rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName);
+ m_aError.setResId( static_cast<sal_uInt16>(nErrorResourceId) );
+
+ if (NS_FAILED(rv))
+ {
+ if ( nErrorResourceId == 0 )
+ m_aError.setResId( STR_UNSPECIFIED_ERROR );
+ return sal_False;
+ }
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTableStrings()\n" );
+ _rStrings = m_aTableNames;
+ _rTypes = m_aTableTypes;
+
+ _pCon->setForceLoadTables(sal_False);
+ return( sal_True );
+}
+
+sal_Bool MDatabaseMetaDataHelper::getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ const Sequence< ::rtl::OUString >& types,
+ ODatabaseMetaDataResultSet::ORows& _rRows)
+{
+
+ static ODatabaseMetaDataResultSet::ORows aRows;
+
+ OSL_TRACE( "IN MDatabaseMetaDataHelper::getTables()\n" );
+ ::osl::MutexGuard aGuard( m_aMetaMutex );
+
+ ODatabaseMetaDataResultSet::ORows().swap(aRows); // this makes real clear where memory is freed as well
+ aRows.clear();
+
+ ::std::vector< ::rtl::OUString > tables;
+ ::std::vector< ::rtl::OUString > tabletypes;
+ ::rtl::OUString matchAny = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("%"));;
+
+ if ( !getTableStrings( _pCon, tables,tabletypes ) )
+ return sal_False;
+
+ for ( size_t i = 0; i < tables.size(); i++ ) {
+ ODatabaseMetaDataResultSet::ORow aRow(3);
+
+ ::rtl::OUString aTableName = tables[i];
+ ::rtl::OUString aTableType = tabletypes[i];
+ OSL_TRACE("TableName = >%s<\n", OUtoCStr( aTableName ) );
+
+
+ // return tables to caller
+ if (match( tableNamePattern, aTableName, '\0' ) &&
+ ( 0 == types.getLength() || //types is null or types include aTableType or types include "%"
+ 0 != ::comphelper::findValue( types, aTableType, sal_True ).getLength() ||
+ 0 != ::comphelper::findValue( types, matchAny, sal_True ).getLength())) {
+ if ( aTableName.getLength() == 0 ) {
+ aTableName = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("AddressBook"));
+ }
+
+ OSL_TRACE( "TableName = %s ; TableType = %s\n", OUtoCStr(aTableName), OUtoCStr(aTableType) );
+
+ aRow.push_back( new ORowSetValueDecorator( aTableName ) ); // Table name
+ aRow.push_back( new ORowSetValueDecorator( aTableType ) ); // Table type
+ aRow.push_back( ODatabaseMetaDataResultSet::getEmptyValue() ); // Remarks
+ aRows.push_back(aRow);
+ }
+ }
+
+ OSL_TRACE( "\tOUT MDatabaseMetaDataHelper::getTables()\n" );
+ _rRows = aRows;
+ return(sal_True);
+}
+
+
+sal_Bool
+MDatabaseMetaDataHelper::testLDAPConnection( OConnection* _pCon )
+{
+ const sal_Unicode QUERY_CHAR = '?';
+ const sal_Char* MOZ_SCHEMA = "moz-abldapdirectory://";
+ const sal_Char* LDAP_SCHEMA = "ldap://";
+
+ rtl::OString sAbURI;
+ rtl::OUString sAbBindDN;
+ rtl::OUString sAbPassword;
+ sal_Bool useSSL = _pCon->getUseSSL();
+
+ nsresult rv(0);
+
+ sAbURI = OUStringToOString( _pCon->getMozURI(), RTL_TEXTENCODING_ASCII_US );
+ sAbBindDN = _pCon->getBindDN();
+ sAbPassword = _pCon->getPassword();
+
+
+ sal_Int32 pos = sAbURI.indexOf( MOZ_SCHEMA );
+ if ( pos != -1 ) {
+ sAbURI = sAbURI.replaceAt (pos, rtl_str_getLength( MOZ_SCHEMA ), ::rtl::OString(LDAP_SCHEMA) );
+ }
+
+ pos = sAbURI.indexOf( QUERY_CHAR );
+ if ( pos != -1 ) {
+ sal_Int32 len = sAbURI.getLength();
+ sAbURI = sAbURI.replaceAt( pos, len - pos, ::rtl::OString("") );
+ }
+ const sal_Unicode* bindDN=nsnull;
+ if (sAbBindDN.getLength() != 0)
+ {
+ bindDN = sAbBindDN.getStr();
+ }
+
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP;
+ args.argCount = 4;
+ args.arg1 = (void*)sAbURI.getStr();
+ args.arg2 = (void*)bindDN;
+ args.arg3 = (void*)sAbPassword.getStr();
+ args.arg4 = (void*)&useSSL;
+
+ MNSMozabProxy xMProxy;
+ rv = xMProxy.StartProxy( &args, m_ProductType, ::rtl::OUString() );
+ if ( NS_SUCCEEDED( rv ) ) //Init LDAP,pass OUString() to StarProxy to ignore profile switch
+ {
+ args.funcIndex = ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED;
+ TimeValue timeValue = { 1, 0 }; // 1 * 30 Seconds timeout
+ sal_Int32 times=0;
+ while ( times++ < 30 )
+ {
+ rv = xMProxy.StartProxy( &args, m_ProductType, ::rtl::OUString() );
+ if ( NS_SUCCEEDED( rv ) )
+ // connected successfully
+ break;
+
+ if ( rv == (nsresult)PR_NOT_CONNECTED_ERROR )
+ // connection failed
+ break;
+
+ // not yet decided - continue waiting
+ osl_waitThread( &timeValue );
+ }
+ }
+ m_aError.setResId( STR_COULD_NOT_CONNECT_LDAP );
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+}
+
+sal_Bool MDatabaseMetaDataHelper::NewAddressBook(OConnection* _pCon,const ::rtl::OUString & aTableName)
+{
+ sal_Bool bIsMozillaAB;
+
+ bIsMozillaAB = !_pCon->usesFactory() && ! _pCon->isLDAP();
+
+ if ( !bIsMozillaAB )
+ {
+ m_aError.setResId( STR_NO_TABLE_CREATION_SUPPORT );
+ return sal_False;
+ }
+ else
+ OSL_TRACE("Create table\n");
+
+ // Get the mozilla addressbooks from the base directory.
+ nsresult rv = NS_OK;
+
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_NEW_ADDRESS_BOOK;
+ args.argCount = 1;
+ args.arg1 = (void*)&aTableName;
+ rv = xMProxy.StartProxy(&args,m_ProductType,m_ProfileName);
+
+ _pCon->setForceLoadTables(sal_True); //force reload table next time
+ if (rv == NS_ERROR_FILE_IS_LOCKED)
+ {
+ m_aError.setResId( STR_MOZILLA_IS_RUNNING );
+ }
+ else if (NS_FAILED(rv))
+ {
+ m_aError.set( STR_COULD_NOT_CREATE_ADDRESSBOOK, 0, ::rtl::OUString::valueOf( sal_Int32(rv), 16 ) );
+ }
+ OSL_TRACE( "OUT MDatabaseMetaDataHelper::NewAddressBook()\n" );
+ return( NS_SUCCEEDED(rv) ? sal_True : sal_False );
+}
+nsresult NewAddressBook(const ::rtl::OUString * aName)
+{
+ if (isProfileLocked(NULL))
+ return NS_ERROR_FILE_IS_LOCKED;
+ nsresult rv;
+ nsCOMPtr<nsIAbDirectoryProperties> aProperties = do_CreateInstance(NS_ABDIRECTORYPROPERTIES_CONTRACTID, &rv);
+ NS_ENSURE_ARG_POINTER(aProperties);
+ const ::rtl::OUString& uName = *aName;
+ nsString nsName;
+ MTypeConverter::ouStringToNsString(uName,nsName);
+ aProperties->SetDescription(nsName);
+
+ nsCOMPtr<nsIRDFService> rdfService = do_GetService (kRDFServiceCID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIRDFResource> parentResource;
+ rv = rdfService->GetResource(NS_LITERAL_CSTRING(kAllDirectoryRoot), getter_AddRefs(parentResource));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIAbDirectory> parentDir = do_QueryInterface(parentResource, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ rv = parentDir->CreateNewDirectory(aProperties);
+ return rv;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx
new file mode 100644
index 000000000000..39c6e34408d4
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MDatabaseMetaDataHelper.hxx
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+#define _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+
+#include "MErrorResource.hxx"
+#include <comphelper/proparrhlp.hxx>
+#include <comphelper/propertycontainer.hxx>
+#include "FDatabaseMetaDataResultSet.hxx"
+
+#ifndef _CONNECTIVITY_MAB_CONNECTION_HXX_
+#include <MConnection.hxx>
+#endif
+#include <com/sun/star/uno/Sequence.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MDatabaseMetaDataHelper
+ {
+ private:
+ sal_Bool m_bProfileExists ;
+ ::std::vector< ::rtl::OUString > m_aTableNames;
+ ::std::vector< ::rtl::OUString > m_aTableTypes;
+ ::com::sun::star::mozilla::MozillaProductType m_ProductType;
+ ::rtl::OUString m_ProfileName;
+ ErrorDescriptor m_aError;
+
+ public:
+ MDatabaseMetaDataHelper();
+ ~MDatabaseMetaDataHelper();
+
+ //
+ sal_Bool getTableStrings( OConnection* _pCon,
+ ::std::vector< ::rtl::OUString >& _rStrings,
+ ::std::vector< ::rtl::OUString >& _rTypes);
+
+ sal_Bool getTables( OConnection* _pCon,
+ const ::rtl::OUString& tableNamePattern,
+ const ::com::sun::star::uno::Sequence< ::rtl::OUString >& types,
+ ODatabaseMetaDataResultSet::ORows& _rRows);
+ sal_Bool testLDAPConnection( OConnection* _pCon );
+ sal_Bool NewAddressBook( OConnection* _pCon,const ::rtl::OUString & aTableName);
+
+ inline const ErrorDescriptor& getError() const { return m_aError; }
+ };
+ }
+
+}
+#endif // _CONNECTIVITY_MAB_DATABASEMETADATAHELPER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx
new file mode 100644
index 000000000000..5e975087bcfd
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MErrorResource.hxx
@@ -0,0 +1,77 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
+#define CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
+
+#include <rtl/ustring.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class ErrorDescriptor
+ {
+ private:
+ sal_uInt16 m_nErrorResourceId;
+ sal_Int32 m_nErrorCondition;
+ ::rtl::OUString m_sParameter;
+
+ public:
+ ErrorDescriptor()
+ :m_nErrorResourceId(0)
+ ,m_nErrorCondition(0)
+ ,m_sParameter()
+ {
+ }
+
+ inline void set( const sal_uInt16 _nErrorResourceId, const sal_Int32 _nErrorCondition, const ::rtl::OUString& _rParam )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ m_nErrorCondition = _nErrorCondition;
+ m_sParameter = _rParam;
+ }
+ inline void setResId( const sal_uInt16 _nErrorResourceId )
+ {
+ m_nErrorResourceId = _nErrorResourceId;
+ }
+ inline void reset()
+ {
+ m_nErrorResourceId = 0;
+ m_nErrorCondition = 0;
+ }
+
+ inline sal_uInt16 getResId() const { return m_nErrorResourceId; }
+ inline sal_Int32 getErrorCondition() const { return m_nErrorCondition; }
+ inline const ::rtl::OUString& getParameter() const { return m_sParameter; }
+
+ inline bool is() const { return ( m_nErrorResourceId != 0 ) || ( m_nErrorCondition != 0 ); }
+ };
+ }
+}
+
+#endif // CONNECITIVITY_MOZAB_ERROR_RESOURCE_HXX
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx
new file mode 100644
index 000000000000..73c3fb16908b
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.cxx
@@ -0,0 +1,450 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <rtl/strbuf.hxx>
+ // keep this include at the beginning. Some of the other includes seems to inject a symbol "l" into the
+ // global namespace, which leads to a compiler warning in strbuf.hxx, about some parameters named "l"
+ // hiding objects "in an outer scope".
+
+#include "MLdapAttributeMap.hxx"
+#include "MTypeConverter.hxx"
+#include "MQueryHelper.hxx"
+
+#include <tools/diagnose_ex.h>
+
+#include <hash_map>
+
+//........................................................................
+namespace connectivity { namespace mozab {
+//........................................................................
+
+ //====================================================================
+ //= helper
+ //====================================================================
+ namespace
+ {
+ typedef nsresult (NS_STDCALL nsIAbCard::*CardPropertyGetter)( PRUnichar** aFirstName );
+ typedef nsresult (NS_STDCALL nsIAbCard::*CardPropertySetter)( const PRUnichar* aFirstName );
+ struct CardPropertyData
+ {
+ const sal_Char* pLDAPAttributeList;
+ CardPropertyGetter PropGetter;
+ CardPropertySetter PropSetter;
+
+ CardPropertyData()
+ :pLDAPAttributeList( NULL )
+ ,PropGetter( NULL )
+ ,PropSetter( NULL )
+ {
+ }
+ CardPropertyData( const sal_Char* _pLDAPAttributeList, CardPropertyGetter _PropGetter, CardPropertySetter _PropSetter )
+ :pLDAPAttributeList( _pLDAPAttributeList )
+ ,PropGetter( _PropGetter )
+ ,PropSetter( _PropSetter )
+ {
+ }
+ };
+
+ typedef ::std::hash_map< ::rtl::OString, CardPropertyData, ::rtl::OStringHash > MapPropertiesToAttributes;
+
+ #define DEF_CARD_ACCESS( PropertyName ) \
+ &nsIAbCard::Get##PropertyName, &nsIAbCard::Set##PropertyName
+
+ static const MapPropertiesToAttributes& lcl_getPropertyMap()
+ {
+ static MapPropertiesToAttributes aMap;
+ if ( aMap.empty() )
+ {
+ struct MapEntry
+ {
+ const sal_Char* pAsciiPropertyName;
+ const sal_Char* pAsciiAttrributeList;
+ CardPropertyGetter PropGetter;
+ CardPropertySetter PropSetter;
+ };
+ const MapEntry aEntries[] = {
+ { "FirstName", "givenname", DEF_CARD_ACCESS( FirstName ) },
+ { "LastName", "sn,surnname", DEF_CARD_ACCESS( LastName ) },
+ { "DisplayName", "cn,commonname,displayname", DEF_CARD_ACCESS( DisplayName ) },
+ { "NickName", "xmozillanickname", DEF_CARD_ACCESS( NickName ) },
+ { "PrimaryEmail", "mail", DEF_CARD_ACCESS( PrimaryEmail ) },
+ { "SecondEmail", "xmozillasecondemail", DEF_CARD_ACCESS( SecondEmail ) },
+ { "WorkPhone", "telephonenumber", DEF_CARD_ACCESS( WorkPhone ) },
+ { "HomePhone", "homephone", DEF_CARD_ACCESS( HomePhone ) },
+ { "FaxNumber", "fax,facsimiletelephonenumber", DEF_CARD_ACCESS( FaxNumber ) },
+ { "PagerNumber", "pager,pagerphone", DEF_CARD_ACCESS( PagerNumber ) },
+ { "CellularNumber", "mobile,cellphone,carphone", DEF_CARD_ACCESS( CellularNumber ) },
+ { "HomeAddress", "homepostaladdress,mozillaHomeStreet", DEF_CARD_ACCESS( HomeAddress ) },
+ { "HomeAddress2", "mozillaHomeStreet2", DEF_CARD_ACCESS( HomeAddress2 ) },
+ { "HomeCity", "homelocality,mozillaHomeLocalityName", DEF_CARD_ACCESS( HomeCity ) },
+ { "HomeState", "homeregion,mozillaHomeState", DEF_CARD_ACCESS( HomeState ) },
+ { "HomeZipCode", "homepostalcode,mozillaHomePostalCode", DEF_CARD_ACCESS( HomeZipCode ) },
+ { "HomeCountry", "homecountryname,mozillaHomeCountryName", DEF_CARD_ACCESS( HomeCountry ) },
+ { "WorkAddress", "postofficebox,streetaddress,streetaddress1", DEF_CARD_ACCESS( WorkAddress ) },
+ { "WorkAddress2", "streetaddress2", DEF_CARD_ACCESS( WorkAddress2 ) },
+ { "WorkCity", "l,locality", DEF_CARD_ACCESS( WorkCity ) },
+ { "WorkState", "st,region", DEF_CARD_ACCESS( WorkState ) },
+ { "WorkZipCode", "postalcode,zip", DEF_CARD_ACCESS( WorkZipCode ) },
+ { "WorkCountry", "countryname", DEF_CARD_ACCESS( WorkCountry ) },
+ { "JobTitle", "title", DEF_CARD_ACCESS( JobTitle ) },
+ { "Department", "ou,orgunit,department,departmentnumber", DEF_CARD_ACCESS( Department ) },
+ { "Company", "o,company", DEF_CARD_ACCESS( Company ) },
+ { "WebPage1", "workurl", DEF_CARD_ACCESS( WebPage1 ) },
+ { "WebPage2", "homeurl", DEF_CARD_ACCESS( WebPage2 ) },
+ { "BirthYear", "birthyear", DEF_CARD_ACCESS( BirthYear ) },
+ { "BirthMonth", "birthmonth", DEF_CARD_ACCESS( BirthMonth ) },
+ { "BirthYear", "birthday", DEF_CARD_ACCESS( BirthDay ) },
+ { "Custom1", "custom1", DEF_CARD_ACCESS( Custom1 ) },
+ { "Custom2", "custom2", DEF_CARD_ACCESS( Custom2 ) },
+ { "Custom3", "custom3", DEF_CARD_ACCESS( Custom3 ) },
+ { "Custom4", "custom4", DEF_CARD_ACCESS( Custom4 ) },
+ { "Notes", "notes,description", DEF_CARD_ACCESS( Notes ) },
+ { "PreferMailFormat", "xmozillausehtmlmail", NULL, NULL },
+ { NULL, NULL, NULL, NULL }
+ };
+ const MapEntry* loop = aEntries;
+ while ( loop->pAsciiPropertyName )
+ {
+ aMap[ ::rtl::OString( loop->pAsciiPropertyName ) ] =
+ CardPropertyData( loop->pAsciiAttrributeList, loop->PropGetter, loop->PropSetter );
+ ++loop;
+ }
+ }
+ return aMap;
+ }
+ }
+
+ //====================================================================
+ //= AttributeMap_Data
+ //====================================================================
+ struct AttributeMap_Data
+ {
+ };
+
+ //====================================================================
+ //= MLdapAttributeMap
+ //====================================================================
+ // -------------------------------------------------------------------
+ MLdapAttributeMap::MLdapAttributeMap()
+ :m_pData( new AttributeMap_Data )
+ {
+ }
+
+ // -------------------------------------------------------------------
+ MLdapAttributeMap::~MLdapAttributeMap()
+ {
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMPL_THREADSAFE_ISUPPORTS1( MLdapAttributeMap, nsIAbLDAPAttributeMap )
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAttributeList(const nsACString & aProperty, nsACString & _retval)
+ {
+ ::rtl::OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty );
+
+ if ( pos == rPropertyMap.end() )
+ {
+ _retval.SetIsVoid( PR_TRUE );
+ }
+ else
+ {
+ MTypeConverter::asciiToNsACString( pos->second.pLDAPAttributeList, _retval );
+ }
+
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAttributes(const nsACString & aProperty, PRUint32* aCount, char*** aAttrs)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::GetAttributes: not implemented!" );
+ (void)aProperty;
+ (void)aCount;
+ (void)aAttrs;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetFirstAttribute(const nsACString & aProperty, nsACString & _retval)
+ {
+ ::rtl::OString sProperty( MTypeConverter::nsACStringToOString( aProperty ) );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ MapPropertiesToAttributes::const_iterator pos = rPropertyMap.find( sProperty );
+
+ if ( pos == rPropertyMap.end() )
+ {
+ _retval.SetIsVoid( PR_TRUE );
+ }
+ else
+ {
+ sal_Int32 tokenPos(0);
+ ::rtl::OString sAttributeList( pos->second.pLDAPAttributeList );
+ MTypeConverter::asciiToNsACString( sAttributeList.getToken( 0, ',', tokenPos ).getStr(), _retval );
+ }
+
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetAttributeList(const nsACString & aProperty, const nsACString & aAttributeList, PRBool allowInconsistencies)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::SetAttributeList: not implemented!" );
+ (void)aProperty;
+ (void)aAttributeList;
+ (void)allowInconsistencies;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetProperty(const nsACString & aAttribute, nsACString & _retval)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::GetProperty: not implemented!" );
+ (void)aAttribute;
+ (void)_retval;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::GetAllCardAttributes(nsACString & _retval)
+ {
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+
+ ::rtl::OStringBuffer aAllAttributes;
+ for ( MapPropertiesToAttributes::const_iterator loop = rPropertyMap.begin();
+ loop != rPropertyMap.end();
+ ++loop
+ )
+ {
+ aAllAttributes.append( loop->second.pLDAPAttributeList );
+ if ( loop != rPropertyMap.end() )
+ aAllAttributes.append( ',' );
+ }
+
+ MTypeConverter::asciiToNsACString( aAllAttributes.getStr(), _retval );
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::CheckState(void)
+ {
+ // we do not allow modifying the map, so we're always in a valid state
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetFromPrefs(const nsACString & aPrefBranchName)
+ {
+ OSL_ENSURE( false, "MLdapAttributeMap::SetFromPrefs: not implemented!" );
+ (void)aPrefBranchName;
+ return NS_ERROR_NOT_IMPLEMENTED;
+ }
+
+ // -------------------------------------------------------------------
+ NS_IMETHODIMP MLdapAttributeMap::SetCardPropertiesFromLDAPMessage(nsILDAPMessage* aMessage, nsIAbCard* aCard)
+ {
+ NS_ENSURE_ARG_POINTER( aMessage );
+ NS_ENSURE_ARG_POINTER( aCard );
+
+ // in case that's not present in the LDAP message: set the "preferred mail format" to "none"
+ aCard->SetPreferMailFormat( nsIAbPreferMailFormat::unknown );
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ // split the list of attributes for the current property
+ ::rtl::OString sAttributeList( prop->second.pLDAPAttributeList );
+ ::rtl::OString sAttribute;
+
+ sal_Int32 tokenPos = 0;
+ while ( tokenPos != -1 )
+ {
+ sAttribute = sAttributeList.getToken( 0, ',', tokenPos );
+
+ // retrieve the values for the current attribute
+ PRUint32 valueCount = 0;
+ PRUnichar** values = NULL;
+ nsresult rv = aMessage->GetValues( sAttribute.getStr(), &valueCount, &values );
+ if ( NS_FAILED( rv ) )
+ // try the next attribute
+ continue;
+
+ if ( valueCount )
+ {
+ CardPropertySetter propSetter = prop->second.PropSetter;
+ OSL_ENSURE( propSetter,
+ "MLdapAttributeMap::SetCardPropertiesFromLDAPMessage: "
+ "unexpected: could retrieve an attribute value, but have no setter for it!" );
+ if ( propSetter )
+ {
+ (aCard->*propSetter)( values[0] );
+ }
+
+ // we're done with this property - no need to handle the remaining attributes which
+ // map to it
+ break;
+ }
+ }
+ }
+ return NS_OK;
+ }
+
+ // -------------------------------------------------------------------
+ namespace
+ {
+ struct PreferMailFormatType
+ {
+ const sal_Char* description;
+ PRUint32 formatType;
+
+ PreferMailFormatType()
+ :description( NULL )
+ ,formatType( nsIAbPreferMailFormat::unknown )
+ {
+ }
+
+ PreferMailFormatType( const sal_Char* _description, PRUint32 _formatType )
+ :description( _description )
+ ,formatType( _formatType )
+ {
+ }
+ };
+
+ static const PreferMailFormatType* lcl_getMailFormatTypes()
+ {
+ static const PreferMailFormatType aMailFormatTypes[] =
+ {
+ PreferMailFormatType( "text/plain", nsIAbPreferMailFormat::plaintext ),
+ PreferMailFormatType( "text/html", nsIAbPreferMailFormat::html ),
+ PreferMailFormatType( "unknown", nsIAbPreferMailFormat::unknown ),
+ PreferMailFormatType()
+ };
+ return aMailFormatTypes;
+ }
+ }
+
+ // -------------------------------------------------------------------
+ void MLdapAttributeMap::fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result )
+ {
+ _card.SetPreferMailFormat( nsIAbPreferMailFormat::unknown );
+
+ ::rtl::OUString resultValue;
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ resultValue = _result.getValue( prop->first );
+
+ CardPropertySetter propSetter = prop->second.PropSetter;
+ if ( propSetter )
+ {
+ // PRUnichar != sal_Unicode in mingw
+ (_card.*propSetter)( reinterpret_cast_mingw_only<const PRUnichar *>(resultValue.getStr()) );
+ }
+ else
+ {
+ if ( prop->first.equals( "PreferMailFormat" ) )
+ {
+ unsigned int format = nsIAbPreferMailFormat::unknown;
+ const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes();
+ while ( pMailFormatType->description )
+ {
+ if ( resultValue.equalsAscii( pMailFormatType->description ) )
+ {
+ format = pMailFormatType->formatType;
+ break;
+ }
+ ++pMailFormatType;
+ }
+ _card.SetPreferMailFormat(format);
+ }
+ else
+ OSL_ENSURE( false, "MLdapAttributeMap::fillCardFromResult: unexpected property without default setters!" );
+ }
+ }
+ }
+
+ // -------------------------------------------------------------------
+ void MLdapAttributeMap::fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card )
+ {
+ nsXPIDLString value;
+ ::rtl::OUString resultValue;
+
+ const MapPropertiesToAttributes& rPropertyMap( lcl_getPropertyMap() );
+ for ( MapPropertiesToAttributes::const_iterator prop = rPropertyMap.begin();
+ prop != rPropertyMap.end();
+ ++prop
+ )
+ {
+ CardPropertyGetter propGetter = prop->second.PropGetter;
+ if ( propGetter )
+ {
+ (_card.*propGetter)( getter_Copies( value ) );
+
+ nsAutoString temp( value );
+ MTypeConverter::nsStringToOUString( temp, resultValue );
+ }
+ else
+ {
+ if ( prop->first.equals( "PreferMailFormat" ) )
+ {
+ unsigned int format = nsIAbPreferMailFormat::unknown;
+ _card.GetPreferMailFormat( &format );
+ const PreferMailFormatType* pMailFormatType = lcl_getMailFormatTypes();
+ while ( pMailFormatType->description )
+ {
+ if ( format == pMailFormatType->formatType )
+ {
+ resultValue = ::rtl::OUString::createFromAscii( pMailFormatType->description );
+ break;
+ }
+ ++pMailFormatType;
+ }
+ }
+ else
+ OSL_ENSURE( false, "MLdapAttributeMap::fillResultFromCard: unexpected property without default getters!" );
+ }
+
+ _result.insert( prop->first, resultValue );
+ }
+ }
+
+//........................................................................
+} } // namespace connectivity::mozab
+//........................................................................
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx
new file mode 100644
index 000000000000..043b0179ee99
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MLdapAttributeMap.hxx
@@ -0,0 +1,75 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
+#define CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
+
+#include <MNSInclude.hxx>
+
+#include <memory>
+
+//........................................................................
+namespace connectivity { namespace mozab {
+//........................................................................
+
+ struct AttributeMap_Data;
+ class MQueryHelperResultEntry;
+
+ //====================================================================
+ //= class MLdapAttributeMap
+ //====================================================================
+ /** implements the nsIAbLDAPAttributeMap interface
+
+ Somewhere between Mozilla 1.7.5 and SeaMonkey 1.1.12, the LDAP address book
+ implementation was changed to take the attribute mapping (from LDAP attributes
+ to address book properties) not directly from the preferences. Instead, this mapping
+ is now delivered by a dedicated implementation (supporting the nsIAbLDAPAttributeMap
+ interface).
+
+ */
+ class MLdapAttributeMap : public nsIAbLDAPAttributeMap
+ {
+ public:
+ MLdapAttributeMap();
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIABLDAPATTRIBUTEMAP
+
+ static void fillCardFromResult( nsIAbCard& _card, const MQueryHelperResultEntry& _result );
+ static void fillResultFromCard( MQueryHelperResultEntry& _result, nsIAbCard& _card );
+
+ protected:
+ virtual ~MLdapAttributeMap();
+
+ private:
+ ::std::auto_ptr< AttributeMap_Data > m_pData;
+ };
+
+//........................................................................
+} } // namespace connectivity::mozab
+//........................................................................
+
+#endif // CONNECTIVITY_MLDAPATTRIBUTEMAP_HXX
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx
new file mode 100644
index 000000000000..84c2a2a7e20f
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSDeclares.hxx
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_NS_DECLARES_HXX_
+#define _CONNECTIVITY_MAB_NS_DECLARES_HXX_
+
+#include <sal/types.h>
+
+
+const sal_Int32 RowStates_Normal = 0;
+const sal_Int32 RowStates_Inserted = 1;
+const sal_Int32 RowStates_Updated = 2;
+const sal_Int32 RowStates_Deleted = 4;
+const sal_Int32 RowStates_Error = 32;
+
+namespace connectivity{
+ namespace mozab{
+ class OConnection;
+ }
+}
+sal_Bool isProfileLocked(connectivity::mozab::OConnection* _pCon);
+
+class nsIAbDirectory;
+sal_Int32 getDirectoryType(const nsIAbDirectory* directory);
+
+
+#endif // _CONNECTIVITY_MAB_NS_DECLARES_HXX_ 1
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx
new file mode 100644
index 000000000000..80a9bec5ad3d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSInclude.hxx
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef _CONNECTIVITY_MAB_NS_INCLUDE_HXX_
+#define _CONNECTIVITY_MAB_NS_INCLUDE_HXX_ 1
+
+//
+// Only include Mozilla include files once and using this file...
+//
+
+// moved this here and in first position due to "long l;" unxsoli4 warning
+#include <rtl/ustrbuf.hxx>
+
+#include "pre_include_mozilla.h"
+#if defined __GNUC__
+ #pragma GCC system_header
+#endif
+
+#include <nsDebug.h>
+
+#include <nsCOMPtr.h>
+#include <nsISupportsArray.h>
+#include <nsString.h>
+
+#if defined __SUNPRO_CC
+#pragma disable_warn
+ // somewhere in the files included directly or indirectly in nsString.h, warnings are enabled, again
+#endif
+#include <nsMemory.h>
+#include <prtypes.h>
+#include <nsRDFCID.h>
+#include <nsXPIDLString.h>
+#include <nsIRDFService.h>
+#include <nsIRDFResource.h>
+#include <nsReadableUtils.h>
+#include <msgCore.h>
+#include <nsIServiceManager.h>
+#include <nsIAbCard.h>
+#include <nsAbBaseCID.h>
+#include <nsAbAddressCollecter.h>
+#include <nsIPref.h>
+#include <nsIAddrBookSession.h>
+#include <nsIMsgHeaderParser.h>
+#include <nsIAddrBookSession.h>
+#include <nsIAbDirectory.h>
+#include <nsAbDirectoryQuery.h>
+#include <nsIAbDirectoryQuery.h>
+#include <nsIAbDirectoryQueryProxy.h>
+#include <nsIAbDirFactory.h>
+#include <nsIRunnable.h>
+#include <nsIAbLDAPAttributeMap.h>
+#include <nsILDAPMessage.h>
+
+#include <prerr.h>
+
+#include "post_include_mozilla.h"
+
+#endif // _CONNECTIVITY_MAB_NS_INCLUDE_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx
new file mode 100644
index 000000000000..88cf400bf651
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.cxx
@@ -0,0 +1,404 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "MNSMozabProxy.hxx"
+
+#include "resource/mozab_res.hrc"
+#include "MDatabaseMetaDataHelper.hxx"
+#include "MQuery.hxx"
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+
+#include "pre_include_mozilla.h"
+#include <nsIProxyObjectManager.h>
+// More Mozilla includes for LDAP Connection Test
+#include "prprf.h"
+#include "nsILDAPURL.h"
+#include "nsILDAPMessage.h"
+#include "nsILDAPMessageListener.h"
+#include "nsILDAPErrors.h"
+#include "nsILDAPConnection.h"
+#include "nsILDAPOperation.h"
+#include "post_include_mozilla.h"
+#include "MQuery.hxx"
+#include <MQueryHelper.hxx>
+#include <com/sun/star/uno/Reference.hxx>
+#include <unotools/processfactory.hxx>
+#include "com/sun/star/mozilla/XProxyRunner.hpp"
+
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::mozilla;
+
+
+#define TYPEASSERT(value,type) if (value != type) return !NS_OK;
+
+using namespace connectivity::mozab;
+
+/* Implementation file */
+
+static ::osl::Mutex m_aThreadMutex;
+extern nsresult NewAddressBook(const ::rtl::OUString * aName);
+
+
+MNSMozabProxy::MNSMozabProxy()
+{
+ m_Args = NULL;
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+ acquire();
+}
+
+MNSMozabProxy::~MNSMozabProxy()
+{
+}
+
+sal_Int32 MNSMozabProxy::StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const ::rtl::OUString &aProfile)
+{
+ OSL_TRACE( "IN : MNSMozabProxy::StartProxy() \n" );
+ ::osl::MutexGuard aGuard(m_aThreadMutex);
+ m_Product = aProduct;
+ m_Profile = aProfile;
+ m_Args = args;
+ if (!xRunner.is())
+ {
+ Reference<XMultiServiceFactory> xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+ ::com::sun::star::uno::Reference<XInterface> xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xRunner = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner >(xInstance,UNO_QUERY);
+ }
+ const ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XCodeProxy > aCode(this);
+ return xRunner->Run(aCode);
+}
+
+extern nsresult getTableStringsProxied(const sal_Char* sAbURI, sal_Int32 *nDirectoryType,MNameMapper *nmap,
+ ::std::vector< ::rtl::OUString >* _rStrings,
+ ::std::vector< ::rtl::OUString >* _rTypes,
+ sal_Int32* pErrorId );
+
+::com::sun::star::mozilla::MozillaProductType SAL_CALL MNSMozabProxy::getProductType( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_Product;
+}
+::rtl::OUString SAL_CALL MNSMozabProxy::getProfileName( ) throw (::com::sun::star::uno::RuntimeException)
+{
+ return m_Profile;
+}
+
+sal_Int32 SAL_CALL MNSMozabProxy::run( ) throw (::com::sun::star::uno::RuntimeException)
+{
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "IN : MNSMozabProxy::Run() Caller thread :%4d \n" , m_oThreadID );
+#else
+ OSL_TRACE( "IN : MNSMozabProxy::Run() \n" );
+#endif
+ nsresult rv = NS_ERROR_INVALID_ARG;
+ if (m_Args == NULL)
+ return NS_ERROR_INVALID_ARG;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP:
+ case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED:
+ case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE:
+ rv = testLDAPConnection();
+ break;
+ case ProxiedFunc::FUNC_GET_TABLE_STRINGS:
+ rv = getTableStringsProxied((const sal_Char*)m_Args->arg1,
+ (sal_Int32 *)m_Args->arg2,
+ (MNameMapper *)m_Args->arg3,
+ (::std::vector< ::rtl::OUString >*)m_Args->arg4,
+ (::std::vector< ::rtl::OUString >*)m_Args->arg5,
+ (sal_Int32 *)m_Args->arg6);
+ break;
+ case ProxiedFunc::FUNC_EXECUTE_QUERY:
+ if (m_Args->arg1 && m_Args->arg2)
+ {
+ rv = ((MQuery*)m_Args->arg1)->executeQueryProxied((OConnection*)m_Args->arg2);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD:
+ case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD:
+ if (m_Args->arg1)
+ {
+ rv = QueryHelperStub();
+ }
+ break;
+ case ProxiedFunc::FUNC_NEW_ADDRESS_BOOK:
+ if (m_Args->arg1)
+ {
+ rv = NewAddressBook((const ::rtl::OUString*)m_Args->arg1 );
+ }
+ break;
+ default:
+ return NS_ERROR_INVALID_ARG;
+ }
+ return rv;
+}
+
+nsresult MNSMozabProxy::QueryHelperStub()
+{
+ nsresult rv = NS_ERROR_INVALID_ARG;
+ MQueryHelper * mHelper=(MQueryHelper*) m_Args->arg1;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD:
+ if (m_Args->arg2 ) //m_Args->arg2 used to return cord number
+ {
+ *((sal_Int32*)m_Args->arg2) = mHelper->createNewCard();
+ rv = NS_OK;
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD:
+ if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->deleteCard(*((sal_Int32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD:
+ if (m_Args->arg2 && m_Args->arg3 ) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->commitCard(*((sal_Int32*)m_Args->arg2),(nsIAbDirectory*)m_Args->arg3);
+ }
+ break;
+ case ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD:
+ if (m_Args->arg2) //m_Args->arg2 used to get the cord number
+ {
+ rv = mHelper->resyncRow(*((sal_Int32*)m_Args->arg2));
+ }
+ break;
+ default:
+ break;
+ }
+ return rv;
+}
+//-------------------------------------------------------------------
+
+#define NS_LDAPCONNECTION_CONTRACTID "@mozilla.org/network/ldap-connection;1"
+#define NS_LDAPOPERATION_CONTRACTID "@mozilla.org/network/ldap-operation;1"
+#define NS_LDAPMESSAGE_CONTRACTID "@mozilla.org/network/ldap-message;1"
+#define NS_LDAPURL_CONTRACTID "@mozilla.org/network/ldap-url;1"
+
+namespace connectivity {
+ namespace mozab {
+ class MLDAPMessageListener : public nsILDAPMessageListener
+ {
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSILDAPMESSAGELISTENER
+
+ MLDAPMessageListener();
+ virtual ~MLDAPMessageListener();
+
+ sal_Bool initialized() const;
+ sal_Bool goodConnection() const { return initialized() && m_GoodConnection; }
+
+ protected:
+
+ ::osl::Mutex m_aMutex;
+ ::osl::Condition m_aCondition;
+
+ sal_Bool m_IsComplete;
+ sal_Bool m_GoodConnection;
+
+ void setConnectionStatus( sal_Bool _good );
+ };
+ }
+}
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(MLDAPMessageListener, nsILDAPMessageListener)
+
+MLDAPMessageListener::MLDAPMessageListener()
+ : mRefCnt( 0 )
+ , m_IsComplete( sal_False )
+ , m_GoodConnection( sal_False )
+{
+ m_aCondition.reset();
+}
+
+MLDAPMessageListener::~MLDAPMessageListener()
+{
+}
+
+sal_Bool MLDAPMessageListener::initialized() const
+{
+ return const_cast< MLDAPMessageListener* >( this )->m_aCondition.check();
+}
+
+void MLDAPMessageListener::setConnectionStatus( sal_Bool _good )
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ m_IsComplete = sal_True;
+ m_GoodConnection = _good;
+
+ m_aCondition.set();
+}
+
+NS_IMETHODIMP MLDAPMessageListener::OnLDAPInit(nsILDAPConnection* /*aConn*/, nsresult aStatus )
+{
+ setConnectionStatus( NS_SUCCEEDED( aStatus ) ? sal_True : sal_False );
+ return aStatus;
+}
+
+NS_IMETHODIMP MLDAPMessageListener::OnLDAPMessage( nsILDAPMessage* aMessage )
+{
+ nsresult rv;
+
+ PRInt32 messageType;
+ rv = aMessage->GetType(&messageType);
+ NS_ENSURE_SUCCESS(rv, rv);
+ PRInt32 errCode;
+ switch (messageType)
+ {
+ case nsILDAPMessage::RES_BIND:
+ rv = aMessage->GetErrorCode(&errCode);
+ // if the login failed
+ if (errCode != (PRInt32)nsILDAPErrors::SUCCESS) {
+ setConnectionStatus( sal_False );
+ }
+ else
+ setConnectionStatus( sal_True );
+ break;
+ case nsILDAPMessage::RES_SEARCH_RESULT:
+ setConnectionStatus( sal_True );
+ break;
+ default:
+ break;
+ }
+
+ return NS_OK;
+}
+
+//-------------------------------------------------------------------
+
+nsresult
+MNSMozabProxy::testLDAPConnection( )
+{
+ nsresult rv=NS_ERROR_INVALID_ARG;
+ switch(m_Args->funcIndex)
+ {
+ case ProxiedFunc::FUNC_TESTLDAP_INIT_LDAP:
+ if (m_Args->arg1 && m_Args->arg4 )
+ {
+ rv = InitLDAP((sal_Char*)m_Args->arg1,(sal_Unicode*)m_Args->arg2,(sal_Unicode*)m_Args->arg3,(sal_Bool*)m_Args->arg4);
+ }
+ break;
+ case ProxiedFunc::FUNC_TESTLDAP_IS_LDAP_CONNECTED:
+ if (m_Args->arg5)
+ {
+ const MLDAPMessageListener* pListener( static_cast< const MLDAPMessageListener* >( m_Args->arg5 ) );
+ if ( pListener->initialized() )
+ rv = pListener->goodConnection() ? 0 : (nsresult)PR_NOT_CONNECTED_ERROR;
+ else
+ rv = (nsresult)PR_CONNECT_TIMEOUT_ERROR;
+ }
+ break;
+ case ProxiedFunc::FUNC_TESTLDAP_RELEASE_RESOURCE:
+ if (m_Args->arg5)
+ {
+ ((MLDAPMessageListener*)m_Args->arg5)->Release();
+ delete (MLDAPMessageListener*)m_Args->arg5;
+ m_Args->arg5 = NULL;
+ rv = 0;
+ }
+ break;
+ default:
+ return NS_ERROR_INVALID_ARG;
+ }
+ return rv;
+}
+nsresult
+MNSMozabProxy::InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* pPasswd,sal_Bool * nUseSSL)
+{
+ sal_Bool useSSL = *nUseSSL;
+ nsresult rv;
+
+ nsCOMPtr<nsILDAPURL> url;
+ url = do_CreateInstance(NS_LDAPURL_CONTRACTID, &rv);
+ if ( NS_FAILED(rv) )
+ return NS_ERROR_INVALID_ARG;
+
+ rv = url->SetSpec( nsDependentCString(sUri) );
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString host;
+ rv = url->GetAsciiHost(host);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ PRInt32 port;
+ rv = url->GetPort(&port);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCString dn;
+ rv = url->GetDn(dn);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+
+
+ // Get the ldap connection
+ nsCOMPtr<nsILDAPConnection> ldapConnection;
+ ldapConnection = do_CreateInstance(NS_LDAPCONNECTION_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ MLDAPMessageListener* messageListener =
+ new MLDAPMessageListener ( );
+ if (messageListener == NULL)
+ return NS_ERROR_INVALID_ARG;
+
+ messageListener->AddRef();
+
+ nsCAutoString nsBind;
+ // PRUnichar != sal_Unicode in mingw
+ nsBind.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(sBindDN));
+
+ // Now lets initialize the LDAP connection properly.
+ rv = ldapConnection->Init(host.get(), port, useSSL, nsBind,
+ messageListener,NULL,nsILDAPConnection::VERSION3);
+ // Initiate the LDAP operation
+ nsCOMPtr<nsILDAPOperation> ldapOperation =
+ do_CreateInstance(NS_LDAPOPERATION_CONTRACTID, &rv);
+
+ rv = ldapOperation->Init(ldapConnection, messageListener, nsnull);
+ if (NS_FAILED(rv))
+ return NS_ERROR_UNEXPECTED; // this should never happen
+
+ if ( pPasswd && *pPasswd )
+ {
+ nsCAutoString nsPassword;
+ // PRUnichar != sal_Unicode in mingw
+ nsPassword.AssignWithConversion(reinterpret_cast_mingw_only<const PRUnichar *>(pPasswd));
+ rv = ldapOperation->SimpleBind(nsPassword);
+ }
+
+ if (NS_SUCCEEDED(rv))
+ m_Args->arg5 = messageListener;
+ return rv;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx
new file mode 100644
index 000000000000..4cd7c9805c9e
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSMozabProxy.hxx
@@ -0,0 +1,119 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_MOZABHELPER_HXX_
+#define _CONNECTIVITY_MAB_MOZABHELPER_HXX_
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+
+#include <MNSInclude.hxx>
+#ifndef _CPPUHELPER_COMPBASE2_HXX_
+#include <cppuhelper/compbase1.hxx>
+#endif
+#ifndef _COM_SUN_STAR_MOZILLA_XCODEPROXY_HDL_
+#include <com/sun/star/mozilla/XCodeProxy.hpp>
+#endif
+#ifndef _COM_SUN_STAR_MOZILLA_XPROXYRUNNER_HDL_
+#include "com/sun/star/mozilla/XProxyRunner.hdl"
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ namespace ProxiedFunc
+ {
+ enum
+ {
+ FUNC_TESTLDAP_INIT_LDAP=1,
+ FUNC_TESTLDAP_IS_LDAP_CONNECTED,
+ FUNC_TESTLDAP_RELEASE_RESOURCE,
+ FUNC_GET_TABLE_STRINGS,
+ FUNC_EXECUTE_QUERY,
+ FUNC_QUERYHELPER_CREATE_NEW_CARD,
+ FUNC_QUERYHELPER_DELETE_CARD,
+ FUNC_QUERYHELPER_COMMIT_CARD,
+ FUNC_QUERYHELPER_RESYNC_CARD,
+ FUNC_NEW_ADDRESS_BOOK
+ };
+ }
+
+ struct RunArgs
+ {
+ sal_Int32 funcIndex; //Function Index
+ sal_Int32 argCount; //parameter count
+ void * arg1;
+ void * arg2;
+ void * arg3;
+ void * arg4;
+ void * arg5;
+ void * arg6;
+ RunArgs()
+ {
+ arg1 = NULL;
+ arg2 = NULL;
+ arg3 = NULL;
+ arg4 = NULL;
+ arg5 = NULL;
+ arg6 = NULL;
+ }
+ };
+ typedef RunArgs RunArgs;
+ typedef ::cppu::WeakImplHelper1< ::com::sun::star::mozilla::XCodeProxy > MNSMozabProxy_BASE;
+
+
+ class MNSMozabProxy : public MNSMozabProxy_BASE
+ {
+ public:
+ MNSMozabProxy();
+ virtual ~MNSMozabProxy();
+
+ //XCodeProxy
+ virtual sal_Int32 SAL_CALL run( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::com::sun::star::mozilla::MozillaProductType SAL_CALL getProductType( ) throw (::com::sun::star::uno::RuntimeException);
+ virtual ::rtl::OUString SAL_CALL getProfileName( ) throw (::com::sun::star::uno::RuntimeException);
+
+ public:
+ sal_Int32 StartProxy(RunArgs * args,::com::sun::star::mozilla::MozillaProductType aProduct,const ::rtl::OUString &aProfile); //Call this to start proxy
+
+ protected:
+ nsresult testLDAPConnection();
+ nsresult InitLDAP(sal_Char* sUri, sal_Unicode* sBindDN, sal_Unicode* sPasswd,sal_Bool * nUseSSL);
+ nsresult QueryHelperStub();
+ private:
+ ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XProxyRunner > xRunner;
+
+ RunArgs * m_Args;
+ ::com::sun::star::mozilla::MozillaProductType m_Product;
+ ::rtl::OUString m_Profile;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+ };
+ }
+}
+#endif //_CONNECTIVITY_MAB_MOZABHELPER_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx
new file mode 100644
index 000000000000..b4c16cd562e6
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.cxx
@@ -0,0 +1,86 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include <MNSTerminateListener.hxx>
+#include <comphelper/processfactory.hxx>
+#include <com/sun/star/frame/XDesktop.hpp>
+#include <MNSInit.hxx>
+
+
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::frame;
+::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> MNSTerminateListener::mxTerminateListener = new MNSTerminateListener();
+
+// -----------------------------------------
+// - MNSTerminateListener -
+// -----------------------------------------
+
+MNSTerminateListener::MNSTerminateListener( )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+MNSTerminateListener::~MNSTerminateListener()
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::disposing( const EventObject& /*Source*/ ) throw( RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::queryTermination( const EventObject& /*aEvent*/ ) throw( TerminationVetoException, RuntimeException )
+{
+}
+
+// -----------------------------------------------------------------------------
+
+void SAL_CALL MNSTerminateListener::notifyTermination( const EventObject& /*aEvent*/ ) throw( RuntimeException )
+{
+ MNS_Term(sal_True); //Force XPCOM to shutdown
+}
+
+void MNSTerminateListener::addTerminateListener()
+{
+ Reference< XMultiServiceFactory > xFact( ::comphelper::getProcessServiceFactory() );
+
+ if( xFact.is() )
+ {
+ Reference< XDesktop > xDesktop( xFact->createInstance( ::rtl::OUString::createFromAscii( "com.sun.star.frame.Desktop" ) ), UNO_QUERY );
+
+ if( xDesktop.is() )
+ xDesktop->addTerminateListener(mxTerminateListener);
+ }
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx
new file mode 100644
index 000000000000..7c173699b6c9
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNSTerminateListener.hxx
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _MNSTERMINATELISTENER_HXX
+#define _MNSTERMINATELISTENER_HXX
+
+#include <cppuhelper/implbase1.hxx>
+#include <com/sun/star/frame/XTerminateListener.hpp>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+
+//class to implement the XTerminateListener interface
+class MNSTerminateListener : public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XTerminateListener >
+{
+
+private:
+
+ // XEventListener
+ virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw( ::com::sun::star::uno::RuntimeException );
+
+ // XTerminateListener
+ virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException );
+ virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& aEvent ) throw( ::com::sun::star::uno::RuntimeException );
+
+
+public:
+ MNSTerminateListener();
+ virtual ~MNSTerminateListener();
+public:
+ static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XTerminateListener> mxTerminateListener;
+ static void addTerminateListener();
+};
+
+#endif
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx
new file mode 100644
index 000000000000..f488c4c4f298
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+
+#include <MNameMapper.hxx>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+
+using namespace connectivity::mozab;
+using namespace rtl;
+
+bool
+MNameMapper::ltstr::operator()( const ::rtl::OUString &s1, const ::rtl::OUString &s2) const
+{
+ return s1.compareTo(s2) < 0;
+}
+
+MNameMapper::MNameMapper()
+{
+ mDirMap = new MNameMapper::dirMap;
+ mUriMap = new MNameMapper::uriMap;
+}
+MNameMapper::~MNameMapper()
+{
+ clear();
+}
+
+void MNameMapper::reset()
+{
+ clear();
+ mDirMap = new MNameMapper::dirMap;
+ mUriMap = new MNameMapper::uriMap;
+}
+void MNameMapper::clear()
+{
+ if ( mUriMap != NULL ) {
+ delete mUriMap;
+ }
+ if ( mDirMap != NULL ) {
+ MNameMapper::dirMap::iterator iter;
+ for (iter = mDirMap -> begin(); iter != mDirMap -> end(); ++iter) {
+ NS_IF_RELEASE(((*iter).second));
+ }
+ delete mDirMap;
+ }
+}
+const char * getURI(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return NULL; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return NULL; }
+ return uri;
+}
+
+// May modify the name passed in so that it's unique
+nsresult
+MNameMapper::add( ::rtl::OUString& str, nsIAbDirectory* abook )
+{
+ MNameMapper::dirMap::iterator iter;
+
+ OSL_TRACE( "IN MNameMapper::add()\n" );
+
+ if ( abook == NULL ) {
+ OSL_TRACE( "\tOUT MNameMapper::add() called with null abook\n" );
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ ::rtl::OUString ouUri=::rtl::OUString::createFromAscii(getURI(abook));
+ if ( mUriMap->find (ouUri) != mUriMap->end() ) //There's already an entry with same uri
+ {
+ return NS_ERROR_FILE_NOT_FOUND;
+ }
+ mUriMap->insert( MNameMapper::uriMap::value_type( ouUri, abook ) );
+
+ ::rtl::OUString tempStr=str;
+ long count =1;
+ while ( mDirMap->find( tempStr ) != mDirMap->end() ) {
+
+ tempStr = str + ::rtl::OUString::valueOf(count);;
+ count ++;
+ }
+ str = tempStr;
+ NS_IF_ADDREF(abook);
+ mDirMap->insert( MNameMapper::dirMap::value_type( str, abook ) );
+ OSL_TRACE( "\tOUT MNameMapper::add()\n" );
+ return 0;
+}
+
+bool
+MNameMapper::getDir( const ::rtl::OUString& str, nsIAbDirectory* *abook )
+{
+ MNameMapper::dirMap::iterator iter;
+
+ OSL_TRACE( "IN MNameMapper::getDir( %s )\n", OUtoCStr(str)?OUtoCStr(str):"NULL" );
+
+ if ( (iter = mDirMap->find( str )) != mDirMap->end() ) {
+ *abook = (*iter).second;
+ NS_IF_ADDREF(*abook);
+ } else {
+ *abook = NULL;
+ }
+
+ OSL_TRACE( "\tOUT MNameMapper::getDir() : %s\n", (*abook)?"True":"False" );
+
+ return( (*abook) != NULL );
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx
new file mode 100644
index 000000000000..eb5d7c97e578
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MNameMapper.hxx
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_NAMEMAPPER_HXX_
+#define _CONNECTIVITY_MAB_NAMEMAPPER_HXX_ 1
+
+#include <map>
+
+// Mozilla includes
+#include <MNSInclude.hxx>
+
+// Star Includes
+#include <rtl/ustring.hxx>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MNameMapper
+ {
+ private:
+
+ struct ltstr
+ {
+ bool operator()( const ::rtl::OUString &s1, const ::rtl::OUString &s2) const;
+ };
+
+
+ typedef ::std::multimap< ::rtl::OUString, nsIAbDirectory *, ltstr > dirMap;
+ typedef ::std::multimap< ::rtl::OUString, nsIAbDirectory *, ltstr > uriMap;
+
+ static MNameMapper *instance;
+ dirMap *mDirMap;
+ uriMap *mUriMap;
+
+ //clear dirs
+ void clear();
+
+ public:
+ static MNameMapper* getInstance();
+
+ MNameMapper();
+ ~MNameMapper();
+
+ // May modify the name passed in so that it's unique
+ nsresult add( ::rtl::OUString& str, nsIAbDirectory* abook );
+
+ //reset dirs
+ void reset();
+
+ // Get the directory corresponding to str
+ bool getDir( const ::rtl::OUString& str, nsIAbDirectory* *abook );
+
+ };
+
+ }
+}
+
+#endif //_CONNECTIVITY_MAB_NAMEMAPPER_HXX_
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx
new file mode 100644
index 000000000000..33534979f085
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.cxx
@@ -0,0 +1,823 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <MQueryHelper.hxx>
+#include <MNameMapper.hxx>
+#include <MConnection.hxx>
+#include <connectivity/dbexception.hxx>
+#include "MQuery.hxx"
+#include "MLdapAttributeMap.hxx"
+#include "MTypeConverter.hxx"
+#include "MNSMozabProxy.hxx"
+#include <com/sun/star/uno/Reference.hxx>
+#include <unotools/processfactory.hxx>
+#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
+
+#if OSL_DEBUG_LEVEL > 0
+# define OUtoCStr( x ) ( ::rtl::OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
+#else /* OSL_DEBUG_LEVEL */
+# define OUtoCStr( x ) ("dummy")
+#endif /* OSL_DEBUG_LEVEL */
+
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+static NS_DEFINE_CID(kAbDirectoryQueryArgumentsCID, NS_ABDIRECTORYQUERYARGUMENTS_CID);
+static NS_DEFINE_CID(kBooleanConditionStringCID, NS_BOOLEANCONDITIONSTRING_CID);
+static NS_DEFINE_CID(kBooleanExpressionCID, NS_BOOLEANEXPRESSION_CID);
+static NS_DEFINE_CID(kAbDirectoryQueryProxyCID, NS_ABDIRECTORYQUERYPROXY_CID);
+static NS_DEFINE_CID(kAbLDAPAttributeMap, NS_IABLDAPATTRIBUTEMAP_IID);
+
+using namespace connectivity::mozab;
+using namespace connectivity;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbc;
+using namespace connectivity;
+
+// -------------------------------------------------------------------------
+// Used to store an nsIAbDirectoryQuery member without the need to use Mozilla
+// types in the MQuery.hxx file.
+//
+namespace connectivity {
+ namespace mozab {
+ struct MQueryDirectory {
+ nsCOMPtr<nsIAbDirectory> directory;
+ nsCOMPtr<nsIAbDirectoryQuery> directoryQuery;
+ PRInt32 contextId;
+ MQueryDirectory() : contextId(-1) {}
+ };
+ }
+}
+
+// -------------------------------------------------------------------------
+/*
+MQuery::MQuery()
+{
+ OSL_TRACE( "IN MQuery::MQuery()\n" );
+
+ construct();
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+
+ OSL_TRACE( "\tOUT MQuery::MQuery()\n" );
+}
+*/
+// -------------------------------------------------------------------------
+MQuery::MQuery( const OColumnAlias& _ca )
+ :m_rColumnAlias( _ca )
+{
+ OSL_TRACE( "IN MQuery::MQuery( ca )\n" );
+
+ construct();
+
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+
+ OSL_TRACE( "\tOUT MQuery::MQuery( ca )\n" );
+}
+// -------------------------------------------------------------------------
+MQuery::~MQuery()
+{
+ OSL_TRACE("IN MQuery::~MQuery()\n");
+
+ // MQueryHelper is reference counted, so we need to decrement the
+ // count here.
+ //
+ if ( m_aQueryDirectory->contextId != -1 && m_aQueryDirectory->directoryQuery !=
+ NULL )
+ m_aQueryDirectory->directoryQuery->StopQuery(m_aQueryDirectory->contextId);
+
+ if ( m_aQueryDirectory )
+ delete m_aQueryDirectory;
+
+ NS_IF_RELEASE( m_aQueryHelper);
+
+ OSL_TRACE("\tOUT MQuery::~MQuery()\n");
+}
+// -----------------------------------------------------------------------------
+void MQuery::construct()
+{
+ // Set default values. (For now just as a reminder).
+ m_aError.reset();
+ m_bQuerySubDirs = sal_True; // LDAP Queryies require this to be set!
+ m_nMaxNrOfReturns = -1; // Unlimited number of returns.
+
+ m_aQueryDirectory = new MQueryDirectory();
+ // MQueryHelper is reference counted, so we need to add to the
+ // count here to prevent accidental deletion else where...
+ //
+ m_aQueryHelper = new MQueryHelper();
+ NS_IF_ADDREF( m_aQueryHelper);
+}
+// -------------------------------------------------------------------------
+void MQuery::setAddressbook(::rtl::OUString &ab)
+{
+ OSL_TRACE("IN MQuery::setAddressbook()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aAddressbook = ab;
+
+ OSL_TRACE("\tOUT MQuery::setAddressbook()\n");
+}
+// -------------------------------------------------------------------------
+::rtl::OUString MQuery::getAddressbook() const
+{
+ OSL_TRACE("IN MQuery::getAddressbook()\n");
+
+ OSL_TRACE("\tOUT MQuery::getAddressbook()\n");
+
+ return(m_aAddressbook);
+}
+// -------------------------------------------------------------------------
+void MQuery::setMaxNrOfReturns(const sal_Int32 mnr)
+{
+ OSL_TRACE( "IN MQuery::setMaxNrOfReturns()\n" );
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_nMaxNrOfReturns = mnr;
+ OSL_TRACE("\tOUT MQuery::setMaxNrOfReturns()\n" );
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::getMaxNrOfReturns() const
+{
+ OSL_TRACE("IN MQuery::getMaxNrOfReturns()\n");
+
+ OSL_TRACE("\tOUT MQuery::getMaxNrOfReturns()\n");
+
+ return(m_nMaxNrOfReturns);
+}
+// -------------------------------------------------------------------------
+void MQuery::setQuerySubDirs(sal_Bool &qsd)
+{
+ OSL_TRACE("IN MQuery::setQuerySubDirs()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_bQuerySubDirs = qsd;
+ OSL_TRACE("\tOUT MQuery::setQuerySubDirs()\n");
+}
+// -------------------------------------------------------------------------
+sal_Bool MQuery::getQuerySubDirs() const
+{
+ OSL_TRACE("IN MQuery::getQuerySubDirs()\n");
+
+ OSL_TRACE("\tOUT MQuery::getQuerySubDirs()\n");
+
+ return(m_bQuerySubDirs);
+}
+// -------------------------------------------------------------------------
+void MQuery::setExpression( MQueryExpression &_expr )
+{
+ OSL_TRACE("IN MQuery::setExpression()\n");
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ m_aExpr = _expr;
+
+ OSL_TRACE("\tOUT MQuery::setExpression()\n");
+}
+// -------------------------------------------------------------------------
+static sal_Int32 generateExpression( MQuery* _aQuery, MQueryExpression* _aExpr,
+ nsIAbBooleanExpression* queryExpression )
+{
+ nsresult rv; // Store return values.
+ // Array that holds all matchItems, to be passed to DoQuery().
+ nsCOMPtr<nsISupportsArray> matchItems;
+ NS_NewISupportsArray(getter_AddRefs(matchItems));
+
+ // Add every individual boolString to matchItems array.
+ nsString matchValue;
+ // Initialise the matchItems container.
+ MQueryExpression::ExprVector::iterator evIter;
+ for( evIter = _aExpr->getExpressions().begin();
+ evIter != _aExpr->getExpressions().end();
+ ++evIter )
+ {
+ if ( (*evIter)->isStringExpr() ) {
+ nsCOMPtr<nsIAbBooleanConditionString> boolString = do_CreateInstance (kBooleanConditionStringCID, &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ MQueryExpressionString* evStr = static_cast<MQueryExpressionString*> (*evIter);
+
+ // Set the 'name' property of the boolString.
+ // Check if it's an alias first...
+ rtl::OString attrName = _aQuery->getColumnAlias().getProgrammaticNameOrFallbackToUTF8Alias( evStr->getName() );
+ boolString->SetName( strdup( attrName.getStr() ) );
+ OSL_TRACE("Name = %s ;", attrName.getStr() );
+ // Set the 'matchType' property of the boolString. Check for equal length.
+ sal_Bool requiresValue = sal_True;
+ switch(evStr->getCond()) {
+ case MQueryOp::Exists:
+ OSL_TRACE("MQueryOp::Exists; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Exists);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::DoesNotExist:
+ OSL_TRACE("MQueryOp::DoesNotExist; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotExist);
+ requiresValue = sal_False;
+ break;
+ case MQueryOp::Contains:
+ OSL_TRACE("MQueryOp::Contains; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Contains);
+ break;
+ case MQueryOp::DoesNotContain:
+ OSL_TRACE("MQueryOp::DoesNotContain; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::DoesNotContain);
+ break;
+ case MQueryOp::Is:
+ OSL_TRACE("MQueryOp::Is; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ case MQueryOp::IsNot:
+ OSL_TRACE("MQueryOp::IsNot; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::IsNot);
+ break;
+ case MQueryOp::BeginsWith:
+ OSL_TRACE("MQueryOp::BeginsWith; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::BeginsWith);
+ break;
+ case MQueryOp::EndsWith:
+ OSL_TRACE("MQueryOp::EndsWith; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::EndsWith);
+ break;
+ case MQueryOp::SoundsLike:
+ OSL_TRACE("MQueryOp::SoundsLike; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::SoundsLike);
+ break;
+ case MQueryOp::RegExp:
+ OSL_TRACE("MQueryOp::RegExp; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::RegExp);
+ break;
+ default:
+ OSL_TRACE("(default) MQueryOp::Is; ");
+ boolString->SetCondition(nsIAbBooleanConditionTypes::Is);
+ break;
+ }
+ // Set the 'matchValue' property of the boolString. Value returned in unicode.
+ if ( requiresValue )
+ {
+ OSL_TRACE("Value = %s \n", OUtoCStr( evStr->getValue() ) );
+ MTypeConverter::ouStringToNsString( evStr->getValue(), matchValue);
+ boolString->SetValue(matchValue.get ());
+ }
+ // Add the individual boolString to the container of matchItems.
+ matchItems->AppendElement(boolString);
+ }
+ else if ( (*evIter)->isExpr() ) {
+ nsCOMPtr< nsIAbBooleanExpression > subQueryExpr = do_CreateInstance( kBooleanExpressionCID , &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+ rv = generateExpression( _aQuery, static_cast< MQueryExpression* >(*evIter),
+ subQueryExpr );
+ NS_ENSURE_SUCCESS( rv, rv );
+ matchItems->AppendElement(subQueryExpr);
+ }
+ else {
+ // Should never see this...
+ OSL_ASSERT("Unknown Expression Type!");
+ return( NS_ERROR_UNEXPECTED );
+ }
+ }
+
+ queryExpression->SetExpressions(matchItems);
+ if ( _aExpr->getExpressionCondition() == MQueryExpression::AND )
+ queryExpression->SetOperation(nsIAbBooleanOperationTypes::AND);
+ else
+ queryExpression->SetOperation(nsIAbBooleanOperationTypes::OR);
+
+ return( NS_OK );
+}
+sal_uInt32 MQuery::InsertLoginInfo(OConnection* _pCon)
+{
+ nsresult rv; // Store return values.
+
+ rtl::OUString nameAB = _pCon->getHost().replace('.','_');
+ rtl::OUString bindDN = _pCon->getBindDN();
+ rtl::OUString password = _pCon->getPassword();
+ sal_Bool useSSL = _pCon->getUseSSL();
+
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create the ldap maxHits entry for the preferences file.
+ // Note: maxHits is applicable to LDAP only in mozilla.
+ nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers."));
+ const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(nameAB.getStr());
+ prefName.Append(pAddressBook);
+
+ if (bindDN.getLength())
+ {
+ nsCAutoString bindPrefName=prefName;
+ bindPrefName.Append(NS_LITERAL_CSTRING(".auth.dn"));
+ rv = prefs->SetCharPref (bindPrefName.get(),
+ MTypeConverter::ouStringToCCharStringAscii( bindDN.getStr() ) );
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCAutoString pwdPrefName=prefName;
+ pwdPrefName.Append(NS_LITERAL_CSTRING(".auth.pwd"));
+ rv = prefs->SetCharPref (pwdPrefName.get(),
+ MTypeConverter::ouStringToCCharStringAscii( password.getStr() ) );
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ if (useSSL)
+ {
+ nsCAutoString sslPrefName=prefName;
+ sslPrefName.Append(NS_LITERAL_CSTRING(".UseSSL"));
+ rv = prefs->SetBoolPref (sslPrefName.get(),useSSL);
+ NS_ENSURE_SUCCESS(rv, rv);
+ }
+ return rv;
+}
+
+//determine whether current profile is locked,any error will lead to return true
+sal_Bool isProfileLocked(OConnection* _pCon)
+{
+ ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap > xMozillaBootstrap;
+ ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
+ OSL_ENSURE( xFactory.is(), "can't get service factory" );
+
+ ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xInstance = xFactory->createInstance(::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.mozilla.MozillaBootstrap")) );
+ OSL_ENSURE( xInstance.is(), "failed to create instance" );
+ xMozillaBootstrap = ::com::sun::star::uno::Reference< ::com::sun::star::mozilla::XMozillaBootstrap >(xInstance,::com::sun::star::uno::UNO_QUERY);
+ if (_pCon)
+ return xMozillaBootstrap->isProfileLocked(_pCon->getProduct(),_pCon->getMozProfile());
+ else
+ return xMozillaBootstrap->isCurrentProfileLocked();
+}
+
+
+// -------------------------------------------------------------------------
+sal_Int32 getDirectoryType(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return SDBCAddress::Unknown; }
+ const sal_Char *sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_LDAP );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::LDAP;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Mozilla;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_MOZILLA_MDB );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Mozilla;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_EXPRESS );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::OutlookExp;
+ }
+ sUriPrefix = ::connectivity::mozab::getSchemeURI( ::connectivity::mozab::SCHEME_OUTLOOK_MAPI );
+ if (strncmp(uri,sUriPrefix,strlen(sUriPrefix)) == 0)
+ {
+ return SDBCAddress::Outlook;
+ }
+ return SDBCAddress::Unknown;
+
+}
+// -------------------------------------------------------------------------
+sal_Bool isForceQueryProxyUsed(const nsIAbDirectory* directory)
+{
+ sal_Int32 nType = getDirectoryType(directory);
+ if (nType == SDBCAddress::Outlook || nType == SDBCAddress::OutlookExp)
+ return sal_True;
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::commitRow(const sal_Int32 rowIndex)
+{
+ if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery)
+ return sal_False;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_COMMIT_CARD;
+ args.argCount = 3;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&rowIndex;
+ args.arg3 = (void*)m_aQueryDirectory->directory;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return rv;
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::deleteRow(const sal_Int32 rowIndex)
+{
+ if (!m_aQueryHelper || !m_aQueryDirectory || !m_aQueryDirectory->directoryQuery)
+ return sal_False;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_DELETE_CARD;
+ args.argCount = 3;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&rowIndex;
+ args.arg3 = (void*)m_aQueryDirectory->directory;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return rv;
+
+}
+
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::executeQuery(OConnection* _pCon)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ OSL_TRACE("IN MQuery::executeQuery()\n");
+ m_Product = _pCon->getProduct();
+ m_Profile = _pCon->getMozProfile();
+
+ nsresult rv;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_EXECUTE_QUERY;
+ args.argCount = 2;
+ args.arg1 = (void*)this;
+ args.arg2 = (void*)_pCon;
+ rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ return rv;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQuery::executeQueryProxied(OConnection* _pCon)
+{
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE("IN MQuery::executeQueryProxied() Caller thread: %4d \n", m_oThreadID);
+#endif
+
+ nsresult rv; // Store return values.
+ // MTypeConverter aTypeConverter;
+ // Create a nsIAbDirectory object to initialise the nsIAbDirectoryQuery object.
+ nsCOMPtr<nsIRDFService> rdfService(do_GetService(kRDFServiceCID, &rv)) ;
+ if (NS_FAILED(rv))
+ return(-1);
+
+ nsCOMPtr<nsIAbDirectory> directory;
+ MNameMapper *nmap = _pCon->getNameMapper();
+
+
+ if ( nmap->getDir( m_aAddressbook, getter_AddRefs( directory ) ) == sal_False )
+ return( -1 );
+
+
+ //insert ldap bind info to mozilla profile(in memery,none saved),so we can use it in mozilla part codes
+ if (_pCon->isLDAP())
+ {
+ rv = InsertLoginInfo(_pCon);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ }
+ // Since Outlook Express and Outlook in OCL mode support a very limited query capability,
+ // we use the following bool to judge whether we need bypass any use of a DirectoryQuery
+ // interface and instead force the use of the QueryProxy.
+ sal_Bool forceQueryProxyUse = isForceQueryProxyUsed(directory);
+
+ m_aQueryDirectory->directory = directory;
+ // Initialize directory in cases of LDAP and Mozilla
+ if (!forceQueryProxyUse) m_aQueryDirectory->directoryQuery = do_QueryInterface(directory, &rv);
+
+ if ( NS_FAILED(rv) || forceQueryProxyUse)
+ {
+ // Create a nsIAbDirectoryQuery object which eventually will execute
+ // the query by calling DoQuery().
+ nsCOMPtr< nsIAbDirectoryQueryProxy > directoryQueryProxy = do_CreateInstance( kAbDirectoryQueryProxyCID, &rv);
+
+ // Need to turn this off for anything using the Query Proxy since it
+ // treats Mailing Lists as directories!
+
+ m_bQuerySubDirs = sal_False;
+
+ rv = directoryQueryProxy->Initiate (directory);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ m_aQueryDirectory->directoryQuery = do_QueryInterface (directoryQueryProxy, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+ OSL_TRACE("Using the directoryQueryProxy\n");
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else
+ OSL_TRACE("Not using a Query Proxy, Query i/f supported by directory\n");
+#endif /* OSL_DEBUG_LEVEL */
+
+ /*
+ // The problem here is that an LDAP Address Book may exist as
+ // a Mozilla Address Book. So we need to limit the number of
+ // records returned by the Server:
+ // 1. Determine if this is an LDAP Address Book
+ // [LDAP overrides the default operations(write|read|search) of all types with search only].
+ // 2. Determine if the limit is already set by us.
+ // 3. Use the mozilla preferences to see if this value is set.
+ // 4. Use value or else default to 100.
+ */
+ PRBool isWriteable;
+ rv = directory->GetOperations (&isWriteable);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if (!(isWriteable & nsIAbDirectory::opWrite))
+ {
+ if(m_nMaxNrOfReturns == -1)
+ {
+ // Determine if the limit maxHits has been set in the mozilla preferences
+ // if set, then use the value otherwise default to 100
+ nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID, &rv);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // create the ldap maxHits entry for the preferences file.
+ // Note: maxHits is applicable to LDAP only in mozilla.
+ nsCAutoString prefName(NS_LITERAL_CSTRING("ldap_2.servers."));
+ const char *pAddressBook = MTypeConverter::ouStringToCCharStringAscii(m_aAddressbook);
+ prefName.Append(pAddressBook);
+ prefName.Append(NS_LITERAL_CSTRING(".maxHits"));
+
+ PRInt32 maxHits;
+ rv = prefs->GetIntPref(prefName.get(), &maxHits);
+ if (NS_FAILED(rv))
+ m_nMaxNrOfReturns = 100;
+ else
+ m_nMaxNrOfReturns = maxHits;
+ }
+ }
+
+
+ nsCOMPtr< nsIAbBooleanExpression > queryExpression = do_CreateInstance( kBooleanExpressionCID , &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+ rv = generateExpression( this, &m_aExpr, queryExpression );
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ // Use the nsIAbCard to return the card properties.
+ const char *returnProperties[] = {"card:nsIAbCard"};
+ PRInt32 count=1;
+
+ nsCOMPtr< nsIAbDirectoryQueryArguments > arguments = do_CreateInstance( kAbDirectoryQueryArgumentsCID, &rv);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetExpression(queryExpression);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetReturnProperties(count, returnProperties);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ rv = arguments->SetQuerySubDirectories(m_bQuerySubDirs);
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ nsCOMPtr< nsIAbLDAPAttributeMap > attributeMap( new MLdapAttributeMap );
+ rv = arguments->SetTypeSpecificArg( attributeMap );
+ NS_ENSURE_SUCCESS( rv, rv );
+
+ // Execute the query.
+ OSL_TRACE( "****** calling DoQuery\n");
+
+ m_aError.reset();
+
+ m_aQueryHelper->reset();
+
+ rv = m_aQueryDirectory->directoryQuery->DoQuery(arguments, m_aQueryHelper, m_nMaxNrOfReturns, -1, &m_aQueryDirectory->contextId);
+
+
+ if (NS_FAILED(rv)) {
+ m_aQueryDirectory->contextId = -1;
+ OSL_TRACE( "****** DoQuery failed\n");
+ OSL_TRACE("\tOUT MQuery::executeQueryProxied()\n");
+ m_aQueryHelper->notifyQueryError() ;
+ return(-1);
+ }
+#if OSL_DEBUG_LEVEL > 0
+ else {
+ OSL_TRACE( "****** DoQuery succeeded \n");
+ }
+#endif
+
+ OSL_TRACE("\tOUT MQuery::executeQueryProxied()\n");
+
+ return(0);
+}
+
+// -------------------------------------------------------------------------
+//
+//
+// If the query executed is being done asynchronously then this may return
+// -1 as the count, ie. it's undetermined.
+//
+sal_Int32
+MQuery::getRowCount()
+{
+ return( m_aQueryHelper->getResultCount() );
+}
+
+// -------------------------------------------------------------------------
+//
+//
+// As opposed to getRowCount() this returns the actual number of rows fetched
+// so far (if is an async query)
+//
+sal_uInt32
+MQuery::getRealRowCount()
+{
+ return( m_aQueryHelper->getRealCount() );
+}
+
+//
+// If the query executed is being done asynchronously then this may be
+// false
+//
+sal_Bool
+MQuery::queryComplete( void )
+{
+ return( hadError() || m_aQueryHelper->queryComplete() );
+}
+
+sal_Bool
+MQuery::waitForQueryComplete( void )
+{
+ if( m_aQueryHelper->waitForQueryComplete( ) )
+ return sal_True;
+ m_aError = m_aQueryHelper->getError();
+ return( sal_False );
+}
+
+// -------------------------------------------------------------------------
+
+sal_Bool
+MQuery::checkRowAvailable( sal_Int32 nDBRow )
+{
+ while( !queryComplete() && m_aQueryHelper->getRealCount() <= (sal_uInt32)nDBRow )
+ if ( !m_aQueryHelper->waitForRow( nDBRow ) ) {
+ m_aError = m_aQueryHelper->getError();
+ return( sal_False );
+ }
+
+ return( getRowCount() > nDBRow );
+}
+// -------------------------------------------------------------------------
+sal_Bool
+MQuery::setRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType ) const
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError();
+ return sal_False;
+ }
+ switch ( nType )
+ {
+ case DataType::VARCHAR:
+ xResEntry->setValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ), rValue.getString() );
+ break;
+ default:
+ OSL_ENSURE( sal_False, "invalid data type!" );
+ break;
+ }
+
+ return sal_True;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool
+MQuery::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const rtl::OUString& aDBColumnName, sal_Int32 nType ) const
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ const_cast< MQuery* >( this )->m_aError = m_aQueryHelper->getError();
+ rValue.setNull();
+ return sal_False;
+ }
+ switch ( nType )
+ {
+ case DataType::VARCHAR:
+ rValue = xResEntry->getValue( m_rColumnAlias.getProgrammaticNameOrFallbackToUTF8Alias( aDBColumnName ) );
+ break;
+
+ default:
+ rValue.setNull();
+ break;
+ }
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32
+MQuery::getRowStates(sal_Int32 nDBRow)
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ m_aError = m_aQueryHelper->getError();
+ return RowStates_Error;
+ }
+ return xResEntry->getRowStates();
+}
+sal_Bool
+MQuery::setRowStates(sal_Int32 nDBRow,sal_Int32 aState)
+{
+ MQueryHelperResultEntry* xResEntry = m_aQueryHelper->getByIndex( nDBRow );
+
+ OSL_ENSURE( xResEntry != NULL, "xResEntry == NULL");
+ if (xResEntry == NULL )
+ {
+ m_aError = m_aQueryHelper->getError();
+ return sal_False;
+ }
+ return xResEntry->setRowStates(aState);
+}
+
+sal_Bool
+MQuery::resyncRow(sal_Int32 nDBRow)
+{
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_RESYNC_CARD;
+ args.argCount = 2;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&nDBRow;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+ m_aError = m_aQueryHelper->getError();
+ return NS_SUCCEEDED( rv ) ? sal_True : sal_False;
+}
+
+sal_Int32
+MQuery::createNewCard()
+{
+ sal_Int32 nNumber = 0;
+ MNSMozabProxy xMProxy;
+ RunArgs args;
+ args.funcIndex = ProxiedFunc::FUNC_QUERYHELPER_CREATE_NEW_CARD;
+ args.argCount = 2;
+ args.arg1 = (void*)m_aQueryHelper;
+ args.arg2 = (void*)&nNumber;
+ nsresult rv = xMProxy.StartProxy(&args,m_Product,m_Profile);
+
+ m_aError = m_aQueryHelper->getError();
+ NS_ENSURE_SUCCESS(rv,0);
+ return nNumber;
+}
+// -------------------------------------------------------------------------
+
+MNameMapper*
+MQuery::CreateNameMapper()
+{
+ return( new MNameMapper() );
+}
+
+// -------------------------------------------------------------------------
+void
+MQuery::FreeNameMapper( MNameMapper* _ptr )
+{
+ delete _ptr;
+}
+// -------------------------------------------------------------------------
+sal_Bool MQuery::isWritable(OConnection* _pCon)
+{
+ if ( !m_aQueryDirectory )
+ return sal_False;
+
+ nsresult rv; // Store return values.
+ nsCOMPtr<nsIAbDirectory> directory = do_QueryInterface(m_aQueryDirectory->directory, &rv);;
+ if (NS_FAILED(rv))
+ return sal_False;
+ if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(_pCon))
+ return sal_False;
+
+ PRBool isWriteable;
+ rv = directory->GetOperations (&isWriteable);
+ if (NS_FAILED(rv))
+ return sal_False;
+ sal_Bool bWritable = ( isWriteable & nsIAbDirectory::opWrite ) == nsIAbDirectory::opWrite;
+ return bWritable;
+}
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx
new file mode 100644
index 000000000000..8d7d52e6eb97
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQuery.hxx
@@ -0,0 +1,282 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _CONNECTIVITY_MAB_QUERY_HXX_
+#define _CONNECTIVITY_MAB_QUERY_HXX_
+
+#include "MColumnAlias.hxx"
+#include "MErrorResource.hxx"
+#include <connectivity/FValue.hxx>
+#include "MNSDeclares.hxx"
+#include <osl/thread.hxx>
+#ifndef _COM_SUN_STAR_MOZILLA_MOZILLPRODUCTTYPE_HPP_
+#include <com/sun/star/mozilla/MozillaProductType.hpp>
+#endif
+
+namespace connectivity
+{
+ namespace mozab
+ {
+
+ class MQueryHelper;
+ struct MQueryDirectory;
+
+ namespace MQueryOp {
+ typedef enum {
+ Exists = 0,
+ DoesNotExist = 1,
+ Contains = 2,
+ DoesNotContain = 3,
+ Is = 4,
+ IsNot = 5,
+ BeginsWith = 6,
+ EndsWith = 7,
+ SoundsLike = 8,
+ RegExp = 9
+ } cond_type;
+ }
+
+ class MQueryExpressionBase {
+ public:
+ typedef enum {
+ Unknown,
+ StringExpr,
+ Expr
+ } node_type;
+
+ protected:
+ node_type m_eNodeType;
+
+ MQueryExpressionBase() : m_eNodeType( Unknown ) {}
+ MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
+
+ public:
+ sal_Bool isUnknown( ) { return m_eNodeType == Unknown; }
+ sal_Bool isStringExpr( ) { return m_eNodeType == StringExpr; }
+ sal_Bool isExpr( ) { return m_eNodeType == Expr; }
+ };
+
+ class MQueryExpressionString : public MQueryExpressionBase {
+ protected:
+ ::rtl::OUString m_aName; // LHS
+ MQueryOp::cond_type m_aBooleanCondition;
+ ::rtl::OUString m_aValue; // RHS
+
+ public:
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond,
+ ::rtl::OUString rhs )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( rhs )
+ {
+ }
+
+ MQueryExpressionString( ::rtl::OUString& lhs,
+ MQueryOp::cond_type cond )
+ : MQueryExpressionBase( MQueryExpressionBase::StringExpr )
+ , m_aName( lhs )
+ , m_aBooleanCondition( cond )
+ , m_aValue( ::rtl::OUString() )
+ {
+ }
+
+ const ::rtl::OUString& getName() const { return m_aName; }
+ MQueryOp::cond_type getCond() const { return m_aBooleanCondition; }
+ const ::rtl::OUString& getValue() const { return m_aValue; }
+ };
+
+ class MQuery;
+
+ class MQueryExpression : public MQueryExpressionBase
+ {
+ friend class MQuery;
+
+ public:
+ typedef ::std::vector< MQueryExpressionBase* > ExprVector;
+
+ typedef enum {
+ AND,
+ OR
+ } bool_cond;
+
+ void setExpressions( ExprVector& _exprVector )
+ { m_aExprVector = _exprVector; }
+
+ // All expressions on a peer level use same condition operator
+ void setExpressionCondition( bool_cond _cond )
+ { m_aExprCondType = _cond; }
+
+ ExprVector& getExpressions( )
+ { return m_aExprVector; }
+
+ // All expressions on a peer level use same condition operator
+ bool_cond getExpressionCondition( )
+ { return m_aExprCondType; }
+
+ MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
+ m_aExprCondType( OR )
+ { m_aExprVector.clear(); }
+
+
+ protected:
+ ExprVector m_aExprVector;
+ bool_cond m_aExprCondType;
+
+ };
+
+
+ class MQuery
+ {
+ /*
+ * A query resultset with a maximum limit of
+ * m_nMaxNrOfReturns return items, is created from
+ * the following SQL statement:
+ *
+ * -------------------------------------------------
+ * SELECT m_aAttributes FROM m_aAddressbook
+ * WHERE m_aMatchItems SQL_OPR m_aMatchValue
+ * -------------------------------------------------
+ *
+ * We are\are not, depending on boolean m_bQuerySubDirs,
+ * interested in querying the sub-directories of the
+ * addressbook directory, if any.
+ *
+ * SQL_OPR:
+ * m_aSqlOppr contains the SQL operations for every
+ * attribute in m_aAttributes.
+ * This member must be initialised together with
+ * m_aAttributes.
+ *
+ * The SQL operations defined for 'SQL_OPR' are:
+ * matchExists = 0,
+ * matchDoesNotExist = 1,
+ * matchContains = 2,
+ * matchDoesNotContain = 3,
+ * matchIs = 4,
+ * matchIsNot = 5,
+ * matchBeginsWith = 6,
+ * matchEndsWith = 7,
+ * matchSoundsLike = 8,
+ * matchRegExp = 9.
+ * There must be mapping to one of these values.
+ *
+ * The following members MUST be initialised before
+ * a query is executed:
+ * m_Attributes, m_aMapAttrOppr, m_aAddressbook,
+ * m_aMatchItems and m_aMatchValue.
+ *
+ * m_bQuerySubDirs and m_nMaxNrReturns are set to a
+ * default value in the constructor which can be
+ * overridden. If (element of) m_aSqlOppr is not set,
+ * the default SQL operation is 'matchIs'.
+ *
+ */
+ private:
+ MQueryDirectory *m_aQueryDirectory;
+ MQueryHelper *m_aQueryHelper;
+ ::rtl::OUString m_aAddressbook;
+ sal_Int32 m_nMaxNrOfReturns;
+ sal_Bool m_bQuerySubDirs;
+ MQueryExpression m_aExpr;
+ const OColumnAlias& m_rColumnAlias;
+ ::com::sun::star::mozilla::MozillaProductType
+ m_Product;
+ ::rtl::OUString m_Profile;
+ ErrorDescriptor m_aError;
+
+ void construct();
+ protected:
+ ::osl::Mutex m_aMutex;
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+
+ public:
+ /*
+ * - Contains accessors to the members of this class.
+ * - executeQuery() initiates a non-blocking query.
+ */
+ sal_Int32 executeQuery(OConnection* _pCon);
+ sal_Int32 executeQueryProxied(OConnection* _pCon); //Used only by MNSMozabProxy
+
+ sal_Int32 createNewCard(); //return Row count number
+ sal_Int32 deleteRow(const sal_Int32 rowIndex);
+ sal_Int32 commitRow(const sal_Int32 rowIndex);
+ sal_Bool resyncRow(sal_Int32 nDBRow);
+
+ sal_Bool isWritable(OConnection* _pCon);
+
+ sal_uInt32 InsertLoginInfo(OConnection* _pCon);
+
+ void setAddressbook( ::rtl::OUString&);
+ ::rtl::OUString getAddressbook(void) const;
+
+ const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
+
+ void setExpression( MQueryExpression &_expr );
+
+ void setMaxNrOfReturns( const sal_Int32);
+ sal_Int32 getMaxNrOfReturns(void) const;
+
+ void setQuerySubDirs( sal_Bool&);
+ sal_Bool getQuerySubDirs(void) const;
+
+ sal_Int32 getRowCount( void );
+ sal_uInt32 getRealRowCount( void );
+ sal_Bool queryComplete( void );
+ sal_Bool waitForQueryComplete( void );
+ sal_Bool checkRowAvailable( sal_Int32 nDBRow );
+ sal_Bool getRowValue( connectivity::ORowSetValue& rValue,
+ sal_Int32 nDBRow,
+ const rtl::OUString& aDBColumnName,
+ sal_Int32 nType ) const;
+ sal_Bool setRowValue( connectivity::ORowSetValue& rValue,
+ sal_Int32 nDBRow,
+ const rtl::OUString& aDBColumnName,
+ sal_Int32 nType ) const;
+ sal_Int32 getRowStates(sal_Int32 nDBRow);
+ sal_Bool setRowStates(sal_Int32 nDBRow,sal_Int32 aState);
+
+ bool hadError() const { return m_aError.is(); }
+ inline const ErrorDescriptor& getError() const { return m_aError; }
+
+ public:
+// MQuery();
+ MQuery( const OColumnAlias& _ca );
+ virtual ~MQuery();
+ static MNameMapper* CreateNameMapper();
+ static void FreeNameMapper( MNameMapper* _ptr );
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MAB_QUERY_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx
new file mode 100644
index 000000000000..f63336870d95
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.cxx
@@ -0,0 +1,635 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include "MQueryHelper.hxx"
+#include "MTypeConverter.hxx"
+#include "MConnection.hxx"
+#include "MNSDeclares.hxx"
+#include "MLdapAttributeMap.hxx"
+
+#include <connectivity/dbexception.hxx>
+
+#include "resource/mozab_res.hrc"
+
+using namespace connectivity::mozab;
+
+
+NS_IMPL_THREADSAFE_ISUPPORTS1(connectivity::mozab::MQueryHelper,nsIAbDirectoryQueryResultListener)
+
+//
+// class MQueryHelperResultEntry
+//
+
+
+MQueryHelperResultEntry::MQueryHelperResultEntry()
+{
+ m_Card = NULL;
+ m_RowStates = 0;
+}
+
+MQueryHelperResultEntry::~MQueryHelperResultEntry()
+{
+ OSL_TRACE("IN MQueryHelperResultEntry::~MQueryHelperResultEntry()\n");
+ OSL_TRACE("OUT MQueryHelperResultEntry::~MQueryHelperResultEntry()\n");
+
+}
+void
+MQueryHelperResultEntry::setCard(nsIAbCard *card)
+{
+ m_Card = card;
+}
+nsIAbCard *
+MQueryHelperResultEntry::getCard()
+{
+ return m_Card;
+}
+void MQueryHelperResultEntry::insert( const rtl::OString &key, rtl::OUString &value )
+{
+ m_Fields[ key ] = value;
+}
+
+rtl::OUString MQueryHelperResultEntry::getValue( const rtl::OString &key ) const
+{
+ FieldMap::const_iterator iter = m_Fields.find( key );
+ if ( iter == m_Fields.end() )
+ {
+ return rtl::OUString();
+ }
+ else
+ {
+ return iter->second;
+ }
+}
+
+void MQueryHelperResultEntry::setValue( const rtl::OString &key, const rtl::OUString & rValue)
+{
+ m_Fields[ key ] = rValue;
+}
+//
+// class MQueryHelper
+//
+MQueryHelper::MQueryHelper()
+ :m_nIndex( 0 )
+ ,m_bHasMore( sal_True )
+ ,m_bAtEnd( sal_False )
+ ,m_bErrorCondition( sal_False )
+ ,m_bQueryComplete( sal_False )
+ ,mRefCnt( 0 ) // NSISUPPORTS - Initialize RefCnt to 0
+{
+ m_aResults.clear();
+#if OSL_DEBUG_LEVEL > 0
+ m_oThreadID = osl_getThreadIdentifier(NULL);
+#endif
+}
+
+MQueryHelper::~MQueryHelper()
+{
+ OSL_TRACE("IN MQueryHelper::~MQueryHelper()\n");
+ clear_results();
+ OSL_TRACE("OUT MQueryHelper::~MQueryHelper()\n");
+}
+
+void
+MQueryHelper::append(MQueryHelperResultEntry* resEnt )
+{
+ if ( resEnt != NULL ) {
+ m_aResults.push_back( resEnt );
+ m_bAtEnd = sal_False;
+ }
+}
+
+void
+MQueryHelper::clear_results()
+{
+ resultsArray::iterator iter = m_aResults.begin();
+ while ( iter != m_aResults.end() ) {
+ delete (*iter);
+ ++iter;
+ }
+ m_aResults.clear();
+}
+
+void
+MQueryHelper::rewind()
+{
+ m_nIndex = 0;
+}
+
+void
+MQueryHelper::reset()
+{
+ m_nIndex = 0;
+ m_bHasMore = sal_True;
+ m_bQueryComplete = sal_False;
+ m_bAtEnd = sal_False;
+ m_bErrorCondition = sal_False;
+ clear_results();
+}
+
+void
+MQueryHelper::clearResultOrComplete()
+{
+ // Don't use a Mutex, it should be called by a method already holding it.
+ OSL_TRACE("In/Out : clearResultOrComplete()");
+ m_aCondition.reset();
+}
+
+void
+MQueryHelper::notifyResultOrComplete()
+{
+ OSL_TRACE("In/Out : notifyResultOrComplete()");
+ m_aCondition.set();
+}
+
+sal_Bool
+MQueryHelper::waitForResultOrComplete( )
+{
+ TimeValue timeValue = { 1, 0 }; // 20 Seconds 0 NanoSecond timeout
+ sal_Int32 times=0;
+ osl::Condition::Result rv = ::osl::Condition::result_ok;
+
+ OSL_TRACE("In : waitForResultOrComplete()");
+ // Can't hold mutex or condition would never get set...
+ while( (m_aCondition.check() == sal_False || rv == ::osl::Condition::result_error) && times < 20) {
+ rv = m_aCondition.wait( &timeValue );
+ times ++;
+ }
+ if (times >= 20 && rv == ::osl::Condition::result_timeout ) {
+ OSL_TRACE("waitForResultOrComplete() : Timeout!");
+ m_aError.setResId( STR_TIMEOUT_WAITING );
+ return sal_False;
+ }
+
+ if ( isError() ) {
+ OSL_TRACE("waitForResultOrComplete() : Error returned!");
+ m_aError.setResId( STR_ERR_EXECUTING_QUERY );
+ return sal_False;
+ }
+ m_aError.reset();
+ OSL_TRACE(" Out : waitForResultOrComplete()");
+ return sal_True;
+}
+
+
+MQueryHelperResultEntry*
+MQueryHelper::next( )
+{
+ MQueryHelperResultEntry* result;
+ sal_Int32 index;
+
+ m_aMutex.acquire();
+ index = m_nIndex;
+ m_aMutex.release();
+
+ result = getByIndex( m_nIndex + 1) ; // Add 1 as Row is numbered from 1 to N
+
+ if ( result ) {
+ m_aMutex.acquire();
+ m_nIndex++;
+ m_aMutex.release();
+ }
+
+ return( result );
+}
+
+MQueryHelperResultEntry*
+MQueryHelper::getByIndex( sal_uInt32 nRow )
+{
+ // Row numbers are from 1 to N, need to ensure this, and then
+ // substract 1
+ if ( nRow < 1 ) {
+ return( NULL );
+ }
+
+ do {
+ // Obtain the Mutex - don't use a guard as we want to be able to release
+ // and acquire again...
+ m_aMutex.acquire();
+ if ( nRow > m_aResults.size() )
+ {
+ if ( m_bQueryComplete )
+ {
+ m_bAtEnd = sal_True;
+ m_aMutex.release();
+ return( NULL );
+ }
+ else
+ {
+ clearResultOrComplete();
+ m_aMutex.release();
+ if ( !waitForResultOrComplete( ) )
+ return( NULL );
+ }
+ }
+ else
+ {
+ m_aMutex.release();
+ return( m_aResults[ nRow -1 ] );
+ }
+ } while ( sal_True );
+}
+
+sal_Bool
+MQueryHelper::hasMore() const
+{
+ return m_bHasMore;
+}
+
+sal_Bool
+MQueryHelper::atEnd() const
+{
+ return m_bAtEnd;
+}
+
+sal_Bool
+MQueryHelper::isError() const
+{
+ return m_bErrorCondition;
+}
+
+sal_Bool
+MQueryHelper::queryComplete() const
+{
+ return m_bQueryComplete;
+}
+
+sal_Bool
+MQueryHelper::waitForQueryComplete( )
+{
+ m_aMutex.acquire();
+
+ OSL_TRACE("In : waitForQueryComplete()");
+ if ( ! m_bQueryComplete ) {
+ do
+ {
+ m_aMutex.release();
+ clearResultOrComplete();
+ if ( !waitForResultOrComplete( ) )
+ return( sal_False );
+ m_aMutex.acquire();
+ }
+ while ( !m_bQueryComplete );
+ }
+
+ m_aMutex.release();
+ OSL_TRACE("Out : waitForQueryComplete()");
+ return( sal_True );
+}
+
+sal_Bool
+MQueryHelper::waitForRow( sal_Int32 rowNum )
+{
+ m_aMutex.acquire();
+ do
+ {
+ m_aMutex.release();
+ clearResultOrComplete();
+ if ( !waitForResultOrComplete() )
+ return( sal_False );
+ m_aMutex.acquire();
+ }
+ while ( !m_bQueryComplete && m_aResults.size() < (size_t)rowNum );
+
+ m_aMutex.release();
+ return( sal_True );
+}
+
+// -------------------------------------------------------------------------
+
+sal_Int32
+MQueryHelper::getResultCount() const
+{
+ OSL_TRACE( "IN MQueryHelper::getResultCount()" );
+ if ( !m_bQueryComplete )
+ {
+ OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = -1\n");
+ return -1;
+ }
+ else
+ {
+ OSL_TRACE( "\tOUT MQueryHelper::getResultCount() = %d\n", m_aResults.size() );
+ return static_cast<sal_Int32>(m_aResults.size());
+ }
+}
+
+// -------------------------------------------------------------------------
+
+sal_uInt32
+MQueryHelper::getRealCount() const
+{
+ OSL_TRACE( "IN/OUT MQueryHelper::getRealCount() = %d\n", m_aResults.size() );
+ return static_cast<sal_Int32>(m_aResults.size());
+}
+
+// -------------------------------------------------------------------------
+NS_IMETHODIMP MQueryHelper::OnQueryItem(nsIAbDirectoryQueryResult *result)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+#if OSL_DEBUG_LEVEL > 0
+ OSL_TRACE( "IN MQueryHelper::OnQueryItem() Caller thread: %4d \n",m_oThreadID );
+#endif
+ nsresult rv;
+ PRInt32 resultType;
+
+ if ( result == NULL ) {
+ OSL_TRACE("\tresult ptr is NULL\n");
+ return NS_OK;
+ }
+
+ // Get return status of executeQuery() call.
+ rv = result -> GetType(&resultType);
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ // Check for errors of the executeQuery() call.
+ switch ( resultType ) {
+ case nsIAbDirectoryQueryResult::queryResultError:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultError\n");
+ m_bQueryComplete = sal_True;
+ m_bErrorCondition = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultStopped:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultStopped\n");
+ m_bQueryComplete = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultComplete:
+ OSL_TRACE("\tresultType == nsIAbDirectoryQueryResult::queryResultComplete\n");
+ m_bQueryComplete = sal_True;
+ notifyResultOrComplete();
+ return NS_OK;
+ case nsIAbDirectoryQueryResult::queryResultMatch:
+ OSL_TRACE("IN MQueryHelper::OnQueryItem --> queryResultMatch\n");
+ // Don't return, continues onto rest of method.
+ break;
+ default:
+ OSL_TRACE("\t******** Unexpected : resultType\n");
+ m_bQueryComplete = sal_True;
+ return NS_OK;
+ }
+
+ // Initialise an array that holds the resultset of the query.
+ nsCOMPtr<nsISupportsArray> properties;
+ rv = result -> GetResult(getter_AddRefs (properties));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+
+ nsCOMPtr<nsISupports> item;
+ rv = properties -> GetElementAt(0, getter_AddRefs(item));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ nsCOMPtr<nsIAbDirectoryQueryPropertyValue> property(do_QueryInterface(item, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ char *name;
+ rv = property -> GetName(&name);
+ NS_ENSURE_SUCCESS(rv, rv);
+ if ( !strcmp(name,"card:nsIAbCard") )
+ {
+ nsCOMPtr<nsISupports> cardSupports;
+ property->GetValueISupports (getter_AddRefs (cardSupports));
+ nsCOMPtr<nsIAbCard> card(do_QueryInterface(cardSupports, &rv));
+ NS_ENSURE_SUCCESS(rv, rv);
+
+ getCardValues(card);
+ }
+ nsMemory::Free(name);
+
+ OSL_TRACE( "\tOUT MQueryHelper::OnQueryItem()\n" );
+
+ notifyResultOrComplete();
+
+ return(NS_OK);
+}
+
+// -----------------------------------------------------------------------------
+void MQueryHelper::notifyQueryError()
+{
+ m_bQueryComplete = sal_True ;
+ notifyResultOrComplete() ;
+}
+
+const char * getAddrURI(const nsIAbDirectory* directory)
+{
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)directory, &retCode) ;
+ if (NS_FAILED(retCode)) { return NULL; }
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ if (NS_FAILED(retCode)) { return NULL; }
+ return uri;
+ }
+
+#define ENSURE_GETUPDATECARD(x) \
+ if (NS_FAILED(retCode)) \
+ { \
+ OSL_TRACE( x ); \
+ return card; \
+ }
+static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
+
+//Some address book does not support query uri on card
+//In this case, we can't resync the cards, we just return the old cards
+nsIAbCard * getUpdatedCard( nsIAbCard* card)
+{
+ OSL_ENSURE(card != NULL, "getUpdatedCard for NULL");
+ nsresult retCode;
+ nsCOMPtr<nsIRDFResource> rdfResource = do_QueryInterface((nsISupports *)card, &retCode) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not support nsIRDFResource\n" );
+
+ const char * uri;
+ retCode=rdfResource->GetValueConst(&uri);
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" );
+
+ nsCOMPtr<nsIRDFService> rdfService (do_GetService(kRDFServiceCID, &retCode)) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Card does not has a uri\n" );
+
+ nsCOMPtr<nsIRDFResource> rdfCard;
+
+ retCode = rdfService->GetResource(nsDependentCString(uri), getter_AddRefs(rdfCard)) ;
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Can not get the updated card\n" );
+
+ nsCOMPtr<nsIAbCard> aNewCard=do_QueryInterface((nsISupports *)rdfCard, &retCode);
+ ENSURE_GETUPDATECARD( "IN getUpdatedCard: Error in get new card\n" );
+
+ return aNewCard;
+ }
+
+#define ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory) \
+ if (getDirectoryType(directory) == SDBCAddress::Mozilla && isProfileLocked(NULL)) \
+ { \
+ m_aError.setResId( STR_MOZILLA_IS_RUNNIG_NO_CHANGES ); \
+ return sal_False; \
+ }
+
+sal_Int32 MQueryHelper::commitCard(const sal_Int32 rowIndex,nsIAbDirectory * directory)
+{
+ ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory);
+
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ return sal_False;
+ }
+ nsresult rv;
+ PRBool hasCard;
+ rv = directory->HasCard(card,&hasCard);
+ if (setCardValues(rowIndex) != sal_True)
+ return sal_False;
+
+ if (!NS_FAILED(rv) && hasCard)
+ {
+ rv = card->EditCardToDatabase(getAddrURI(directory));
+ }
+ else
+ {
+ nsIAbCard *addedCard=NULL;
+ rv = directory->AddCard(card,&addedCard);
+ if (!NS_FAILED(rv))
+ resEntry->setCard(addedCard);
+ }
+ //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process
+ if (rv == NS_ERROR_FILE_ACCESS_DENIED )
+ m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB );
+
+ return !(NS_FAILED(rv));
+}
+
+sal_Int32 MQueryHelper::deleteCard(const sal_Int32 rowIndex,nsIAbDirectory * directory)
+{
+ ENSURE_MOZAB_PROFILE_NOT_LOOKED(directory);
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ return sal_False;
+ }
+ nsresult rv;
+ PRBool hasCard;
+ if (resEntry->getRowStates() == RowStates_Inserted)
+ {
+ rv = 0;
+ hasCard = sal_True;
+ }
+ else
+ rv = directory->HasCard(card,&hasCard);
+
+ if (!NS_FAILED(rv) && hasCard)
+ {
+ nsCOMPtr <nsISupportsArray> cardsToDelete;
+ rv = NS_NewISupportsArray(getter_AddRefs(cardsToDelete));
+ if (NS_SUCCEEDED(rv))
+ {
+ nsCOMPtr<nsISupports> supports = do_QueryInterface(card, &rv);
+ if (NS_SUCCEEDED(rv))
+ {
+ rv = cardsToDelete->AppendElement(supports);
+ if (NS_SUCCEEDED(rv))
+ rv = directory->DeleteCards(cardsToDelete);
+ }
+ }
+ }
+
+ if (NS_SUCCEEDED(rv))
+ resEntry->setRowStates(RowStates_Deleted);
+ //We return NS_ERROR_FILE_ACCESS_DENIED in the case the mozillaAB has been changed out side of our process
+ if (rv == NS_ERROR_FILE_ACCESS_DENIED )
+ m_aError.setResId( STR_FOREIGN_PROCESS_CHANGED_AB );
+ return !(NS_FAILED(rv));
+}
+
+sal_Bool MQueryHelper::setCardValues(const sal_Int32 rowIndex)
+{
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ m_aError.setResId( STR_CANT_FIND_ROW );
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ if (!card)
+ {
+ m_aError.setResId( STR_CANT_FIND_CARD_FOR_ROW );
+ return sal_False;
+ }
+
+ MLdapAttributeMap::fillCardFromResult( *card, *resEntry );
+ return sal_True;
+}
+
+void MQueryHelper::getCardValues(nsIAbCard *card,sal_Int32 rowIndex)
+{
+ MQueryHelperResultEntry *resEntry;
+ if (rowIndex>0)
+ {
+ resEntry = getByIndex(rowIndex);
+ }
+ else
+ resEntry = new MQueryHelperResultEntry();
+
+ MLdapAttributeMap::fillResultFromCard( *resEntry, *card );
+ resEntry->setCard(card);
+ if (!rowIndex)
+ append( resEntry );
+}
+sal_Bool MQueryHelper::resyncRow(sal_Int32 rowIndex)
+{
+
+ MQueryHelperResultEntry *resEntry = getByIndex(rowIndex);
+ if (!resEntry)
+ {
+ m_aError.setResId( STR_CANT_FIND_ROW );
+ return sal_False;
+ }
+ nsIAbCard *card=resEntry->getCard();
+ card = getUpdatedCard(card);
+ getCardValues(card,rowIndex);
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+sal_Int32 MQueryHelper::createNewCard()
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ nsresult rv;
+ nsCOMPtr <nsIAbCard> card = do_CreateInstance(NS_ABCARDPROPERTY_CONTRACTID, &rv);
+ //set default values
+ getCardValues(card);
+ return static_cast<sal_Int32>(m_aResults.size());
+}
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx
new file mode 100644
index 000000000000..233b57a7fe6d
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MQueryHelper.hxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+#define _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+
+#include <MNSInclude.hxx>
+#include "MErrorResource.hxx"
+#include <sal/types.h>
+#include <rtl/ustring.hxx>
+#include <osl/mutex.hxx>
+#include <osl/conditn.hxx>
+#include <comphelper/stl_types.hxx>
+#include <osl/thread.hxx>
+
+#include <hash_map>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MQueryHelperResultEntry
+ {
+ private:
+ typedef ::std::hash_map< ::rtl::OString, ::rtl::OUString, ::rtl::OStringHash > FieldMap;
+
+ mutable ::osl::Mutex m_aMutex;
+ FieldMap m_Fields;
+ nsCOMPtr<nsIAbCard> m_Card;
+ sal_Int32 m_RowStates;
+
+ public:
+ MQueryHelperResultEntry();
+ ~MQueryHelperResultEntry();
+
+ void insert( const rtl::OString &key, rtl::OUString &value );
+ rtl::OUString getValue( const rtl::OString &key ) const;
+ void setValue( const rtl::OString &key, const rtl::OUString & rValue);
+
+ void setCard(nsIAbCard *card);
+ nsIAbCard *getCard();
+ sal_Bool setRowStates(sal_Int32 state){m_RowStates = state; return sal_True;};
+ sal_Int32 getRowStates() { return m_RowStates;};
+ };
+
+ class MQueryHelper : public nsIAbDirectoryQueryResultListener
+ {
+ private:
+ typedef std::vector< MQueryHelperResultEntry* > resultsArray;
+
+ mutable ::osl::Mutex m_aMutex;
+ ::osl::Condition m_aCondition;
+ resultsArray m_aResults;
+ sal_Int32 m_nIndex;
+ sal_Bool m_bHasMore;
+ sal_Bool m_bAtEnd;
+ sal_Bool m_bErrorCondition;
+ sal_Bool m_bQueryComplete;
+ ErrorDescriptor m_aError;
+
+ void append(MQueryHelperResultEntry* resEnt );
+
+ void clear_results();
+
+ void clearResultOrComplete();
+ void notifyResultOrComplete();
+ sal_Bool waitForResultOrComplete( );
+ void getCardValues(nsIAbCard *card,sal_Int32 rowIndex=0);
+#if OSL_DEBUG_LEVEL > 0
+ oslThreadIdentifier m_oThreadID;
+#endif
+
+ public:
+
+ NS_DECL_ISUPPORTS
+ NS_DECL_NSIABDIRECTORYQUERYRESULTLISTENER
+
+ MQueryHelper();
+
+ virtual ~MQueryHelper();
+
+ void reset();
+
+ void rewind();
+
+ MQueryHelperResultEntry* next( );
+
+ MQueryHelperResultEntry* getByIndex( sal_uInt32 nRow );
+
+ const ErrorDescriptor& getError() const { return m_aError; }
+
+ sal_Bool isError() const;
+
+ sal_Bool hasMore() const;
+
+ sal_Bool atEnd() const;
+
+ sal_Bool queryComplete() const;
+
+ sal_Bool waitForQueryComplete( );
+
+ sal_Bool waitForRow( sal_Int32 rowNum );
+
+ sal_Int32 getResultCount() const;
+
+ sal_uInt32 getRealCount() const;
+ sal_Int32 createNewCard(); //return Row count number
+ sal_Bool resyncRow(sal_Int32 rowIndex);
+
+ void notifyQueryError() ;
+ sal_Bool setCardValues(const sal_Int32 rowIndex);
+ sal_Int32 commitCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
+ sal_Int32 deleteCard(const sal_Int32 rowIndex, nsIAbDirectory * directory);
+ };
+ }
+}
+#endif // _CONNECTIVITY_MAB_QUERYHELPER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx
new file mode 100644
index 000000000000..b0c422031475
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.cxx
@@ -0,0 +1,138 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <MNSInclude.hxx>
+#include "MTypeConverter.hxx"
+#include <ucbhelper/content.hxx>
+
+using namespace connectivity::mozab;
+
+// -------------------------------------------------------------------------
+void MTypeConverter::ouStringToNsString(::rtl::OUString const &ous, nsString &nss)
+{
+ // Convert to ::rtl::OString (utf-8 encoding).
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+ PRUint32 csLen = os.getLength();
+
+ NS_ConvertUTF8toUCS2 mozString(cs, csLen);
+ //const PRUnichar* uniMozString = (const PRUnichar*) mozString;
+ nss = mozString; // temp.
+}
+// -------------------------------------------------------------------------
+::rtl::OUString MTypeConverter::nsACStringToOUString( const nsACString& _source )
+{
+ const char* buffer = _source.BeginReading();
+ const char* bufferEnd = _source.EndReading();
+ return ::rtl::OUString( buffer, static_cast<sal_Int32>(bufferEnd - buffer), RTL_TEXTENCODING_ASCII_US );
+}
+// -------------------------------------------------------------------------
+::rtl::OString MTypeConverter::nsACStringToOString( const nsACString& _source )
+{
+ const char* buffer = _source.BeginReading();
+ const char* bufferEnd = _source.EndReading();
+ return ::rtl::OString( buffer, static_cast<sal_Int32>(bufferEnd - buffer) );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::asciiOUStringToNsACString( const ::rtl::OUString& _asciiString, nsACString& _dest )
+{
+ ::rtl::OString sAsciiVersion( _asciiString.getStr(), _asciiString.getLength(), RTL_TEXTENCODING_ASCII_US );
+ asciiToNsACString( sAsciiVersion.getStr(), _dest );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest )
+{
+ _dest.Truncate();
+ _dest.AppendASCII( _asciiString );
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::nsStringToOUString(nsString const &nss, ::rtl::OUString &ous)
+{
+ // Get clone of buffer.
+ PRUnichar *uc = ToNewUnicode(nss);
+ sal_Int32 nssLen = nss.Length();
+
+ // TODO check if this is ok.
+ // PRUnichar != sal_Unicode in mingw
+ ::rtl::OUString _ous(reinterpret_cast_mingw_only<sal_Unicode *>(uc), nssLen);
+ ous = _ous;
+
+ nsMemory::Free(uc);
+}
+// -------------------------------------------------------------------------
+void MTypeConverter::prUnicharToOUString(PRUnichar const *pru, ::rtl::OUString &ous)
+{
+ // TODO, specify length.
+ // PRUnichar != sal_Unicode in mingw
+ ::rtl::OUString _ous(reinterpret_cast_mingw_only<const sal_Unicode *>(pru));
+ ous = _ous;
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringUtf8(::rtl::OUString const &ous)
+{
+ // Convert to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_UTF8);
+
+ const char *cs = os.getStr();
+
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::ouStringToCCharStringAscii(::rtl::OUString const &ous)
+{
+ // Convert ::rtl::OUString to ::rtl::OString,
+ ::rtl::OString os(ous,ous.getLength(), RTL_TEXTENCODING_ASCII_US);
+
+ return(strdup(os.getStr()));
+}
+// -------------------------------------------------------------------------
+char *MTypeConverter::nsStringToCCharStringAscii(nsString const &nss)
+{
+ char cs[1024];
+ nss.ToCString(cs, 1024);
+
+ return(strdup(cs));
+}
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::ouStringToStlString(::rtl::OUString const &ous)
+{
+ // Convert ::rtl::OUString to ::rtl::OString.
+ ::rtl::OString os(ous,ous.getLength(),RTL_TEXTENCODING_ASCII_US);
+ return( ::std::string(os.getStr()));
+}
+#if 0
+// -------------------------------------------------------------------------
+::std::string MTypeConverter::nsStringToStlString(nsString const &nss)
+{
+ return( ::std::string(nss.GetBuffer()));
+}
+#endif
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx
new file mode 100644
index 000000000000..266bf2aad486
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/MTypeConverter.hxx
@@ -0,0 +1,66 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#ifndef _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+#define _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+
+#include <rtl/ustring.hxx>
+
+#include<string>
+
+namespace connectivity
+{
+ namespace mozab
+ {
+ class MTypeConverter
+ {
+ public:
+ static void ouStringToNsString(const ::rtl::OUString&, nsString&);
+ static void nsStringToOUString(const nsString&, ::rtl::OUString&);
+ static void prUnicharToOUString(const PRUnichar*, ::rtl::OUString&);
+ // Use free() for the following 3 calls.
+ static char *ouStringToCCharStringAscii(const ::rtl::OUString&);
+ static char *nsStringToCCharStringAscii(const nsString&);
+ static char *ouStringToCCharStringUtf8(const ::rtl::OUString&);
+ // Convert to stl-string.
+ static ::std::string ouStringToStlString(const ::rtl::OUString&);
+ static ::std::string nsStringToStlString(const nsString&);
+
+ static ::rtl::OUString nsACStringToOUString( const nsACString& _source );
+ static ::rtl::OString nsACStringToOString( const nsACString& _source );
+ static void asciiOUStringToNsACString( const ::rtl::OUString& _asciiString, nsACString& _dest );
+ static void asciiToNsACString( const sal_Char* _asciiString, nsACString& _dest );
+
+ private:
+ MTypeConverter() {};
+ };
+ }
+}
+
+#endif // _CONNECTIVITY_MAB_TYPECONVERTER_HXX_
+
diff --git a/connectivity/source/drivers/mozab/mozillasrc/makefile.mk b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk
new file mode 100644
index 000000000000..4c3e5380f451
--- /dev/null
+++ b/connectivity/source/drivers/mozab/mozillasrc/makefile.mk
@@ -0,0 +1,77 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+CALL_CDECL=TRUE
+
+#mozilla specific stuff.
+MOZ_LIB=$(SOLARVERSION)$/$(INPATH)$/lib$(UPDMINOREXT)
+MOZ_INC=$(SOLARVERSION)$/$(INPATH)$/inc$(UPDMINOREXT)$/mozilla
+#End of mozilla specific stuff.
+
+PRJ=..$/..$/..$/..
+PRJINC=..$/..$/..
+PRJNAME=connectivity
+TARGET=mozabsrc
+
+# --- Settings ----------------------------------
+
+USE_DEFFILE=TRUE
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+.INCLUDE : settings.mk
+
+.IF ("$(SYSTEM_MOZILLA)" == "YES" && "$(WITH_MOZILLA)" == "YES") || "$(WITH_MOZILLA)" == "NO" || "$(OS)" == "OS2"
+dummy:
+ @echo " Not building the mozillasrc stuff in OpenOffice.org build"
+ @echo " dependency to Mozilla developer snapshots not feasable at the moment"
+ @echo " see http://bugzilla.mozilla.org/show_bug.cgi?id=135137"
+.ELSE
+
+.INCLUDE : $(PRJ)$/version.mk
+
+.INCLUDE : ../makefile_mozab.mk
+
+INCPRE += -I../bootstrap
+
+# --- Files -------------------------------------
+
+SLOFILES = \
+ $(SLO)$/MQueryHelper.obj \
+ $(SLO)$/MDatabaseMetaDataHelper.obj \
+ $(SLO)$/MQuery.obj \
+ $(SLO)$/MTypeConverter.obj \
+ $(SLO)$/MNameMapper.obj \
+ $(SLO)$/MNSMozabProxy.obj \
+ $(SLO)$/MNSTerminateListener.obj \
+ $(SLO)$/MLdapAttributeMap.obj \
+
+.ENDIF
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/connectivity/source/drivers/mozab/post_include_mozilla.h b/connectivity/source/drivers/mozab/post_include_mozilla.h
new file mode 100644
index 000000000000..a257d54f305a
--- /dev/null
+++ b/connectivity/source/drivers/mozab/post_include_mozilla.h
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if defined __SUNPRO_CC
+#pragma enable_warn
+#elif defined _MSC_VER
+#pragma warning(pop)
+#endif
+
+#ifdef MOZ_BOOL
+# undef BOOL
+# undef Bool
+#endif
+
+#ifdef DEBUG_WAS_DEFINED
+ #define DEBUG DEBUG_WAS_DEFINED
+#endif
+
+#ifdef _DEBUG_WAS_DEFINED
+ #define _DEBUG _DEBUG_WAS_DEFINED
+#endif
+
+#ifndef _CONNECTIVITY_MOZILLA_REINTERPRET_CAST_MINGW_ONLY_
+#define _CONNECTIVITY_MOZILLA_REINTERPRET_CAST_MINGW_ONLY_
+
+#ifdef __cplusplus
+#ifdef __MINGW32__
+template<class T1, class T2> T1 inline reinterpret_cast_mingw_only(T2 p) { return reinterpret_cast<T1>(p); }
+#else
+template<class T1, class T2> T1 inline reinterpret_cast_mingw_only(T2 p) { return p; }
+#endif
+#endif
+
+#endif
diff --git a/connectivity/source/drivers/mozab/pre_include_mozilla.h b/connectivity/source/drivers/mozab/pre_include_mozilla.h
new file mode 100644
index 000000000000..762d51160db9
--- /dev/null
+++ b/connectivity/source/drivers/mozab/pre_include_mozilla.h
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef BOOL
+# define MOZ_BOOL
+
+# define BOOL mozBOOL
+# define Bool mozBooL
+#endif
+
+// Turn off DEBUG Assertions
+#ifdef _DEBUG
+ #define _DEBUG_WAS_DEFINED _DEBUG
+ #ifndef MOZILLA_ENABLE_DEBUG
+ #undef _DEBUG
+ #endif
+#else
+ #undef _DEBUG_WAS_DEFINED
+ #ifdef MOZILLA_ENABLE_DEBUG
+ #define _DEBUG 1
+ #endif
+#endif
+
+// and turn off the additional virtual methods which are part of some interfaces when compiled
+// with debug
+#ifdef DEBUG
+ #define DEBUG_WAS_DEFINED DEBUG
+ #ifndef MOZILLA_ENABLE_DEBUG
+ #undef DEBUG
+ #endif
+#else
+ #undef DEBUG_WAS_DEFINED
+ #ifdef MOZILLA_ENABLE_DEBUG
+ #define DEBUG 1
+ #endif
+#endif
+
+#if defined __GNUC__
+ #pragma GCC system_header
+#elif defined __SUNPRO_CC
+ #pragma disable_warn
+#elif defined _MSC_VER
+ #pragma warning(push, 1)
+ #pragma warning(disable:4946 4710)
+#endif
+
diff --git a/connectivity/source/drivers/mysql/YCatalog.cxx b/connectivity/source/drivers/mysql/YCatalog.cxx
new file mode 100644
index 000000000000..eab600fc33dc
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YCatalog.cxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YCatalog.hxx"
+#include "mysql/YUsers.hxx"
+#include "mysql/YTables.hxx"
+#include "mysql/YViews.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <comphelper/types.hxx>
+
+
+// -------------------------------------------------------------------------
+using namespace connectivity;
+using namespace connectivity::mysql;
+using namespace connectivity::sdbcx;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OMySQLCatalog::OMySQLCatalog(const Reference< XConnection >& _xConnection) : OCatalog(_xConnection)
+ ,m_xConnection(_xConnection)
+{
+}
+// -----------------------------------------------------------------------------
+void OMySQLCatalog::refreshObjects(const Sequence< ::rtl::OUString >& _sKindOfObject,TStringVector& _rNames)
+{
+ Reference< XResultSet > xResult = m_xMetaData->getTables(Any(),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")),
+ _sKindOfObject);
+ fillNames(xResult,_rNames);
+}
+// -------------------------------------------------------------------------
+void OMySQLCatalog::refreshTables()
+{
+ TStringVector aVector;
+ static const ::rtl::OUString s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ static const ::rtl::OUString s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+ static const ::rtl::OUString s_sAll(RTL_CONSTASCII_USTRINGPARAM("%"));
+
+ Sequence< ::rtl::OUString > sTableTypes(3);
+ sTableTypes[0] = s_sTableTypeView;
+ sTableTypes[1] = s_sTableTypeTable;
+ sTableTypes[2] = s_sAll; // just to be sure to include anything else ....
+
+ refreshObjects(sTableTypes,aVector);
+
+ if ( m_pTables )
+ m_pTables->reFill(aVector);
+ else
+ m_pTables = new OTables(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OMySQLCatalog::refreshViews()
+{
+ Sequence< ::rtl::OUString > aTypes(1);
+ aTypes[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+
+/*
+ sal_Bool bSupportsViews = sal_False;
+ try
+ {
+ Reference<XResultSet> xRes = m_xMetaData->getTableTypes();
+ Reference<XRow> xRow(xRes,UNO_QUERY);
+ while ( !bSupportsViews && xRow.is() && xRes->next() )
+ {
+ ::rtl::OUString sTableType( xRow->getString( 1 ) );
+ bSupportsViews = sTableType.equalsIgnoreAsciiCase( aTypes[0] );
+ }
+ }
+ catch(const SQLException&)
+ {
+ }
+*/
+ // let's simply assume the server is new enough to support views. Current drivers
+ // as of this writing might not return the proper information in getTableTypes, so
+ // don't rely on it.
+ // during #73245# / 2007-10-26 / frank.schoenheit@sun.com
+ bool bSupportsViews = sal_True;
+
+ TStringVector aVector;
+ if ( bSupportsViews )
+ refreshObjects(aTypes,aVector);
+
+ if ( m_pViews )
+ m_pViews->reFill(aVector);
+ else
+ m_pViews = new OViews(m_xMetaData,*this,m_aMutex,aVector);
+}
+// -------------------------------------------------------------------------
+void OMySQLCatalog::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+void OMySQLCatalog::refreshUsers()
+{
+ TStringVector aVector;
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ Reference< XResultSet > xResult = xStmt->executeQuery(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("select User from mysql.user group by User")));
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ TString2IntMap aMap;
+ while( xResult->next() )
+ aVector.push_back(xRow->getString(1));
+ ::comphelper::disposeComponent(xResult);
+ }
+ ::comphelper::disposeComponent(xStmt);
+
+ if(m_pUsers)
+ m_pUsers->reFill(aVector);
+ else
+ m_pUsers = new OUsers(*this,m_aMutex,aVector,m_xConnection,this);
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OMySQLCatalog::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if ( rType == ::getCppuType((const Reference<XGroupsSupplier>*)0) )
+ return Any();
+
+
+ return OCatalog::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OMySQLCatalog::getTypes( ) throw(RuntimeException)
+{
+ Sequence< Type > aTypes = OCatalog::getTypes();
+ ::std::vector<Type> aOwnTypes;
+ aOwnTypes.reserve(aTypes.getLength());
+ const Type* pBegin = aTypes.getConstArray();
+ const Type* pEnd = pBegin + aTypes.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if ( !(*pBegin == ::getCppuType((const Reference<XGroupsSupplier>*)0)))
+ {
+ aOwnTypes.push_back(*pBegin);
+ }
+ }
+ const Type* pTypes = aOwnTypes.empty() ? 0 : &aOwnTypes[0];
+ return Sequence< Type >(pTypes, aOwnTypes.size());
+}
+// -----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/mysql/YColumns.cxx b/connectivity/source/drivers/mysql/YColumns.cxx
new file mode 100644
index 000000000000..abfcfacc7cf2
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YColumns.cxx
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YColumns.hxx"
+#include "TConnection.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::mysql;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+
+OMySQLColumns::OMySQLColumns( ::cppu::OWeakObject& _rParent
+ ,sal_Bool _bCase
+ ,::osl::Mutex& _rMutex
+ ,const TStringVector &_rVector
+ ,sal_Bool _bUseHardRef
+ ) : OColumnsHelper(_rParent,_bCase,_rMutex,_rVector,_bUseHardRef)
+{
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySet > OMySQLColumns::createDescriptor()
+{
+ return new OMySQLColumn(sal_True);
+}
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+OMySQLColumn::OMySQLColumn( sal_Bool _bCase)
+ : connectivity::sdbcx::OColumn( _bCase )
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OMySQLColumn::construct()
+{
+ m_sAutoIncrement = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("auto_increment"));
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_AUTOINCREMENTCREATION),PROPERTY_ID_AUTOINCREMENTCREATION,0,&m_sAutoIncrement, ::getCppuType(&m_sAutoIncrement));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OMySQLColumn::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & SAL_CALL OMySQLColumn::getInfoHelper()
+{
+ return *OMySQLColumn_PROP::getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+Sequence< ::rtl::OUString > SAL_CALL OMySQLColumn::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(1);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Column");
+
+ return aSupported;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mysql/YDriver.cxx b/connectivity/source/drivers/mysql/YDriver.cxx
new file mode 100644
index 000000000000..024066207622
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YDriver.cxx
@@ -0,0 +1,481 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YDriver.hxx"
+#include "mysql/YCatalog.hxx"
+#include <osl/diagnose.h>
+#include <comphelper/namedvaluecollection.hxx>
+#include "connectivity/dbexception.hxx"
+#include <connectivity/dbcharset.hxx>
+#include <com/sun/star/sdbc/XDriverAccess.hpp>
+#include "TConnection.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+//........................................................................
+namespace connectivity
+{
+//........................................................................
+ using namespace mysql;
+ using namespace ::com::sun::star::uno;
+ using namespace ::com::sun::star::sdbc;
+ using namespace ::com::sun::star::sdbcx;
+ using namespace ::com::sun::star::beans;
+ using namespace ::com::sun::star::lang;
+
+ namespace mysql
+ {
+ Reference< XInterface > SAL_CALL ODriverDelegator_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFac) throw( Exception )
+ {
+ return *(new ODriverDelegator(_rxFac));
+ }
+ }
+
+
+ //====================================================================
+ //= ODriverDelegator
+ //====================================================================
+ //--------------------------------------------------------------------
+ ODriverDelegator::ODriverDelegator(const Reference< XMultiServiceFactory >& _rxFactory)
+ : ODriverDelegator_BASE(m_aMutex)
+ ,m_xFactory(_rxFactory)
+ ,m_eDriverType(D_ODBC)
+ {
+ }
+
+ //--------------------------------------------------------------------
+ ODriverDelegator::~ODriverDelegator()
+ {
+ try
+ {
+ ::comphelper::disposeComponent(m_xODBCDriver);
+ ::comphelper::disposeComponent(m_xNativeDriver);
+ TJDBCDrivers::iterator aIter = m_aJdbcDrivers.begin();
+ TJDBCDrivers::iterator aEnd = m_aJdbcDrivers.end();
+ for ( ;aIter != aEnd;++aIter )
+ ::comphelper::disposeComponent(aIter->second);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+
+ // --------------------------------------------------------------------------------
+ void ODriverDelegator::disposing()
+ {
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); m_aConnections.end() != i; ++i)
+ {
+ Reference<XInterface > xTemp = i->first.get();
+ ::comphelper::disposeComponent(xTemp);
+ }
+ m_aConnections.clear();
+ TWeakPairVector().swap(m_aConnections);
+
+ ODriverDelegator_BASE::disposing();
+ }
+
+ namespace
+ {
+ sal_Bool isOdbcUrl(const ::rtl::OUString& _sUrl)
+ {
+ return _sUrl.copy(0,16).equalsAscii("sdbc:mysql:odbc:");
+ }
+ //--------------------------------------------------------------------
+ sal_Bool isNativeUrl(const ::rtl::OUString& _sUrl)
+ {
+ return (!_sUrl.compareTo(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:mysql:mysqlc:")), sizeof("sdbc:mysql:mysqlc:")-1));
+ }
+ //--------------------------------------------------------------------
+ T_DRIVERTYPE lcl_getDriverType(const ::rtl::OUString& _sUrl)
+ {
+ T_DRIVERTYPE eRet = D_JDBC;
+ if ( isOdbcUrl(_sUrl ) )
+ eRet = D_ODBC;
+ else if ( isNativeUrl(_sUrl ) )
+ eRet = D_NATIVE;
+ return eRet;
+ }
+ //--------------------------------------------------------------------
+ ::rtl::OUString transformUrl(const ::rtl::OUString& _sUrl)
+ {
+ ::rtl::OUString sNewUrl = _sUrl.copy(11);
+ if ( isOdbcUrl( _sUrl ) )
+ sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:")) + sNewUrl;
+ else if ( isNativeUrl( _sUrl ) )
+ sNewUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("sdbc:")) + sNewUrl;
+ else
+ {
+ sNewUrl = sNewUrl.copy(5);
+
+ ::rtl::OUString sTempUrl = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("jdbc:mysql://"));
+
+ sTempUrl += sNewUrl;
+ sNewUrl = sTempUrl;
+ }
+ return sNewUrl;
+ }
+ //--------------------------------------------------------------------
+ Reference< XDriver > lcl_loadDriver(const Reference< XMultiServiceFactory >& _rxFactory,const ::rtl::OUString& _sUrl)
+ {
+ Reference<XDriverAccess> xDriverAccess(_rxFactory->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdbc.DriverManager")) ),UNO_QUERY);
+ OSL_ENSURE(xDriverAccess.is(),"Could not load driver manager!");
+ Reference< XDriver > xDriver;
+ if ( xDriverAccess.is() )
+ xDriver = xDriverAccess->getDriverByURL(_sUrl);
+ return xDriver;
+ }
+ //--------------------------------------------------------------------
+ Sequence< PropertyValue > lcl_convertProperties(T_DRIVERTYPE _eType,const Sequence< PropertyValue >& info,const ::rtl::OUString& _sUrl)
+ {
+ ::std::vector<PropertyValue> aProps;
+ const PropertyValue* pSupported = info.getConstArray();
+ const PropertyValue* pEnd = pSupported + info.getLength();
+
+ aProps.reserve(info.getLength() + 5);
+ for (;pSupported != pEnd; ++pSupported)
+ {
+ aProps.push_back( *pSupported );
+ }
+
+ if ( _eType == D_ODBC )
+ {
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Silent"))
+ ,0
+ ,makeAny(sal_True)
+ ,PropertyState_DIRECT_VALUE) );
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PreventGetVersionColumns"))
+ ,0
+ ,makeAny(sal_True)
+ ,PropertyState_DIRECT_VALUE) );
+ }
+ else if ( _eType == D_JDBC )
+ {
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))
+ ,0
+ ,makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver")))
+ ,PropertyState_DIRECT_VALUE) );
+ }
+ else
+ {
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PublicConnectionURL"))
+ ,0
+ ,makeAny(_sUrl)
+ ,PropertyState_DIRECT_VALUE) );
+ }
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled"))
+ ,0
+ ,makeAny(sal_True)
+ ,PropertyState_DIRECT_VALUE) );
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoRetrievingStatement"))
+ ,0
+ ,makeAny(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SELECT LAST_INSERT_ID()")))
+ ,PropertyState_DIRECT_VALUE) );
+ aProps.push_back( PropertyValue(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParameterNameSubstitution"))
+ ,0
+ ,makeAny(sal_True)
+ ,PropertyState_DIRECT_VALUE) );
+ PropertyValue* pProps = aProps.empty() ? 0 : &aProps[0];
+ return Sequence< PropertyValue >(pProps, aProps.size());
+ }
+ }
+ //--------------------------------------------------------------------
+ Reference< XDriver > ODriverDelegator::loadDriver( const ::rtl::OUString& url, const Sequence< PropertyValue >& info )
+ {
+ Reference< XDriver > xDriver;
+ const ::rtl::OUString sCuttedUrl = transformUrl(url);
+ const T_DRIVERTYPE eType = lcl_getDriverType( url );
+ if ( eType == D_ODBC )
+ {
+ if ( !m_xODBCDriver.is() )
+ m_xODBCDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ xDriver = m_xODBCDriver;
+ } // if ( bIsODBC )
+ else if ( eType == D_NATIVE )
+ {
+ if ( !m_xNativeDriver.is() )
+ m_xNativeDriver = lcl_loadDriver(m_xFactory,sCuttedUrl);
+ xDriver = m_xNativeDriver;
+ }
+ else
+ {
+ ::comphelper::NamedValueCollection aSettings( info );
+ ::rtl::OUString sDriverClass(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver"));
+ sDriverClass = aSettings.getOrDefault( "JavaDriverClass", sDriverClass );
+
+ TJDBCDrivers::iterator aFind = m_aJdbcDrivers.find(sDriverClass);
+ if ( aFind == m_aJdbcDrivers.end() )
+ aFind = m_aJdbcDrivers.insert(TJDBCDrivers::value_type(sDriverClass,lcl_loadDriver(m_xFactory,sCuttedUrl))).first;
+ xDriver = aFind->second;
+ }
+
+ return xDriver;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XConnection > SAL_CALL ODriverDelegator::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ Reference< XConnection > xConnection;
+ if ( acceptsURL(url) )
+ {
+ Reference< XDriver > xDriver;
+ xDriver = loadDriver(url,info);
+ if ( xDriver.is() )
+ {
+ ::rtl::OUString sCuttedUrl = transformUrl(url);
+ const T_DRIVERTYPE eType = lcl_getDriverType( url );
+ Sequence< PropertyValue > aConvertedProperties = lcl_convertProperties(eType,info,url);
+ if ( eType == D_JDBC )
+ {
+ ::comphelper::NamedValueCollection aSettings( info );
+ ::rtl::OUString sIanaName = aSettings.getOrDefault( "CharSet", ::rtl::OUString() );
+ if ( sIanaName.getLength() )
+ {
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end() )
+ {
+ ::rtl::OUString sAdd;
+ if ( RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding() )
+ {
+ static const ::rtl::OUString s_sCharSetOp(RTL_CONSTASCII_USTRINGPARAM("useUnicode=true&"));
+ if ( !sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp) )
+ {
+ sAdd = s_sCharSetOp;
+ } // if ( !sCuttedUrl.matchIgnoreAsciiCase(s_sCharSetOp) )
+ } // if ( RTL_TEXTENCODING_UTF8 == (*aLookup).getEncoding() )
+ if ( sCuttedUrl.indexOf('?') == -1 )
+ sCuttedUrl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("?"));
+ else
+ sCuttedUrl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("&"));
+ sCuttedUrl += sAdd;
+ sCuttedUrl += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("characterEncoding="));
+ sCuttedUrl += sIanaName;
+ }
+ }
+ } // if ( !bIsODBC )
+
+ xConnection = xDriver->connect( sCuttedUrl, aConvertedProperties );
+ if ( xConnection.is() )
+ {
+ OMetaConnection* pMetaConnection = NULL;
+ // now we have to set the URL to get the correct answer for metadata()->getURL()
+ Reference< XUnoTunnel> xTunnel(xConnection,UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+ pMetaConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
+ if ( pMetaConnection )
+ pMetaConnection->setURL(url);
+ }
+ m_aConnections.push_back(TWeakPair(WeakReferenceHelper(xConnection),TWeakConnectionPair(WeakReferenceHelper(),pMetaConnection)));
+ }
+ }
+ }
+ return xConnection;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Bool SAL_CALL ODriverDelegator::acceptsURL( const ::rtl::OUString& url ) throw (SQLException, RuntimeException)
+ {
+ Sequence< PropertyValue > info;
+
+ sal_Bool bOK = url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:odbc:" ) )
+ || url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:jdbc:" ) )
+ || ( url.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( "sdbc:mysql:mysqlc:" ) )
+ && loadDriver( url, info ).is()
+ );
+ return bOK;
+ }
+
+ //--------------------------------------------------------------------
+ Sequence< DriverPropertyInfo > SAL_CALL ODriverDelegator::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw (SQLException, RuntimeException)
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+ if ( !acceptsURL(url) )
+ return Sequence< DriverPropertyInfo >();
+
+ Sequence< ::rtl::OUString > aBoolean(2);
+ aBoolean[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"));
+ aBoolean[1] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("1"));
+
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SuppressVersionColumns"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Display version columns (when available)."))
+ ,sal_False
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0"))
+ ,aBoolean)
+ );
+ const T_DRIVERTYPE eType = lcl_getDriverType( url );
+ if ( eType == D_JDBC )
+ {
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("JavaDriverClass"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("The JDBC driver class name."))
+ ,sal_True
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.mysql.jdbc.Driver"))
+ ,Sequence< ::rtl::OUString >())
+ );
+ }
+
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverDelegator::getMajorVersion( ) throw (RuntimeException)
+ {
+ return 1;
+ }
+
+ //--------------------------------------------------------------------
+ sal_Int32 SAL_CALL ODriverDelegator::getMinorVersion( ) throw (RuntimeException)
+ {
+ return 0;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByConnection( const Reference< XConnection >& connection ) throw (SQLException, RuntimeException)
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(ODriverDelegator_BASE::rBHelper.bDisposed);
+
+ Reference< XTablesSupplier > xTab;
+ Reference< XUnoTunnel> xTunnel(connection,UNO_QUERY);
+ if ( xTunnel.is() )
+ {
+ OMetaConnection* pConnection = reinterpret_cast<OMetaConnection*>(xTunnel->getSomething( OMetaConnection::getUnoTunnelImplementationId() ));
+ if ( pConnection )
+ {
+ TWeakPairVector::iterator aEnd = m_aConnections.end();
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ if ( i->second.second == pConnection )
+ {
+ xTab = Reference< XTablesSupplier >(i->second.first.get().get(),UNO_QUERY);
+ if ( !xTab.is() )
+ {
+ xTab = new OMySQLCatalog(connection);
+ i->second.first = WeakReferenceHelper(xTab);
+ }
+ break;
+ }
+ }
+ }
+ } // if ( xTunnel.is() )
+ if ( !xTab.is() )
+ {
+ TWeakPairVector::iterator aEnd = m_aConnections.end();
+ for (TWeakPairVector::iterator i = m_aConnections.begin(); aEnd != i; ++i)
+ {
+ Reference< XConnection > xTemp(i->first.get(),UNO_QUERY);
+ if ( xTemp == connection )
+ {
+ xTab = Reference< XTablesSupplier >(i->second.first.get().get(),UNO_QUERY);
+ if ( !xTab.is() )
+ {
+ xTab = new OMySQLCatalog(connection);
+ i->second.first = WeakReferenceHelper(xTab);
+ }
+ break;
+ }
+ }
+ }
+ return xTab;
+ }
+
+ //--------------------------------------------------------------------
+ Reference< XTablesSupplier > SAL_CALL ODriverDelegator::getDataDefinitionByURL( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw (SQLException, RuntimeException)
+ {
+ if ( ! acceptsURL(url) )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ } // if ( ! acceptsURL(url) )
+
+ return getDataDefinitionByConnection(connect(url,info));
+ }
+
+ // XServiceInfo
+ // --------------------------------------------------------------------------------
+ //------------------------------------------------------------------------------
+ rtl::OUString ODriverDelegator::getImplementationName_Static( ) throw(RuntimeException)
+ {
+ return rtl::OUString::createFromAscii("org.openoffice.comp.drivers.MySQL.Driver");
+ }
+ //------------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > ODriverDelegator::getSupportedServiceNames_Static( ) throw (RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSNS( 2 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ aSNS[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.Driver");
+ return aSNS;
+ }
+ //------------------------------------------------------------------
+ ::rtl::OUString SAL_CALL ODriverDelegator::getImplementationName( ) throw(RuntimeException)
+ {
+ return getImplementationName_Static();
+ }
+
+ //------------------------------------------------------------------
+ sal_Bool SAL_CALL ODriverDelegator::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+ {
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+ }
+ //------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL ODriverDelegator::getSupportedServiceNames( ) throw(RuntimeException)
+ {
+ return getSupportedServiceNames_Static();
+ }
+ //------------------------------------------------------------------
+//........................................................................
+} // namespace connectivity
+//........................................................................
diff --git a/connectivity/source/drivers/mysql/YTable.cxx b/connectivity/source/drivers/mysql/YTable.cxx
new file mode 100644
index 000000000000..06be64f83313
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YTable.cxx
@@ -0,0 +1,385 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YTable.hxx"
+#include "mysql/YTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/sdbcx/VColumn.hxx"
+#include "connectivity/TKeys.hxx"
+#include "connectivity/TIndexes.hxx"
+#include "connectivity/TColumnsHelper.hxx"
+#include "mysql/YCatalog.hxx"
+#include "mysql/YColumns.hxx"
+#include "TConnection.hxx"
+
+
+using namespace ::comphelper;
+using namespace connectivity::mysql;
+using namespace connectivity::sdbcx;
+using namespace connectivity;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+namespace connectivity
+{
+ namespace mysql
+ {
+ class OMySQLKeysHelper : public OKeysHelper
+ {
+ protected:
+ // -----------------------------------------------------------------------------
+ virtual ::rtl::OUString getDropForeignKey() const
+ {
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP FOREIGN KEY "));
+ }
+ public:
+ OMySQLKeysHelper( OTableHelper* _pTable,
+ ::osl::Mutex& _rMutex,
+ const TStringVector& _rVector
+ ) : OKeysHelper(_pTable,_rMutex,_rVector){}
+
+ };
+ }
+}
+
+OMySQLTable::OMySQLTable( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection)
+ :OTableHelper(_pTables,_xConnection,sal_True)
+{
+ // we create a new table here, so we should have all the rights or ;-)
+ m_nPrivileges = Privilege::DROP |
+ Privilege::REFERENCE |
+ Privilege::ALTER |
+ Privilege::CREATE |
+ Privilege::READ |
+ Privilege::DELETE |
+ Privilege::UPDATE |
+ Privilege::INSERT |
+ Privilege::SELECT;
+ construct();
+}
+// -------------------------------------------------------------------------
+OMySQLTable::OMySQLTable( sdbcx::OCollection* _pTables,
+ const Reference< XConnection >& _xConnection,
+ const ::rtl::OUString& _Name,
+ const ::rtl::OUString& _Type,
+ const ::rtl::OUString& _Description ,
+ const ::rtl::OUString& _SchemaName,
+ const ::rtl::OUString& _CatalogName,
+ sal_Int32 _nPrivileges
+ ) : OTableHelper( _pTables,
+ _xConnection,
+ sal_True,
+ _Name,
+ _Type,
+ _Description,
+ _SchemaName,
+ _CatalogName)
+ , m_nPrivileges(_nPrivileges)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OMySQLTable::construct()
+{
+ OTableHelper::construct();
+ if ( !isNew() )
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PRIVILEGES), PROPERTY_ID_PRIVILEGES,PropertyAttribute::READONLY,&m_nPrivileges, ::getCppuType(&m_nPrivileges));
+}
+// -----------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OMySQLTable::createArrayHelper( sal_Int32 /*_nId*/ ) const
+{
+ return doCreateArrayHelper();
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OMySQLTable::getInfoHelper()
+{
+ return *static_cast<OMySQLTable_PROP*>(const_cast<OMySQLTable*>(this))->getArrayHelper(isNew() ? 1 : 0);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OMySQLTable::createColumns(const TStringVector& _rNames)
+{
+ OMySQLColumns* pColumns = new OMySQLColumns(*this,sal_True,m_aMutex,_rNames);
+ pColumns->setParent(this);
+ return pColumns;
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OMySQLTable::createKeys(const TStringVector& _rNames)
+{
+ return new OMySQLKeysHelper(this,m_aMutex,_rNames);
+}
+// -----------------------------------------------------------------------------
+sdbcx::OCollection* OMySQLTable::createIndexes(const TStringVector& _rNames)
+{
+ return new OIndexesHelper(this,m_aMutex,_rNames);
+}
+//--------------------------------------------------------------------------
+Sequence< sal_Int8 > OMySQLTable::getUnoTunnelImplementationId()
+{
+ static ::cppu::OImplementationId * pId = 0;
+ if (! pId)
+ {
+ ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
+ if (! pId)
+ {
+ static ::cppu::OImplementationId aId;
+ pId = &aId;
+ }
+ }
+ return pId->getImplementationId();
+}
+
+// com::sun::star::lang::XUnoTunnel
+//------------------------------------------------------------------
+sal_Int64 OMySQLTable::getSomething( const Sequence< sal_Int8 > & rId ) throw (RuntimeException)
+{
+ return (rId.getLength() == 16 && 0 == rtl_compareMemory(getUnoTunnelImplementationId().getConstArray(), rId.getConstArray(), 16 ) )
+ ? reinterpret_cast< sal_Int64 >( this )
+ : OTable_TYPEDEF::getSomething(rId);
+}
+// -------------------------------------------------------------------------
+// XAlterTable
+void SAL_CALL OMySQLTable::alterColumnByName( const ::rtl::OUString& colName, const Reference< XPropertySet >& descriptor ) throw(SQLException, NoSuchElementException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(
+#ifdef GCC
+ ::connectivity::sdbcx::OTableDescriptor_BASE::rBHelper.bDisposed
+#else
+ rBHelper.bDisposed
+#endif
+ );
+
+ if ( m_pColumns && !m_pColumns->hasByName(colName) )
+ throw NoSuchElementException(colName,*this);
+
+
+ if ( !isNew() )
+ {
+ // first we have to check what should be altered
+ Reference<XPropertySet> xProp;
+ m_pColumns->getByName(colName) >>= xProp;
+ // first check the types
+ sal_Int32 nOldType = 0,nNewType = 0,nOldPrec = 0,nNewPrec = 0,nOldScale = 0,nNewScale = 0;
+
+ ::dbtools::OPropertyMap& rProp = OMetaConnection::getPropMap();
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nOldType;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPE)) >>= nNewType;
+ // and precsions and scale
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION)) >>= nOldPrec;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_PRECISION))>>= nNewPrec;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nOldScale;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_SCALE)) >>= nNewScale;
+ // second: check the "is nullable" value
+ sal_Int32 nOldNullable = 0,nNewNullable = 0;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nOldNullable;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISNULLABLE)) >>= nNewNullable;
+
+ // check also the auto_increment
+ sal_Bool bOldAutoIncrement = sal_False,bAutoIncrement = sal_False;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bOldAutoIncrement;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_ISAUTOINCREMENT)) >>= bAutoIncrement;
+ bool bColumnNameChanged = false;
+ ::rtl::OUString sOldDesc,sNewDesc;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sOldDesc;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sNewDesc;
+
+ if ( nOldType != nNewType
+ || nOldPrec != nNewPrec
+ || nOldScale != nNewScale
+ || nNewNullable != nOldNullable
+ || bOldAutoIncrement != bAutoIncrement
+ || sOldDesc != sNewDesc )
+ {
+ // special handling because they change dthe type names to distinguish
+ // if a column should be an auto_incmrement one
+ if ( bOldAutoIncrement != bAutoIncrement )
+ {
+ ::rtl::OUString sTypeName;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME)) >>= sTypeName;
+
+ static ::rtl::OUString s_sAutoIncrement(RTL_CONSTASCII_USTRINGPARAM("auto_increment"));
+ if ( bAutoIncrement )
+ {
+ if ( sTypeName.indexOf(s_sAutoIncrement) == -1 )
+ {
+ sTypeName += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sTypeName += s_sAutoIncrement;
+ }
+ }
+ else
+ {
+ sal_Int32 nIndex = 0;
+ if ( sTypeName.getLength() && (nIndex = sTypeName.indexOf(s_sAutoIncrement)) != -1 )
+ {
+ sTypeName = sTypeName.copy(0,nIndex);
+ descriptor->setPropertyValue(rProp.getNameByIndex(PROPERTY_ID_TYPENAME),makeAny(sTypeName));
+ }
+ }
+ }
+ alterColumnType(nNewType,colName,descriptor);
+ bColumnNameChanged = true;
+ }
+
+ // third: check the default values
+ ::rtl::OUString sNewDefault,sOldDefault;
+ xProp->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sOldDefault;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_DEFAULTVALUE)) >>= sNewDefault;
+
+ if(sOldDefault.getLength())
+ {
+ dropDefaultValue(colName);
+ if(sNewDefault.getLength() && sOldDefault != sNewDefault)
+ alterDefaultValue(sNewDefault,colName);
+ }
+ else if(!sOldDefault.getLength() && sNewDefault.getLength())
+ alterDefaultValue(sNewDefault,colName);
+
+ // now we should look if the name of the column changed
+ ::rtl::OUString sNewColumnName;
+ descriptor->getPropertyValue(rProp.getNameByIndex(PROPERTY_ID_NAME)) >>= sNewColumnName;
+ if ( !sNewColumnName.equalsIgnoreAsciiCase(colName) && !bColumnNameChanged )
+ {
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" CHANGE "));
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,colName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ sSql += OTables::adjustSQL(::dbtools::createStandardColumnPart(descriptor,getConnection(),static_cast<OTables*>(m_pTables),getTypeCreatePattern()));
+ executeStatement(sSql);
+ }
+ m_pColumns->refresh();
+ }
+ else
+ {
+ if(m_pColumns)
+ {
+ m_pColumns->dropByName(colName);
+ m_pColumns->appendByDescriptor(descriptor);
+ }
+ }
+
+}
+// -----------------------------------------------------------------------------
+void OMySQLTable::alterColumnType(sal_Int32 nNewType,const ::rtl::OUString& _rColName, const Reference<XPropertySet>& _xDescriptor)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" CHANGE "));
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,_rColName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+
+ OColumn* pColumn = new OColumn(sal_True);
+ Reference<XPropertySet> xProp = pColumn;
+ ::comphelper::copyProperties(_xDescriptor,xProp);
+ xProp->setPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE),makeAny(nNewType));
+
+ sSql += OTables::adjustSQL(::dbtools::createStandardColumnPart(xProp,getConnection(),static_cast<OTables*>(m_pTables),getTypeCreatePattern()));
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OMySQLTable::getTypeCreatePattern() const
+{
+ static const ::rtl::OUString s_sCreatePattern(RTL_CONSTASCII_USTRINGPARAM("(M,D)"));
+ return s_sCreatePattern;
+}
+// -----------------------------------------------------------------------------
+void OMySQLTable::alterDefaultValue(const ::rtl::OUString& _sNewDefault,const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER "));
+
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,_rColName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" SET DEFAULT '")) + _sNewDefault;
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("'"));
+
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+void OMySQLTable::dropDefaultValue(const ::rtl::OUString& _rColName)
+{
+ ::rtl::OUString sSql = getAlterTableColumnPart();
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" ALTER "));
+
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+ sSql += ::dbtools::quoteName(sQuote,_rColName);
+ sSql += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" DROP DEFAULT"));
+
+ executeStatement(sSql);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OMySQLTable::getAlterTableColumnPart()
+{
+ ::rtl::OUString sSql = ::rtl::OUString::createFromAscii("ALTER TABLE ");
+ const ::rtl::OUString sQuote = getMetaData()->getIdentifierQuoteString( );
+
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( getMetaData(), m_CatalogName, m_SchemaName, m_Name, sal_True, ::dbtools::eInTableDefinitions ) );
+ sSql += sComposedName;
+
+ return sSql;
+}
+// -----------------------------------------------------------------------------
+void OMySQLTable::executeStatement(const ::rtl::OUString& _rStatement )
+{
+ ::rtl::OUString sSQL = _rStatement;
+ if(sSQL.lastIndexOf(',') == (sSQL.getLength()-1))
+ sSQL = sSQL.replaceAt(sSQL.getLength()-1,1,::rtl::OUString::createFromAscii(")"));
+
+ Reference< XStatement > xStmt = getConnection()->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sSQL);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OMySQLTable::getRenameStart() const
+{
+ return ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RENAME TABLE "));
+}
+
+
+
+
diff --git a/connectivity/source/drivers/mysql/YTables.cxx b/connectivity/source/drivers/mysql/YTables.cxx
new file mode 100644
index 000000000000..80bb2baf58c0
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YTables.cxx
@@ -0,0 +1,243 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YTables.hxx"
+#include "mysql/YViews.hxx"
+#include "mysql/YTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include "mysql/YCatalog.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include <comphelper/types.hxx>
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace ::cppu;
+using namespace connectivity::mysql;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OTables::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_rName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ static const ::rtl::OUString s_sTableTypeView(RTL_CONSTASCII_USTRINGPARAM("VIEW"));
+ static const ::rtl::OUString s_sTableTypeTable(RTL_CONSTASCII_USTRINGPARAM("TABLE"));
+ static const ::rtl::OUString s_sAll(RTL_CONSTASCII_USTRINGPARAM("%"));
+
+ Sequence< ::rtl::OUString > sTableTypes(3);
+ sTableTypes[0] = s_sTableTypeView;
+ sTableTypes[1] = s_sTableTypeTable;
+ sTableTypes[2] = s_sAll; // just to be sure to include anything else ....
+
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ Reference< XResultSet > xResult = m_xMetaData->getTables(aCatalog,sSchema,sTable,sTableTypes);
+
+ sdbcx::ObjectType xRet = NULL;
+ if ( xResult.is() )
+ {
+ Reference< XRow > xRow(xResult,UNO_QUERY);
+ if ( xResult->next() ) // there can be only one table with this name
+ {
+// Reference<XStatement> xStmt = m_xConnection->createStatement();
+// if ( xStmt.is() )
+// {
+// Reference< XResultSet > xPrivRes = xStmt->executeQuery();
+// Reference< XRow > xPrivRow(xPrivRes,UNO_QUERY);
+// while ( xPrivRes.is() && xPrivRes->next() )
+// {
+// if ( xPrivRow->getString(1) )
+// {
+// }
+// }
+// }
+ sal_Int32 nPrivileges = Privilege::DROP |
+ Privilege::REFERENCE |
+ Privilege::ALTER |
+ Privilege::CREATE |
+ Privilege::READ |
+ Privilege::DELETE |
+ Privilege::UPDATE |
+ Privilege::INSERT |
+ Privilege::SELECT;
+
+ OMySQLTable* pRet = new OMySQLTable( this
+ ,static_cast<OMySQLCatalog&>(m_rParent).getConnection()
+ ,sTable
+ ,xRow->getString(4)
+ ,xRow->getString(5)
+ ,sSchema
+ ,sCatalog
+ ,nPrivileges);
+ xRet = pRet;
+ }
+ ::comphelper::disposeComponent(xResult);
+ }
+
+ return xRet;
+}
+// -------------------------------------------------------------------------
+void OTables::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OMySQLCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OTables::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OTables::createDescriptor()
+{
+ return new OMySQLTable(this,static_cast<OMySQLCatalog&>(m_rParent).getConnection());
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OTables::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createTable(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OTables::dropObject(sal_Int32 _nPos,const ::rtl::OUString _sElementName)
+{
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
+
+
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,_sElementName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP ");
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ sal_Bool bIsView = xProp.is() && ::comphelper::getString(xProp->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_TYPE))) == ::rtl::OUString::createFromAscii("VIEW");
+ if(bIsView) // here we have a view
+ aSql += ::rtl::OUString::createFromAscii("VIEW ");
+ else
+ aSql += ::rtl::OUString::createFromAscii("TABLE ");
+
+ ::rtl::OUString sComposedName(
+ ::dbtools::composeTableName( m_xMetaData, sCatalog, sSchema, sTable, sal_True, ::dbtools::eInDataManipulation ) );
+ aSql += sComposedName;
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+ // if no exception was thrown we must delete it from the views
+ if ( bIsView )
+ {
+ OViews* pViews = static_cast<OViews*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateViews());
+ if ( pViews && pViews->hasByName(_sElementName) )
+ pViews->dropByNameImpl(_sElementName);
+ }
+ }
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OTables::adjustSQL(const ::rtl::OUString& _sSql)
+{
+ ::rtl::OUString sSQL = _sSql;
+ static const ::rtl::OUString s_sUNSIGNED(RTL_CONSTASCII_USTRINGPARAM("UNSIGNED"));
+ sal_Int32 nIndex = sSQL.indexOf(s_sUNSIGNED);
+ while(nIndex != -1 )
+ {
+ sal_Int32 nParen = sSQL.indexOf(')',nIndex);
+ sal_Int32 nPos = nIndex + s_sUNSIGNED.getLength();
+ ::rtl::OUString sNewUnsigned( sSQL.copy(nPos,nParen - nPos + 1));
+ sSQL = sSQL.replaceAt(nIndex,s_sUNSIGNED.getLength()+sNewUnsigned.getLength(),sNewUnsigned + s_sUNSIGNED);
+ nIndex = sSQL.indexOf(s_sUNSIGNED,nIndex + s_sUNSIGNED.getLength()+sNewUnsigned.getLength());
+ }
+ return sSQL;
+}
+// -------------------------------------------------------------------------
+void OTables::createTable( const Reference< XPropertySet >& descriptor )
+{
+ const Reference< XConnection > xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
+ static const ::rtl::OUString s_sCreatePattern(RTL_CONSTASCII_USTRINGPARAM("(M,D)"));
+ const ::rtl::OUString aSql = adjustSQL(::dbtools::createSqlCreateTableStatement(descriptor,xConnection,this,s_sCreatePattern));
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OTables::appendNew(const ::rtl::OUString& _rsNewTable)
+{
+ insertElement(_rsNewTable,NULL);
+
+ // notify our container listeners
+ ContainerEvent aEvent(static_cast<XContainer*>(this), makeAny(_rsNewTable), Any(), Any());
+ OInterfaceIteratorHelper aListenerLoop(m_aContainerListeners);
+ while (aListenerLoop.hasMoreElements())
+ static_cast<XContainerListener*>(aListenerLoop.next())->elementInserted(aEvent);
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OTables::getNameForObject(const sdbcx::ObjectType& _xObject)
+{
+ OSL_ENSURE(_xObject.is(),"OTables::getNameForObject: Object is NULL!");
+ return ::dbtools::composeTableName( m_xMetaData, _xObject, ::dbtools::eInDataManipulation, false, false, false );
+}
+// -----------------------------------------------------------------------------
+void OTables::addComment(const Reference< XPropertySet >& descriptor,::rtl::OUStringBuffer& _rOut)
+{
+ ::rtl::OUString sDesc;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_DESCRIPTION)) >>= sDesc;
+ if ( sDesc.getLength() )
+ {
+ _rOut.appendAscii(" COMMENT '");
+ _rOut.append(sDesc);
+ _rOut.appendAscii("'");
+ }
+}
diff --git a/connectivity/source/drivers/mysql/YUser.cxx b/connectivity/source/drivers/mysql/YUser.cxx
new file mode 100644
index 000000000000..9913fbe963fd
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YUser.cxx
@@ -0,0 +1,350 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YUser.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <com/sun/star/sdbcx/Privilege.hpp>
+#include <com/sun/star/sdbcx/PrivilegeObject.hpp>
+#include "TConnection.hxx"
+#include "resource/common_res.hrc"
+
+using namespace connectivity;
+using namespace connectivity::mysql;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+// -------------------------------------------------------------------------
+OMySQLUser::OMySQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : connectivity::sdbcx::OUser(sal_True)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+OMySQLUser::OMySQLUser( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ const ::rtl::OUString& _Name
+ ) : connectivity::sdbcx::OUser(_Name,sal_True)
+ ,m_xConnection(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+void OMySQLUser::refreshGroups()
+{
+}
+// -------------------------------------------------------------------------
+OUserExtend::OUserExtend( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection) : OMySQLUser(_xConnection)
+{
+ construct();
+}
+// -------------------------------------------------------------------------
+typedef connectivity::sdbcx::OUser OUser_TYPEDEF;
+void OUserExtend::construct()
+{
+ registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD), PROPERTY_ID_PASSWORD,0,&m_Password,::getCppuType(reinterpret_cast< ::rtl::OUString*>(NULL)));
+}
+// -----------------------------------------------------------------------------
+cppu::IPropertyArrayHelper* OUserExtend::createArrayHelper() const
+{
+ Sequence< Property > aProps;
+ describeProperties(aProps);
+ return new cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+cppu::IPropertyArrayHelper & OUserExtend::getInfoHelper()
+{
+ return *OUserExtend_PROP::getArrayHelper();
+}
+typedef connectivity::sdbcx::OUser_BASE OUser_BASE_RBHELPER;
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OMySQLUser::getPrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRights;
+}
+// -----------------------------------------------------------------------------
+void OMySQLUser::findPrivilegesAndGrantPrivileges(const ::rtl::OUString& objName, sal_Int32 objType,sal_Int32& nRights,sal_Int32& nRightsWithGrant) throw(SQLException, RuntimeException)
+{
+ nRightsWithGrant = nRights = 0;
+ // first we need to create the sql stmt to select the privs
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(xMeta,objName,sCatalog,sSchema,sTable,::dbtools::eInDataManipulation);
+ Reference<XResultSet> xRes;
+ switch(objType)
+ {
+ case PrivilegeObject::TABLE:
+ case PrivilegeObject::VIEW:
+ {
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getTablePrivileges(aCatalog,sSchema,sTable);
+ }
+ break;
+
+ case PrivilegeObject::COLUMN:
+ {
+ Any aCatalog;
+ if ( sCatalog.getLength() )
+ aCatalog <<= sCatalog;
+ xRes = xMeta->getColumnPrivileges(aCatalog,sSchema,sTable,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("%")));
+ }
+ break;
+ }
+
+ if ( xRes.is() )
+ {
+ static const ::rtl::OUString sSELECT = ::rtl::OUString::createFromAscii("SELECT");
+ static const ::rtl::OUString sINSERT = ::rtl::OUString::createFromAscii("INSERT");
+ static const ::rtl::OUString sUPDATE = ::rtl::OUString::createFromAscii("UPDATE");
+ static const ::rtl::OUString sDELETE = ::rtl::OUString::createFromAscii("DELETE");
+ static const ::rtl::OUString sREAD = ::rtl::OUString::createFromAscii("READ");
+ static const ::rtl::OUString sCREATE = ::rtl::OUString::createFromAscii("CREATE");
+ static const ::rtl::OUString sALTER = ::rtl::OUString::createFromAscii("ALTER");
+ static const ::rtl::OUString sREFERENCE = ::rtl::OUString::createFromAscii("REFERENCE");
+ static const ::rtl::OUString sDROP = ::rtl::OUString::createFromAscii("DROP");
+ static const ::rtl::OUString sYes = ::rtl::OUString::createFromAscii("YES");
+
+ nRightsWithGrant = nRights = 0;
+
+ Reference<XRow> xCurrentRow(xRes,UNO_QUERY);
+ while( xCurrentRow.is() && xRes->next() )
+ {
+ ::rtl::OUString sGrantee = xCurrentRow->getString(5);
+ ::rtl::OUString sPrivilege = xCurrentRow->getString(6);
+ ::rtl::OUString sGrantable = xCurrentRow->getString(7);
+
+ if (!m_Name.equalsIgnoreAsciiCase(sGrantee))
+ continue;
+
+ if (sPrivilege.equalsIgnoreAsciiCase(sSELECT))
+ {
+ nRights |= Privilege::SELECT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::SELECT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sINSERT))
+ {
+ nRights |= Privilege::INSERT;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::INSERT;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sUPDATE))
+ {
+ nRights |= Privilege::UPDATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::UPDATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDELETE))
+ {
+ nRights |= Privilege::DELETE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DELETE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREAD))
+ {
+ nRights |= Privilege::READ;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::READ;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sCREATE))
+ {
+ nRights |= Privilege::CREATE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::CREATE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sALTER))
+ {
+ nRights |= Privilege::ALTER;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::ALTER;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sREFERENCE))
+ {
+ nRights |= Privilege::REFERENCE;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::REFERENCE;
+ }
+ else if (sPrivilege.equalsIgnoreAsciiCase(sDROP))
+ {
+ nRights |= Privilege::DROP;
+ if ( sGrantable.equalsIgnoreAsciiCase(sYes) )
+ nRightsWithGrant |= Privilege::DROP;
+ }
+ }
+ ::comphelper::disposeComponent(xRes);
+ }
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OMySQLUser::getGrantablePrivileges( const ::rtl::OUString& objName, sal_Int32 objType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+
+ sal_Int32 nRights,nRightsWithGrant;
+ findPrivilegesAndGrantPrivileges(objName,objType,nRights,nRightsWithGrant);
+ return nRightsWithGrant;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OMySQLUser::grantPrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_GRANTED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ } // if ( objType != PrivilegeObject::TABLE )
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("GRANT ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" TO ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OMySQLUser::revokePrivileges( const ::rtl::OUString& objName, sal_Int32 objType, sal_Int32 objPrivileges ) throw(SQLException, RuntimeException)
+{
+ if ( objType != PrivilegeObject::TABLE )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_PRIVILEGE_NOT_REVOKED));
+ ::dbtools::throwGenericSQLException(sError,*this);
+ }
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sPrivs = getPrivilegeString(objPrivileges);
+ if(sPrivs.getLength())
+ {
+ ::rtl::OUString sGrant;
+ sGrant += ::rtl::OUString::createFromAscii("REVOKE ");
+ sGrant += sPrivs;
+ sGrant += ::rtl::OUString::createFromAscii(" ON ");
+ Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
+ sGrant += ::dbtools::quoteTableName(xMeta,objName,::dbtools::eInDataManipulation);
+ sGrant += ::rtl::OUString::createFromAscii(" FROM ");
+ sGrant += m_Name;
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if(xStmt.is())
+ xStmt->execute(sGrant);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+// XUser
+void SAL_CALL OMySQLUser::changePassword( const ::rtl::OUString& /*oldPassword*/, const ::rtl::OUString& newPassword ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+ checkDisposed(OUser_BASE_RBHELPER::rBHelper.bDisposed);
+ ::rtl::OUString sAlterPwd;
+ sAlterPwd = ::rtl::OUString::createFromAscii("SET PASSWORD FOR ");
+ sAlterPwd += m_Name;
+ sAlterPwd += ::rtl::OUString::createFromAscii("@\"%\" = PASSWORD('") ;
+ sAlterPwd += newPassword;
+ sAlterPwd += ::rtl::OUString::createFromAscii("')") ;
+
+
+ Reference<XStatement> xStmt = m_xConnection->createStatement();
+ if ( xStmt.is() )
+ {
+ xStmt->execute(sAlterPwd);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString OMySQLUser::getPrivilegeString(sal_Int32 nRights) const
+{
+ ::rtl::OUString sPrivs;
+ if((nRights & Privilege::INSERT) == Privilege::INSERT)
+ sPrivs += ::rtl::OUString::createFromAscii("INSERT");
+
+ if((nRights & Privilege::DELETE) == Privilege::DELETE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("DELETE");
+ }
+
+ if((nRights & Privilege::UPDATE) == Privilege::UPDATE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("UPDATE");
+ }
+
+ if((nRights & Privilege::ALTER) == Privilege::ALTER)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("ALTER");
+ }
+
+ if((nRights & Privilege::SELECT) == Privilege::SELECT)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("SELECT");
+ }
+
+ if((nRights & Privilege::REFERENCE) == Privilege::REFERENCE)
+ {
+ if(sPrivs.getLength())
+ sPrivs += ::rtl::OUString::createFromAscii(",");
+ sPrivs += ::rtl::OUString::createFromAscii("REFERENCES");
+ }
+
+ return sPrivs;
+}
+// -----------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/mysql/YUsers.cxx b/connectivity/source/drivers/mysql/YUsers.cxx
new file mode 100644
index 000000000000..f49463becfd0
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YUsers.cxx
@@ -0,0 +1,118 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YUsers.hxx"
+#include "mysql/YUser.hxx"
+#include "mysql/YTable.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include "connectivity/sdbcx/IRefreshable.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/dbexception.hxx"
+#include "connectivity/dbtools.hxx"
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::mysql;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+// using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+OUsers::OUsers( ::cppu::OWeakObject& _rParent,
+ ::osl::Mutex& _rMutex,
+ const TStringVector &_rVector,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
+ connectivity::sdbcx::IRefreshableUsers* _pParent)
+ : sdbcx::OCollection(_rParent,sal_True,_rMutex,_rVector)
+ ,m_xConnection(_xConnection)
+ ,m_pParent(_pParent)
+{
+}
+// -----------------------------------------------------------------------------
+
+sdbcx::ObjectType OUsers::createObject(const ::rtl::OUString& _rName)
+{
+ return new OMySQLUser(m_xConnection,_rName);
+}
+// -------------------------------------------------------------------------
+void OUsers::impl_refresh() throw(RuntimeException)
+{
+ m_pParent->refreshUsers();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OUsers::createDescriptor()
+{
+ OUserExtend* pNew = new OUserExtend(m_xConnection);
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OUsers::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("GRANT USAGE ON * TO ");
+ ::rtl::OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString sUserName( _rForName );
+ aSql += ::dbtools::quoteName(aQuote,sUserName)
+ + ::rtl::OUString::createFromAscii(" @\"%\" ");
+ ::rtl::OUString sPassword;
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_PASSWORD)) >>= sPassword;
+ if ( sPassword.getLength() )
+ {
+ aSql += ::rtl::OUString::createFromAscii(" IDENTIFIED BY '");
+ aSql += sPassword;
+ aSql += ::rtl::OUString::createFromAscii("'");
+ }
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OUsers::dropObject(sal_Int32 /*_nPos*/,const ::rtl::OUString _sElementName)
+{
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("REVOKE ALL ON * FROM ");
+ ::rtl::OUString aQuote = m_xConnection->getMetaData()->getIdentifierQuoteString( );
+ aSql += ::dbtools::quoteName(aQuote,_sElementName);
+
+ Reference< XStatement > xStmt = m_xConnection->createStatement( );
+ if(xStmt.is())
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+}
+
+// -------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/mysql/YViews.cxx b/connectivity/source/drivers/mysql/YViews.cxx
new file mode 100644
index 000000000000..92fc15d94d91
--- /dev/null
+++ b/connectivity/source/drivers/mysql/YViews.cxx
@@ -0,0 +1,162 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YViews.hxx"
+#include "mysql/YTables.hxx"
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/sdbc/XResultSet.hpp>
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbcx/KeyType.hpp>
+#include <com/sun/star/sdbcx/CheckOption.hpp>
+#include "mysql/YCatalog.hxx"
+#include <comphelper/extract.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include <cppuhelper/interfacecontainer.h>
+#include "connectivity/sdbcx/VView.hxx"
+#include <comphelper/types.hxx>
+#include "TConnection.hxx"
+
+using namespace ::comphelper;
+
+using namespace ::cppu;
+using namespace connectivity;
+using namespace connectivity::mysql;
+using namespace ::com::sun::star::uno;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::sdbcx;
+using namespace ::com::sun::star::sdbc;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::lang;
+using namespace dbtools;
+typedef connectivity::sdbcx::OCollection OCollection_TYPE;
+
+sdbcx::ObjectType OViews::createObject(const ::rtl::OUString& _rName)
+{
+ ::rtl::OUString sCatalog,sSchema,sTable;
+ ::dbtools::qualifiedNameComponents(m_xMetaData,
+ _rName,
+ sCatalog,
+ sSchema,
+ sTable,
+ ::dbtools::eInDataManipulation);
+ return new ::connectivity::sdbcx::OView(isCaseSensitive(),
+ sTable,
+ m_xMetaData,
+ 0,
+ ::rtl::OUString(),
+ sSchema,
+ sCatalog
+ );
+}
+// -------------------------------------------------------------------------
+void OViews::impl_refresh( ) throw(RuntimeException)
+{
+ static_cast<OMySQLCatalog&>(m_rParent).refreshTables();
+}
+// -------------------------------------------------------------------------
+void OViews::disposing(void)
+{
+m_xMetaData.clear();
+ OCollection::disposing();
+}
+// -------------------------------------------------------------------------
+Reference< XPropertySet > OViews::createDescriptor()
+{
+ Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
+ connectivity::sdbcx::OView* pNew = new connectivity::sdbcx::OView(sal_True,xConnection->getMetaData());
+ return pNew;
+}
+// -------------------------------------------------------------------------
+// XAppend
+sdbcx::ObjectType OViews::appendObject( const ::rtl::OUString& _rForName, const Reference< XPropertySet >& descriptor )
+{
+ createView(descriptor);
+ return createObject( _rForName );
+}
+// -------------------------------------------------------------------------
+// XDrop
+void OViews::dropObject(sal_Int32 _nPos,const ::rtl::OUString /*_sElementName*/)
+{
+ if ( m_bInDrop )
+ return;
+
+ Reference< XInterface > xObject( getObject( _nPos ) );
+ sal_Bool bIsNew = connectivity::sdbcx::ODescriptor::isNew( xObject );
+ if (!bIsNew)
+ {
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("DROP VIEW");
+
+ Reference<XPropertySet> xProp(xObject,UNO_QUERY);
+ aSql += ::dbtools::composeTableName( m_xMetaData, xProp, ::dbtools::eInTableDefinitions, false, false, true );
+
+ Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+}
+// -----------------------------------------------------------------------------
+void OViews::dropByNameImpl(const ::rtl::OUString& elementName)
+{
+ m_bInDrop = sal_True;
+ OCollection_TYPE::dropByName(elementName);
+ m_bInDrop = sal_False;
+}
+// -----------------------------------------------------------------------------
+void OViews::createView( const Reference< XPropertySet >& descriptor )
+{
+ Reference<XConnection> xConnection = static_cast<OMySQLCatalog&>(m_rParent).getConnection();
+
+ ::rtl::OUString aSql = ::rtl::OUString::createFromAscii("CREATE VIEW ");
+ ::rtl::OUString aQuote = xConnection->getMetaData()->getIdentifierQuoteString( );
+ ::rtl::OUString sSchema,sCommand;
+
+ aSql += ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInTableDefinitions, false, false, true );
+
+ aSql += ::rtl::OUString::createFromAscii(" AS ");
+ descriptor->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_COMMAND)) >>= sCommand;
+ aSql += sCommand;
+
+ Reference< XStatement > xStmt = xConnection->createStatement( );
+ if ( xStmt.is() )
+ {
+ xStmt->execute(aSql);
+ ::comphelper::disposeComponent(xStmt);
+ }
+
+ // insert the new view also in the tables collection
+ OTables* pTables = static_cast<OTables*>(static_cast<OMySQLCatalog&>(m_rParent).getPrivateTables());
+ if ( pTables )
+ {
+ ::rtl::OUString sName = ::dbtools::composeTableName( m_xMetaData, descriptor, ::dbtools::eInDataManipulation, false, false, false );
+ pTables->appendNew(sName);
+ }
+}
diff --git a/connectivity/source/drivers/mysql/Yservices.cxx b/connectivity/source/drivers/mysql/Yservices.cxx
new file mode 100644
index 000000000000..0927f191e6e6
--- /dev/null
+++ b/connectivity/source/drivers/mysql/Yservices.cxx
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "mysql/YDriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::mysql;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pT
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ADABAS::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODriverDelegator::getImplementationName_Static(),
+ ODriverDelegator::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODriverDelegator::getImplementationName_Static(),
+ ODriverDelegator::getSupportedServiceNames_Static(),
+ ODriverDelegator_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/mysql/exports.dxp b/connectivity/source/drivers/mysql/exports.dxp
new file mode 100644
index 000000000000..9630d7e06768
--- /dev/null
+++ b/connectivity/source/drivers/mysql/exports.dxp
@@ -0,0 +1,3 @@
+component_getImplementationEnvironment
+component_writeInfo
+component_getFactory
diff --git a/connectivity/source/drivers/mysql/makefile.mk b/connectivity/source/drivers/mysql/makefile.mk
new file mode 100644
index 000000000000..fbb68321cb01
--- /dev/null
+++ b/connectivity/source/drivers/mysql/makefile.mk
@@ -0,0 +1,84 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=mysql
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/YDriver.obj \
+ $(SLO)$/YTables.obj \
+ $(SLO)$/YTable.obj \
+ $(SLO)$/YViews.obj \
+ $(SLO)$/YCatalog.obj \
+ $(SLO)$/YColumns.obj \
+ $(SLO)$/YUser.obj \
+ $(SLO)$/YUsers.obj \
+ $(SLO)$/Yservices.obj
+
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Library -----------------------------------
+
+SHL1TARGET= $(MYSQL_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(CPPULIB) \
+ $(CPPUHELPERLIB) \
+ $(SALLIB) \
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB)
+
+
+SHL1DEPN=
+SHL1IMPLIB= i$(MYSQL_TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1EXPORTFILE= exports.dxp
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
+
+
diff --git a/connectivity/source/drivers/mysql/mysql.xcu b/connectivity/source/drivers/mysql/mysql.xcu
new file mode 100755
index 000000000000..afc5c0d07f5d
--- /dev/null
+++ b/connectivity/source/drivers/mysql/mysql.xcu
@@ -0,0 +1,258 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:mysql:jdbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (JDBC)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="JavaDriverClass" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>com.mysql.jdbc.Driver</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseJava" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:mysql:odbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (ODBC)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ <node oor:name="sdbc:mysql:mysqlc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>org.openoffice.comp.drivers.MySQL.Driver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">MySQL (Native)</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="LocalSocket" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="NamedPipe" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsColumnDescription" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/mysql/mysql.xml b/connectivity/source/drivers/mysql/mysql.xml
new file mode 100644
index 000000000000..22ab9d7c79b5
--- /dev/null
+++ b/connectivity/source/drivers/mysql/mysql.xml
@@ -0,0 +1,29 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>odbc</module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>org.openoffice.comp.drivers.MySQL.Driver</name>
+ <description>
+ This is the implementation of the MySQL driver.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ <supported-service>com.sun.star.sdbcx.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/drivers/odbc/OFunctions.cxx b/connectivity/source/drivers/odbc/OFunctions.cxx
new file mode 100644
index 000000000000..d84c55787635
--- /dev/null
+++ b/connectivity/source/drivers/odbc/OFunctions.cxx
@@ -0,0 +1,285 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+//--------------------------------------------------------------------------
+#include "odbc/OFunctions.hxx"
+#include <osl/process.h>
+
+// Implib-Definitionen fuer ODBC-DLL/shared library:
+
+namespace connectivity
+{
+ T3SQLAllocHandle pODBC3SQLAllocHandle;
+T3SQLConnect pODBC3SQLConnect;
+T3SQLDriverConnect pODBC3SQLDriverConnect;
+T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+T3SQLDataSources pODBC3SQLDataSources;
+T3SQLDrivers pODBC3SQLDrivers;
+T3SQLGetInfo pODBC3SQLGetInfo;
+T3SQLGetFunctions pODBC3SQLGetFunctions;
+T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+//T3SQLSetDescField pODBC3SQLSetDescField;
+//T3SQLGetDescField pODBC3SQLGetDescField;
+//T3SQLGetDescRec pODBC3SQLGetDescRec;
+//T3SQLSetDescRec pODBC3SQLSetDescRec;
+T3SQLPrepare pODBC3SQLPrepare;
+T3SQLBindParameter pODBC3SQLBindParameter;
+//T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLSetCursorName pODBC3SQLSetCursorName;
+T3SQLExecute pODBC3SQLExecute;
+T3SQLExecDirect pODBC3SQLExecDirect;
+//T3SQLNativeSql pODBC3SQLNativeSql;
+T3SQLDescribeParam pODBC3SQLDescribeParam;
+T3SQLNumParams pODBC3SQLNumParams;
+T3SQLParamData pODBC3SQLParamData;
+T3SQLPutData pODBC3SQLPutData;
+T3SQLRowCount pODBC3SQLRowCount;
+T3SQLNumResultCols pODBC3SQLNumResultCols;
+T3SQLDescribeCol pODBC3SQLDescribeCol;
+T3SQLColAttribute pODBC3SQLColAttribute;
+T3SQLBindCol pODBC3SQLBindCol;
+T3SQLFetch pODBC3SQLFetch;
+T3SQLFetchScroll pODBC3SQLFetchScroll;
+T3SQLGetData pODBC3SQLGetData;
+T3SQLSetPos pODBC3SQLSetPos;
+T3SQLBulkOperations pODBC3SQLBulkOperations;
+T3SQLMoreResults pODBC3SQLMoreResults;
+//T3SQLGetDiagField pODBC3SQLGetDiagField;
+T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+T3SQLColumns pODBC3SQLColumns;
+T3SQLForeignKeys pODBC3SQLForeignKeys;
+T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+T3SQLProcedures pODBC3SQLProcedures;
+T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+T3SQLStatistics pODBC3SQLStatistics;
+T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+T3SQLTables pODBC3SQLTables;
+T3SQLFreeStmt pODBC3SQLFreeStmt;
+T3SQLCloseCursor pODBC3SQLCloseCursor;
+T3SQLCancel pODBC3SQLCancel;
+T3SQLEndTran pODBC3SQLEndTran;
+T3SQLDisconnect pODBC3SQLDisconnect;
+T3SQLFreeHandle pODBC3SQLFreeHandle;
+T3SQLGetCursorName pODBC3SQLGetCursorName;
+T3SQLNativeSql pODBC3SQLNativeSql;
+
+sal_Bool LoadFunctions(oslModule pODBCso);
+// -------------------------------------------------------------------------
+// Dynamisches Laden der DLL/shared lib und Adressen der Funktionen besorgen:
+// Liefert sal_True bei Erfolg.
+sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath)
+{
+ static sal_Bool bLoaded = sal_False;
+ static oslModule pODBCso = NULL;
+
+ if (bLoaded)
+ return sal_True;
+#ifdef WIN
+ _rPath = ::rtl::OUString::createFromAscii("ODBC.DLL");
+
+#endif
+#ifdef WNT
+ _rPath = ::rtl::OUString::createFromAscii("ODBC32.DLL");
+#endif
+#ifdef UNX
+ #ifdef MACOSX
+ _rPath = ::rtl::OUString::createFromAscii("libiodbc.dylib");
+ #else
+ _rPath = ::rtl::OUString::createFromAscii("libodbc.so.1");
+ pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
+ if ( !pODBCso )
+ _rPath = ::rtl::OUString::createFromAscii("libodbc.so");
+ #endif /* MACOSX */
+#endif
+#ifdef OS2
+ _rPath = ::rtl::OUString::createFromAscii("ODBC");
+#endif
+
+ if ( !pODBCso )
+ pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
+ if( !pODBCso)
+#ifdef OS2
+ {
+ delete pODBCso;
+ _rPath = ::rtl::OUString::createFromAscii("WOD402");
+ pODBCso = osl_loadModule( _rPath.pData,SAL_LOADMODULE_NOW );
+ if( !pODBCso)
+ return sal_False;
+ }
+#else
+ return sal_False;
+#endif
+
+ return bLoaded = LoadFunctions(pODBCso);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool LoadFunctions(oslModule pODBCso)
+{
+
+ if( ( pODBC3SQLAllocHandle = (T3SQLAllocHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLAllocHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLConnect = (T3SQLConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDriverConnect = (T3SQLDriverConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDriverConnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBrowseConnect = (T3SQLBrowseConnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBrowseConnect").pData )) == NULL )
+ return sal_False;
+ if(( pODBC3SQLDataSources = (T3SQLDataSources)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDataSources").pData )) == NULL )
+ return sal_False;
+ if(( pODBC3SQLDrivers = (T3SQLDrivers)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDrivers").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetInfo = (T3SQLGetInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetInfo").pData )) == NULL )
+ return sal_False;
+ if(( pODBC3SQLGetFunctions = (T3SQLGetFunctions)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetFunctions").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetTypeInfo = (T3SQLGetTypeInfo)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetTypeInfo").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetConnectAttr = (T3SQLSetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetConnectAttr = (T3SQLGetConnectAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetConnectAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetEnvAttr = (T3SQLSetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetEnvAttr = (T3SQLGetEnvAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetEnvAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetStmtAttr = (T3SQLSetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetStmtAttr").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetStmtAttr = (T3SQLGetStmtAttr)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetStmtAttr").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLSetDescField = (T3SQLSetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescField").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetDescField = (T3SQLGetDescField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescField").pData )) == NULL )
+ return sal_False;*/
+ /*if( ( pODBC3SQLGetDescRec = (T3SQLGetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDescRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetDescRec = (T3SQLSetDescRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetDescRec").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLPrepare = (T3SQLPrepare)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrepare").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindParameter = (T3SQLBindParameter)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindParameter").pData )) == NULL )
+ return sal_False;
+// if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+// return sal_False;
+ if( ( pODBC3SQLSetCursorName = (T3SQLSetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecute = (T3SQLExecute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLExecDirect = (T3SQLExecDirect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLExecDirect").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLDescribeParam = (T3SQLDescribeParam)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeParam").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumParams = (T3SQLNumParams)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumParams").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLParamData = (T3SQLParamData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLParamData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPutData = (T3SQLPutData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPutData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLRowCount = (T3SQLRowCount)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLRowCount").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNumResultCols = (T3SQLNumResultCols)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNumResultCols").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDescribeCol = (T3SQLDescribeCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDescribeCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColAttribute = (T3SQLColAttribute)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColAttribute").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBindCol = (T3SQLBindCol)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBindCol").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetch = (T3SQLFetch)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetch").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFetchScroll = (T3SQLFetchScroll)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFetchScroll").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetData = (T3SQLGetData)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetData").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSetPos = (T3SQLSetPos)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSetPos").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLBulkOperations = (T3SQLBulkOperations)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLBulkOperations").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLMoreResults = (T3SQLMoreResults)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLMoreResults").pData )) == NULL )
+ return sal_False;
+ /*if( ( pODBC3SQLGetDiagField = (T3SQLGetDiagField)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagField").pData )) == NULL )
+ return sal_False;*/
+ if( ( pODBC3SQLGetDiagRec = (T3SQLGetDiagRec)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetDiagRec").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumnPrivileges = (T3SQLColumnPrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumnPrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLColumns = (T3SQLColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLForeignKeys = (T3SQLForeignKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLForeignKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLPrimaryKeys = (T3SQLPrimaryKeys)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLPrimaryKeys").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedureColumns = (T3SQLProcedureColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedureColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLProcedures = (T3SQLProcedures)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLProcedures").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLSpecialColumns = (T3SQLSpecialColumns)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLSpecialColumns").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLStatistics = (T3SQLStatistics)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLStatistics").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTablePrivileges = (T3SQLTablePrivileges)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTablePrivileges").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLTables = (T3SQLTables)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLTables").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeStmt = (T3SQLFreeStmt)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeStmt").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCloseCursor = (T3SQLCloseCursor)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCloseCursor").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLCancel = (T3SQLCancel)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLCancel").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLEndTran = (T3SQLEndTran)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLEndTran").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLDisconnect = (T3SQLDisconnect)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLDisconnect").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLFreeHandle = (T3SQLFreeHandle)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLFreeHandle").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLGetCursorName = (T3SQLGetCursorName)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLGetCursorName").pData )) == NULL )
+ return sal_False;
+ if( ( pODBC3SQLNativeSql = (T3SQLNativeSql)osl_getFunctionSymbol(pODBCso, ::rtl::OUString::createFromAscii("SQLNativeSql").pData )) == NULL )
+ return sal_False;
+
+ return sal_True;
+}
+// -------------------------------------------------------------------------
+
+}
+
+
+
diff --git a/connectivity/source/drivers/odbc/ORealDriver.cxx b/connectivity/source/drivers/odbc/ORealDriver.cxx
new file mode 100644
index 000000000000..4e541d4e67d7
--- /dev/null
+++ b/connectivity/source/drivers/odbc/ORealDriver.cxx
@@ -0,0 +1,369 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ORealDriver.hxx"
+#include "odbc/ODriver.hxx"
+#include "odbc/OTools.hxx"
+#include "odbc/OFunctions.hxx"
+#include "diagnose_ex.h"
+
+namespace connectivity
+{
+ sal_Bool LoadFunctions(oslModule pODBCso);
+ sal_Bool LoadLibrary_ODBC3(::rtl::OUString &_rPath);
+ // extern declaration of the function pointer
+ extern T3SQLAllocHandle pODBC3SQLAllocHandle;
+ extern T3SQLConnect pODBC3SQLConnect;
+ extern T3SQLDriverConnect pODBC3SQLDriverConnect;
+ extern T3SQLBrowseConnect pODBC3SQLBrowseConnect;
+ extern T3SQLDataSources pODBC3SQLDataSources;
+ extern T3SQLDrivers pODBC3SQLDrivers;
+ extern T3SQLGetInfo pODBC3SQLGetInfo;
+ extern T3SQLGetFunctions pODBC3SQLGetFunctions;
+ extern T3SQLGetTypeInfo pODBC3SQLGetTypeInfo;
+ extern T3SQLSetConnectAttr pODBC3SQLSetConnectAttr;
+ extern T3SQLGetConnectAttr pODBC3SQLGetConnectAttr;
+ extern T3SQLSetEnvAttr pODBC3SQLSetEnvAttr;
+ extern T3SQLGetEnvAttr pODBC3SQLGetEnvAttr;
+ extern T3SQLSetStmtAttr pODBC3SQLSetStmtAttr;
+ extern T3SQLGetStmtAttr pODBC3SQLGetStmtAttr;
+ //extern T3SQLSetDescField pODBC3SQLSetDescField;
+ //extern T3SQLGetDescField pODBC3SQLGetDescField;
+ //extern T3SQLGetDescRec pODBC3SQLGetDescRec;
+ //extern T3SQLSetDescRec pODBC3SQLSetDescRec;
+ extern T3SQLPrepare pODBC3SQLPrepare;
+ extern T3SQLBindParameter pODBC3SQLBindParameter;
+ //extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLSetCursorName pODBC3SQLSetCursorName;
+ extern T3SQLExecute pODBC3SQLExecute;
+ extern T3SQLExecDirect pODBC3SQLExecDirect;
+ //extern T3SQLNativeSql pODBC3SQLNativeSql;
+ extern T3SQLDescribeParam pODBC3SQLDescribeParam;
+ extern T3SQLNumParams pODBC3SQLNumParams;
+ extern T3SQLParamData pODBC3SQLParamData;
+ extern T3SQLPutData pODBC3SQLPutData;
+ extern T3SQLRowCount pODBC3SQLRowCount;
+ extern T3SQLNumResultCols pODBC3SQLNumResultCols;
+ extern T3SQLDescribeCol pODBC3SQLDescribeCol;
+ extern T3SQLColAttribute pODBC3SQLColAttribute;
+ extern T3SQLBindCol pODBC3SQLBindCol;
+ extern T3SQLFetch pODBC3SQLFetch;
+ extern T3SQLFetchScroll pODBC3SQLFetchScroll;
+ extern T3SQLGetData pODBC3SQLGetData;
+ extern T3SQLSetPos pODBC3SQLSetPos;
+ extern T3SQLBulkOperations pODBC3SQLBulkOperations;
+ extern T3SQLMoreResults pODBC3SQLMoreResults;
+ //extern T3SQLGetDiagField pODBC3SQLGetDiagField;
+ extern T3SQLGetDiagRec pODBC3SQLGetDiagRec;
+ extern T3SQLColumnPrivileges pODBC3SQLColumnPrivileges;
+ extern T3SQLColumns pODBC3SQLColumns;
+ extern T3SQLForeignKeys pODBC3SQLForeignKeys;
+ extern T3SQLPrimaryKeys pODBC3SQLPrimaryKeys;
+ extern T3SQLProcedureColumns pODBC3SQLProcedureColumns;
+ extern T3SQLProcedures pODBC3SQLProcedures;
+ extern T3SQLSpecialColumns pODBC3SQLSpecialColumns;
+ extern T3SQLStatistics pODBC3SQLStatistics;
+ extern T3SQLTablePrivileges pODBC3SQLTablePrivileges;
+ extern T3SQLTables pODBC3SQLTables;
+ extern T3SQLFreeStmt pODBC3SQLFreeStmt;
+ extern T3SQLCloseCursor pODBC3SQLCloseCursor;
+ extern T3SQLCancel pODBC3SQLCancel;
+ extern T3SQLEndTran pODBC3SQLEndTran;
+ extern T3SQLDisconnect pODBC3SQLDisconnect;
+ extern T3SQLFreeHandle pODBC3SQLFreeHandle;
+ extern T3SQLGetCursorName pODBC3SQLGetCursorName;
+ extern T3SQLNativeSql pODBC3SQLNativeSql;
+
+
+ namespace odbc
+ {
+ class ORealObdcDriver : public ODBCDriver
+ {
+ protected:
+ virtual oslGenericFunction getOdbcFunction(sal_Int32 _nIndex) const;
+ virtual SQLHANDLE EnvironmentHandle(::rtl::OUString &_rPath);
+ public:
+ ORealObdcDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) : ODBCDriver(_rxFactory) {}
+ };
+
+ //------------------------------------------------------------------
+oslGenericFunction ORealObdcDriver::getOdbcFunction(sal_Int32 _nIndex) const
+{
+ oslGenericFunction pFunction = NULL;
+ switch(_nIndex)
+ {
+ case ODBC3SQLAllocHandle:
+ pFunction = (oslGenericFunction)pODBC3SQLAllocHandle;
+ break;
+ case ODBC3SQLConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLConnect;
+ break;
+ case ODBC3SQLDriverConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLDriverConnect;
+ break;
+ case ODBC3SQLBrowseConnect:
+ pFunction = (oslGenericFunction)pODBC3SQLBrowseConnect;
+ break;
+ case ODBC3SQLDataSources:
+ pFunction = (oslGenericFunction)pODBC3SQLDataSources;
+ break;
+ case ODBC3SQLDrivers:
+ pFunction = (oslGenericFunction)pODBC3SQLDrivers;
+ break;
+ case ODBC3SQLGetInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetInfo;
+ break;
+ case ODBC3SQLGetFunctions:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetFunctions;
+ break;
+ case ODBC3SQLGetTypeInfo:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetTypeInfo;
+ break;
+ case ODBC3SQLSetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetConnectAttr;
+ break;
+ case ODBC3SQLGetConnectAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetConnectAttr;
+ break;
+ case ODBC3SQLSetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetEnvAttr;
+ break;
+ case ODBC3SQLGetEnvAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetEnvAttr;
+ break;
+ case ODBC3SQLSetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetStmtAttr;
+ break;
+ case ODBC3SQLGetStmtAttr:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetStmtAttr;
+ break;
+ case ODBC3SQLPrepare:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrepare;
+ break;
+ case ODBC3SQLBindParameter:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindParameter;
+ break;
+ case ODBC3SQLSetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetCursorName;
+ break;
+ case ODBC3SQLExecute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecute;
+ break;
+ case ODBC3SQLExecDirect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLExecDirect;
+ break;
+ case ODBC3SQLDescribeParam:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeParam;
+ break;
+ case ODBC3SQLNumParams:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumParams;
+ break;
+ case ODBC3SQLParamData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLParamData;
+ break;
+ case ODBC3SQLPutData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPutData;
+ break;
+ case ODBC3SQLRowCount:
+
+ pFunction = (oslGenericFunction)pODBC3SQLRowCount;
+ break;
+ case ODBC3SQLNumResultCols:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNumResultCols;
+ break;
+ case ODBC3SQLDescribeCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDescribeCol;
+ break;
+ case ODBC3SQLColAttribute:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColAttribute;
+ break;
+ case ODBC3SQLBindCol:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBindCol;
+ break;
+ case ODBC3SQLFetch:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetch;
+ break;
+ case ODBC3SQLFetchScroll:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFetchScroll;
+ break;
+ case ODBC3SQLGetData:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetData;
+ break;
+ case ODBC3SQLSetPos:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSetPos;
+ break;
+ case ODBC3SQLBulkOperations:
+
+ pFunction = (oslGenericFunction)pODBC3SQLBulkOperations;
+ break;
+ case ODBC3SQLMoreResults:
+
+ pFunction = (oslGenericFunction)pODBC3SQLMoreResults;
+ break;
+ case ODBC3SQLGetDiagRec:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetDiagRec;
+ break;
+ case ODBC3SQLColumnPrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumnPrivileges;
+ break;
+ case ODBC3SQLColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLColumns;
+ break;
+ case ODBC3SQLForeignKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLForeignKeys;
+ break;
+ case ODBC3SQLPrimaryKeys:
+
+ pFunction = (oslGenericFunction)pODBC3SQLPrimaryKeys;
+ break;
+ case ODBC3SQLProcedureColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedureColumns;
+ break;
+ case ODBC3SQLProcedures:
+
+ pFunction = (oslGenericFunction)pODBC3SQLProcedures;
+ break;
+ case ODBC3SQLSpecialColumns:
+
+ pFunction = (oslGenericFunction)pODBC3SQLSpecialColumns;
+ break;
+ case ODBC3SQLStatistics:
+
+ pFunction = (oslGenericFunction)pODBC3SQLStatistics;
+ break;
+ case ODBC3SQLTablePrivileges:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTablePrivileges;
+ break;
+ case ODBC3SQLTables:
+
+ pFunction = (oslGenericFunction)pODBC3SQLTables;
+ break;
+ case ODBC3SQLFreeStmt:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeStmt;
+ break;
+ case ODBC3SQLCloseCursor:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCloseCursor;
+ break;
+ case ODBC3SQLCancel:
+
+ pFunction = (oslGenericFunction)pODBC3SQLCancel;
+ break;
+ case ODBC3SQLEndTran:
+
+ pFunction = (oslGenericFunction)pODBC3SQLEndTran;
+ break;
+ case ODBC3SQLDisconnect:
+
+ pFunction = (oslGenericFunction)pODBC3SQLDisconnect;
+ break;
+ case ODBC3SQLFreeHandle:
+
+ pFunction = (oslGenericFunction)pODBC3SQLFreeHandle;
+ break;
+ case ODBC3SQLGetCursorName:
+
+ pFunction = (oslGenericFunction)pODBC3SQLGetCursorName;
+ break;
+ case ODBC3SQLNativeSql:
+
+ pFunction = (oslGenericFunction)pODBC3SQLNativeSql;
+ break;
+ default:
+ OSL_ENSURE(0,"Function unknown!");
+ }
+ return pFunction;
+}
+
+//------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL ODBCDriver_CreateInstance(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory) throw( ::com::sun::star::uno::Exception )
+{
+ return *(new ORealObdcDriver(_rxFactory));
+}
+// -----------------------------------------------------------------------------
+// ODBC Environment (gemeinsam fuer alle Connections):
+SQLHANDLE ORealObdcDriver::EnvironmentHandle(::rtl::OUString &_rPath)
+{
+ // Ist (fuer diese Instanz) bereits ein Environment erzeugt worden?
+ if (!m_pDriverHandle)
+ {
+ SQLHANDLE h = SQL_NULL_HANDLE;
+ // Environment allozieren
+
+ // ODBC-DLL jetzt laden:
+ if (!LoadLibrary_ODBC3(_rPath) || N3SQLAllocHandle(SQL_HANDLE_ENV,SQL_NULL_HANDLE,&h) != SQL_SUCCESS)
+ return SQL_NULL_HANDLE;
+
+ // In globaler Struktur merken ...
+ m_pDriverHandle = h;
+ SQLRETURN nError = N3SQLSetEnvAttr(h, SQL_ATTR_ODBC_VERSION,(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_UINTEGER);
+ OSL_UNUSED( nError );
+ //N3SQLSetEnvAttr(h, SQL_ATTR_CONNECTION_POOLING,(SQLPOINTER) SQL_CP_ONE_PER_HENV, SQL_IS_INTEGER);
+ }
+
+ return m_pDriverHandle;
+}
+// -----------------------------------------------------------------------------
+
+ }
+}
+
diff --git a/connectivity/source/drivers/odbc/ORealDriver.hxx b/connectivity/source/drivers/odbc/ORealDriver.hxx
new file mode 100644
index 000000000000..7815e3a9c94b
--- /dev/null
+++ b/connectivity/source/drivers/odbc/ORealDriver.hxx
@@ -0,0 +1,50 @@
+/*************************************************************************
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+************************************************************************/
+
+#ifndef INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX
+#define INCLUDED_CONNECTIVITY_SOURCE_DRIVERS_ODBC_OREALDRIVER_HXX
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/Exception.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+
+namespace com { namespace sun { namespace star {
+ namespace lang { class XMultiServiceFactory; }
+ namespace uno { class XInterface; }
+} } }
+
+namespace connectivity { namespace odbc {
+
+com::sun::star::uno::Reference< com::sun::star::uno::XInterface >
+ODBCDriver_CreateInstance(
+ com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >
+ const & factory)
+ throw (com::sun::star::uno::Exception);
+
+} }
+
+#endif
diff --git a/connectivity/source/drivers/odbc/makefile.mk b/connectivity/source/drivers/odbc/makefile.mk
new file mode 100644
index 000000000000..508cbfb6df63
--- /dev/null
+++ b/connectivity/source/drivers/odbc/makefile.mk
@@ -0,0 +1,78 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=odbc
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+USE_DEFFILE=TRUE
+LDUMP=ldump2.exe
+
+# --- Settings ----------------------------------
+
+.IF "$(DBGUTIL_OJ)"!=""
+ENVCFLAGS+=/FR$(SLO)$/
+.ENDIF
+
+.INCLUDE : $(PRJ)$/makefile.pmk
+.INCLUDE : $(PRJ)$/version.mk
+
+.IF "$(SYSTEM_ODBC_HEADERS)" == "YES"
+CFLAGS+=-DSYSTEM_ODBC_HEADERS
+.ENDIF
+
+# --- ODBC Library -----------------------------------
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/oservices.obj \
+ $(SLO)$/ORealDriver.obj \
+ $(SLO)$/OFunctions.obj
+
+# --- ODBC Library -----------------------------------
+
+SHL1TARGET= $(ODBC_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(ODBCBASELIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(SALLIB)
+
+SHL1IMPLIB= i$(ODBC_TARGET)
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+SHL1VERSIONMAP=$(SOLARENV)/src/component.map
+
+# --- Targets ----------------------------------
+
+.INCLUDE : $(PRJ)$/target.pmk
diff --git a/connectivity/source/drivers/odbc/odbc.xcu b/connectivity/source/drivers/odbc/odbc.xcu
new file mode 100755
index 000000000000..74ba8815d021
--- /dev/null
+++ b/connectivity/source/drivers/odbc/odbc.xcu
@@ -0,0 +1,175 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************ -->
+<oor:component-data oor:name="Drivers" oor:package="org.openoffice.Office.DataAccess" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <node oor:name="Installed">
+ <node oor:name="sdbc:odbc:*" oor:op="replace">
+ <prop oor:name="Driver">
+ <value>com.sun.star.comp.sdbc.ODBCDriver</value>
+ </prop>
+ <prop oor:name="DriverTypeDisplayName" oor:type="xs:string">
+ <value xml:lang="en-US">ODBC</value>
+ </prop>
+ <node oor:name="Properties">
+ <node oor:name="CharSet" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="SystemDriverSettings" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="UseCatalog" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="AutoIncrementCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="AutoRetrievingStatement" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value></value>
+ </prop>
+ </node>
+ <node oor:name="IsAutoRetrievingEnabled" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>false</value>
+ </prop>
+ </node>
+ <node oor:name="AddIndexAppendix" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="Features">
+ <node oor:name="GeneratedValues" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSQL92NamingConstraints" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="AppendTableAliasInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseKeywordAsBeforeAlias" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseBracketedOuterJoinSyntax" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="IgnoreDriverPrivileges" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="ParameterNameSubstitution" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="DisplayVersionColumns" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseCatalogInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseSchemaInSelect" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseIndexDirectionKeyword" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="UseDOSLineEnds" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="BooleanComparisonMode" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="FormsCheckRequiredFields" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="EscapeDateTime" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="PrimaryKeySupport" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ </node>
+ <node oor:name="MetaData">
+ <node oor:name="SupportsTableCreation" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="SupportsBrowsing" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:boolean">
+ <value>true</value>
+ </prop>
+ </node>
+ <node oor:name="Authentication" oor:op="replace">
+ <prop oor:name="Value" oor:type="xs:string">
+ <value>UserPassword</value>
+ </prop>
+ </node>
+ </node>
+ </node>
+ </node>
+</oor:component-data>
diff --git a/connectivity/source/drivers/odbc/odbc.xml b/connectivity/source/drivers/odbc/odbc.xml
new file mode 100644
index 000000000000..3ff988b07b50
--- /dev/null
+++ b/connectivity/source/drivers/odbc/odbc.xml
@@ -0,0 +1,28 @@
+<?xml version='1.0' encoding="UTF-8"?>
+<!DOCTYPE module-description PUBLIC "-//W3C//DTD HTML 3.2//EN" "module-description.dtd">
+<module-description xmlns:xlink="http://www.w3.org/1999/xlink">
+ <module-name>odbc</module-name>
+ <component-description>
+ <author>Ocke Janssen</author>
+ <name>com.sun.star.comp.sdbc.ODBCDriver</name>
+ <description>
+ This is the implementation of the sdbc-odbc bridge.
+ </description>
+ <loader-name>com.sun.star.loader.SharedLibrary</loader-name>
+ <language>c++</language>
+ <status value="final"/>
+ <supported-service>com.sun.star.sdbc.Driver</supported-service>
+ </component-description>
+ <project-build-dependency>cppuhelper</project-build-dependency>
+ <project-build-dependency>cppu</project-build-dependency>
+ <project-build-dependency>sal</project-build-dependency>
+ <project-build-dependency>vos</project-build-dependency>
+ <runtime-module-dependency>cppuhelper</runtime-module-dependency>
+ <runtime-module-dependency>cppu</runtime-module-dependency>
+ <runtime-module-dependency>sal</runtime-module-dependency>
+ <runtime-module-dependency>vos</runtime-module-dependency>
+ <runtime-module-dependency>dbtools</runtime-module-dependency>
+ <runtime-module-dependency>comphelper</runtime-module-dependency>
+</module-description>
+
+
diff --git a/connectivity/source/drivers/odbc/oservices.cxx b/connectivity/source/drivers/odbc/oservices.cxx
new file mode 100644
index 000000000000..21bc448a5708
--- /dev/null
+++ b/connectivity/source/drivers/odbc/oservices.cxx
@@ -0,0 +1,177 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "ORealDriver.hxx"
+#include "odbc/ODriver.hxx"
+#include <cppuhelper/factory.hxx>
+#include <osl/diagnose.h>
+
+using namespace connectivity::odbc;
+using ::rtl::OUString;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Sequence;
+using ::com::sun::star::registry::XRegistryKey;
+using ::com::sun::star::lang::XSingleServiceFactory;
+using ::com::sun::star::lang::XMultiServiceFactory;
+
+typedef Reference< XSingleServiceFactory > (SAL_CALL *createFactoryFunc)
+ (
+ const Reference< XMultiServiceFactory > & rServiceManager,
+ const OUString & rComponentName,
+ ::cppu::ComponentInstantiation pCreateFunction,
+ const Sequence< OUString > & rServiceNames,
+ rtl_ModuleCount* _pTemp
+ );
+
+//***************************************************************************************
+//
+// Die vorgeschriebene C-Api muss erfuellt werden!
+// Sie besteht aus drei Funktionen, die von dem Modul exportiert werden muessen.
+//
+
+//---------------------------------------------------------------------------------------
+void REGISTER_PROVIDER(
+ const OUString& aServiceImplName,
+ const Sequence< OUString>& Services,
+ const Reference< ::com::sun::star::registry::XRegistryKey > & xKey)
+{
+ OUString aMainKeyName;
+ aMainKeyName = OUString::createFromAscii("/");
+ aMainKeyName += aServiceImplName;
+ aMainKeyName += OUString::createFromAscii("/UNO/SERVICES");
+
+ Reference< ::com::sun::star::registry::XRegistryKey > xNewKey( xKey->createKey(aMainKeyName) );
+ OSL_ENSURE(xNewKey.is(), "ODBC::component_writeInfo : could not create a registry key !");
+
+ for (sal_Int32 i=0; i<Services.getLength(); ++i)
+ xNewKey->createKey(Services[i]);
+}
+
+
+//---------------------------------------------------------------------------------------
+struct ProviderRequest
+{
+ Reference< XSingleServiceFactory > xRet;
+ Reference< XMultiServiceFactory > const xServiceManager;
+ OUString const sImplementationName;
+
+ ProviderRequest(
+ void* pServiceManager,
+ sal_Char const* pImplementationName
+ )
+ : xServiceManager(reinterpret_cast<XMultiServiceFactory*>(pServiceManager))
+ , sImplementationName(OUString::createFromAscii(pImplementationName))
+ {
+ }
+
+ inline
+ sal_Bool CREATE_PROVIDER(
+ const OUString& Implname,
+ const Sequence< OUString > & Services,
+ ::cppu::ComponentInstantiation Factory,
+ createFactoryFunc creator
+ )
+ {
+ if (!xRet.is() && (Implname == sImplementationName))
+ try
+ {
+ xRet = creator( xServiceManager, sImplementationName,Factory, Services,0);
+ }
+ catch(...)
+ {
+ }
+ return xRet.is();
+ }
+
+ void* getProvider() const { return xRet.get(); }
+};
+
+//---------------------------------------------------------------------------------------
+
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL
+component_getImplementationEnvironment(
+ const sal_Char **ppEnvTypeName,
+ uno_Environment ** /*ppEnv*/
+ )
+{
+ *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+ void* /*pServiceManager*/,
+ void* pRegistryKey
+ )
+{
+ if (pRegistryKey)
+ try
+ {
+ Reference< ::com::sun::star::registry::XRegistryKey > xKey(reinterpret_cast< ::com::sun::star::registry::XRegistryKey*>(pRegistryKey));
+
+ REGISTER_PROVIDER(
+ ODBCDriver::getImplementationName_Static(),
+ ODBCDriver::getSupportedServiceNames_Static(), xKey);
+
+ return sal_True;
+ }
+ catch (::com::sun::star::registry::InvalidRegistryException& )
+ {
+ OSL_ENSURE(sal_False, "ODBC::component_writeInfo : could not create a registry key ! ## InvalidRegistryException !");
+ }
+
+ return sal_False;
+}
+
+//---------------------------------------------------------------------------------------
+extern "C" SAL_DLLPUBLIC_EXPORT void* SAL_CALL component_getFactory(
+ const sal_Char* pImplementationName,
+ void* pServiceManager,
+ void* /*pRegistryKey*/)
+{
+ void* pRet = 0;
+ if (pServiceManager)
+ {
+ ProviderRequest aReq(pServiceManager,pImplementationName);
+
+ aReq.CREATE_PROVIDER(
+ ODBCDriver::getImplementationName_Static(),
+ ODBCDriver::getSupportedServiceNames_Static(),
+ ODBCDriver_CreateInstance, ::cppu::createSingleFactory)
+ ;
+
+ if(aReq.xRet.is())
+ aReq.xRet->acquire();
+
+ pRet = aReq.getProvider();
+ }
+
+ return pRet;
+};
+
+
diff --git a/connectivity/source/drivers/odbcbase/OConnection.cxx b/connectivity/source/drivers/odbcbase/OConnection.cxx
new file mode 100644
index 000000000000..0c79db546b3f
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OConnection.cxx
@@ -0,0 +1,670 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/OTools.hxx"
+#include "odbc/OConnection.hxx"
+#include "odbc/ODatabaseMetaData.hxx"
+#include "odbc/OFunctions.hxx"
+#include "odbc/ODriver.hxx"
+#include "odbc/OStatement.hxx"
+#include "odbc/OPreparedStatement.hxx"
+#include <com/sun/star/sdbc/ColumnValue.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <connectivity/dbcharset.hxx>
+#include <connectivity/FValue.hxx>
+#include <comphelper/extract.hxx>
+#include "diagnose_ex.h"
+#include <connectivity/dbexception.hxx>
+
+#include <string.h>
+
+using namespace connectivity::odbc;
+using namespace connectivity;
+using namespace dbtools;
+
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+// --------------------------------------------------------------------------------
+OConnection::OConnection(const SQLHANDLE _pDriverHandle,ODBCDriver* _pDriver)
+ : OSubComponent<OConnection, OConnection_BASE>((::cppu::OWeakObject*)_pDriver, this)
+ ,m_pDriver(_pDriver)
+ ,m_pDriverHandleCopy(_pDriverHandle)
+ ,m_nStatementCount(0)
+ ,m_bClosed(sal_True)
+ ,m_bUseCatalog(sal_False)
+ ,m_bUseOldDateFormat(sal_False)
+ ,m_bParameterSubstitution(sal_False)
+ ,m_bIgnoreDriverPrivileges(sal_False)
+ ,m_bPreventGetVersionColumns(sal_False)
+ ,m_bReadOnly(sal_True)
+{
+ m_pDriver->acquire();
+}
+//-----------------------------------------------------------------------------
+OConnection::~OConnection()
+{
+ if(!isClosed( ))
+ close();
+
+ if ( SQL_NULL_HANDLE != m_aConnectionHandle )
+ N3SQLFreeHandle( SQL_HANDLE_DBC, m_aConnectionHandle );
+ m_aConnectionHandle = SQL_NULL_HANDLE;
+
+ m_pDriver->release();
+ m_pDriver = NULL;
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OConnection::release() throw()
+{
+ relase_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+oslGenericFunction OConnection::getOdbcFunction(sal_Int32 _nIndex) const
+{
+ OSL_ENSURE(m_pDriver,"OConnection::getOdbcFunction: m_pDriver is null!");
+ return m_pDriver->getOdbcFunction(_nIndex);
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OConnection::OpenConnection(const ::rtl::OUString& aConnectStr,sal_Int32 nTimeOut, sal_Bool bSilent)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ if (m_aConnectionHandle == SQL_NULL_HANDLE)
+ return -1;
+
+ SQLRETURN nSQLRETURN = 0;
+ SDB_ODBC_CHAR szConnStrOut[4096];
+ SDB_ODBC_CHAR szConnStrIn[2048];
+ SQLSMALLINT cbConnStrOut;
+ memset(szConnStrOut,'\0',4096);
+ memset(szConnStrIn,'\0',2048);
+ ::rtl::OString aConStr(::rtl::OUStringToOString(aConnectStr,getTextEncoding()));
+ memcpy(szConnStrIn, (SDB_ODBC_CHAR*) aConStr.getStr(), ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()));
+
+#ifndef MACOSX
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_LOGIN_TIMEOUT,(SQLPOINTER)nTimeOut,SQL_IS_UINTEGER);
+ // Verbindung aufbauen
+#endif
+
+#ifdef LINUX
+ OSL_UNUSED( bSilent );
+ nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle,
+ NULL,
+ szConnStrIn,
+ (SQLSMALLINT) ::std::min((sal_Int32)2048,aConStr.getLength()),
+ szConnStrOut,
+ (SQLSMALLINT) (sizeof(szConnStrOut)/sizeof(SDB_ODBC_CHAR)) -1,
+ &cbConnStrOut,
+ SQL_DRIVER_NOPROMPT);
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA || SQL_SUCCESS_WITH_INFO == nSQLRETURN)
+ return nSQLRETURN;
+#else
+
+ SQLUSMALLINT nSilent = bSilent ? SQL_DRIVER_NOPROMPT : SQL_DRIVER_COMPLETE;
+ nSQLRETURN = N3SQLDriverConnect(m_aConnectionHandle,
+ NULL,
+ szConnStrIn,
+ (SQLSMALLINT) ::std::min<sal_Int32>((sal_Int32)2048,aConStr.getLength()),
+ szConnStrOut,
+ (SQLSMALLINT) sizeof szConnStrOut,
+ &cbConnStrOut,
+ nSilent);
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ return nSQLRETURN;
+
+ m_bClosed = sal_False;
+
+#endif //LINUX
+
+ try
+ {
+ ::rtl::OUString aVal;
+ OTools::GetInfo(this,m_aConnectionHandle,SQL_DATA_SOURCE_READ_ONLY,aVal,*this,getTextEncoding());
+ m_bReadOnly = !aVal.compareToAscii("Y");
+ }
+ catch(Exception&)
+ {
+ m_bReadOnly = sal_True;
+ }
+ try
+ {
+ ::rtl::OUString sVersion;
+ OTools::GetInfo(this,m_aConnectionHandle,SQL_DRIVER_ODBC_VER,sVersion,*this,getTextEncoding());
+ m_bUseOldDateFormat = sVersion == ::rtl::OUString::createFromAscii("02.50") || sVersion == ::rtl::OUString::createFromAscii("02.00");
+ }
+ catch(Exception&)
+ {
+ }
+
+
+ // autocoomit ist immer default
+
+ if (!m_bReadOnly)
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_AUTOCOMMIT,(SQLPOINTER)SQL_AUTOCOMMIT_ON,SQL_IS_INTEGER);
+
+ return nSQLRETURN;
+}
+//-----------------------------------------------------------------------------
+SQLRETURN OConnection::Construct(const ::rtl::OUString& url,const Sequence< PropertyValue >& info) throw(SQLException)
+{
+ m_aConnectionHandle = SQL_NULL_HANDLE;
+ m_sURL = url;
+ setConnectionInfo(info);
+
+ // Connection allozieren
+ N3SQLAllocHandle(SQL_HANDLE_DBC,m_pDriverHandleCopy,&m_aConnectionHandle);
+ if(m_aConnectionHandle == SQL_NULL_HANDLE)
+ throw SQLException();
+
+ sal_Int32 nLen = url.indexOf(':');
+ nLen = url.indexOf(':',nLen+1);
+ ::rtl::OUString aDSN(RTL_CONSTASCII_USTRINGPARAM("DSN=")), aUID, aPWD, aSysDrvSettings;
+ aDSN += url.copy(nLen+1);
+
+ const char* pUser = "user";
+ const char* pTimeout = "Timeout";
+ const char* pSilent = "Silent";
+ const char* pPwd = "password";
+ const char* pUseCatalog = "UseCatalog";
+ const char* pSysDrv = "SystemDriverSettings";
+ const char* pCharSet = "CharSet";
+ const char* pParaName = "ParameterNameSubstitution";
+ const char* pPrivName = "IgnoreDriverPrivileges";
+ const char* pVerColName = "PreventGetVersionColumns"; // #i60273#
+ const char* pRetrieving = "IsAutoRetrievingEnabled";
+ const char* pRetriStmt = "AutoRetrievingStatement";
+
+ sal_Int32 nTimeout = 20;
+ sal_Bool bSilent = sal_True;
+ const PropertyValue *pBegin = info.getConstArray();
+ const PropertyValue *pEnd = pBegin + info.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ if(!pBegin->Name.compareToAscii(pTimeout))
+ OSL_VERIFY( pBegin->Value >>= nTimeout );
+ else if(!pBegin->Name.compareToAscii(pSilent))
+ OSL_VERIFY( pBegin->Value >>= bSilent );
+ else if(!pBegin->Name.compareToAscii(pPrivName))
+ OSL_VERIFY( pBegin->Value >>= m_bIgnoreDriverPrivileges );
+ else if(!pBegin->Name.compareToAscii(pVerColName))
+ OSL_VERIFY( pBegin->Value >>= m_bPreventGetVersionColumns );
+ else if(!pBegin->Name.compareToAscii(pParaName))
+ OSL_VERIFY( pBegin->Value >>= m_bParameterSubstitution );
+ else if(!pBegin->Name.compareToAscii(pRetrieving))
+ {
+ sal_Bool bAutoRetrievingEnabled = sal_False;
+ OSL_VERIFY( pBegin->Value >>= bAutoRetrievingEnabled );
+ enableAutoRetrievingEnabled(bAutoRetrievingEnabled);
+ }
+ else if(!pBegin->Name.compareToAscii(pRetriStmt))
+ {
+ ::rtl::OUString sGeneratedValueStatement;
+ OSL_VERIFY( pBegin->Value >>= sGeneratedValueStatement );
+ setAutoRetrievingStatement(sGeneratedValueStatement);
+ }
+ else if(!pBegin->Name.compareToAscii(pUser))
+ {
+ OSL_VERIFY( pBegin->Value >>= aUID );
+ aDSN = aDSN + ::rtl::OUString::createFromAscii(";UID=") + aUID;
+ }
+ else if(!pBegin->Name.compareToAscii(pPwd))
+ {
+ OSL_VERIFY( pBegin->Value >>= aPWD );
+ aDSN = aDSN + ::rtl::OUString::createFromAscii(";PWD=") + aPWD;
+ }
+ else if(!pBegin->Name.compareToAscii(pUseCatalog))
+ {
+ OSL_VERIFY( pBegin->Value >>= m_bUseCatalog );
+ }
+ else if(!pBegin->Name.compareToAscii(pSysDrv))
+ {
+ OSL_VERIFY( pBegin->Value >>= aSysDrvSettings );
+ aDSN += ::rtl::OUString::createFromAscii(";");
+ aDSN += aSysDrvSettings;
+ }
+ else if(0 == pBegin->Name.compareToAscii(pCharSet))
+ {
+ ::rtl::OUString sIanaName;
+ OSL_VERIFY( pBegin->Value >>= sIanaName );
+
+ ::dbtools::OCharsetMap aLookupIanaName;
+ ::dbtools::OCharsetMap::const_iterator aLookup = aLookupIanaName.find(sIanaName, ::dbtools::OCharsetMap::IANA());
+ if (aLookup != aLookupIanaName.end())
+ m_nTextEncoding = (*aLookup).getEncoding();
+ else
+ m_nTextEncoding = RTL_TEXTENCODING_DONTKNOW;
+ if(m_nTextEncoding == RTL_TEXTENCODING_DONTKNOW)
+ m_nTextEncoding = osl_getThreadTextEncoding();
+ }
+ }
+ m_sUser = aUID;
+
+ SQLRETURN nSQLRETURN = OpenConnection(aDSN,nTimeout, bSilent);
+ if (nSQLRETURN == SQL_ERROR || nSQLRETURN == SQL_NO_DATA)
+ {
+ OTools::ThrowException(this,nSQLRETURN,m_aConnectionHandle,SQL_HANDLE_DBC,*this,sal_False);
+ }
+ return nSQLRETURN;
+}
+// XServiceInfo
+// --------------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OConnection, "com.sun.star.sdbc.drivers.odbc.OConnection", "com.sun.star.sdbc.Connection")
+
+// --------------------------------------------------------------------------------
+Reference< XStatement > SAL_CALL OConnection::createStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference< XStatement > xReturn = new OStatement(this);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareStatement( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,sql);
+ m_aStatements.push_back(WeakReferenceHelper(xReturn));
+ return xReturn;
+}
+// --------------------------------------------------------------------------------
+Reference< XPreparedStatement > SAL_CALL OConnection::prepareCall( const ::rtl::OUString& /*sql*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::prepareCall", *this );
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::nativeSQL( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OString aSql(::rtl::OUStringToOString(sql.getStr(),getTextEncoding()));
+ char pOut[2048];
+ SQLINTEGER nOutLen;
+ OTools::ThrowException(this,N3SQLNativeSql(m_aConnectionHandle,(SDB_ODBC_CHAR*)aSql.getStr(),aSql.getLength(),(SDB_ODBC_CHAR*)pOut,sizeof pOut - 1,&nOutLen),m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+ return ::rtl::OUString(pOut,nOutLen,getTextEncoding());
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setAutoCommit( sal_Bool autoCommit ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle,
+ SQL_ATTR_AUTOCOMMIT,
+ (SQLPOINTER)((autoCommit) ? SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF) ,SQL_IS_INTEGER),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::getAutoCommit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ sal_uInt32 nOption = 0;
+ OTools::ThrowException(this,N3SQLGetConnectAttr(m_aConnectionHandle,
+ SQL_ATTR_AUTOCOMMIT, &nOption,0,0),m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+ return nOption == SQL_AUTOCOMMIT_ON ;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::commit( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_COMMIT),m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::rollback( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(this,N3SQLEndTran(SQL_HANDLE_DBC,m_aConnectionHandle,SQL_ROLLBACK),m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isClosed( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ return OConnection_BASE::rBHelper.bDisposed;
+}
+// --------------------------------------------------------------------------------
+Reference< XDatabaseMetaData > SAL_CALL OConnection::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ Reference< XDatabaseMetaData > xMetaData = m_xMetaData;
+ if(!xMetaData.is())
+ {
+ xMetaData = new ODatabaseMetaData(m_aConnectionHandle,this);
+ m_xMetaData = xMetaData;
+ }
+
+ return xMetaData;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setReadOnly( sal_Bool readOnly ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(this,
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_ACCESS_MODE,reinterpret_cast< SQLPOINTER >( readOnly ),SQL_IS_INTEGER),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL OConnection::isReadOnly() throw(SQLException, RuntimeException)
+{
+ // const member which will initialized only once
+ return m_bReadOnly;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setCatalog( const ::rtl::OUString& catalog ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ ::rtl::OString aCat(::rtl::OUStringToOString(catalog.getStr(),getTextEncoding()));
+ OTools::ThrowException(this,
+ N3SQLSetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,(SDB_ODBC_CHAR*)aCat.getStr(),SQL_NTS),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OConnection::getCatalog( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nValueLen;
+ char pCat[1024];
+ OTools::ThrowException(this,
+ N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_CURRENT_CATALOG,(SDB_ODBC_CHAR*)pCat,(sizeof pCat)-1,&nValueLen),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+
+ return ::rtl::OUString(pCat,nValueLen,getTextEncoding());
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTransactionIsolation( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(this,N3SQLSetConnectAttr(m_aConnectionHandle,
+ SQL_ATTR_TXN_ISOLATION,
+ (SQLPOINTER)level,SQL_IS_INTEGER),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL OConnection::getTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 nTxn = 0;
+ SQLINTEGER nValueLen;
+ OTools::ThrowException(this,
+ N3SQLGetConnectAttr(m_aConnectionHandle,SQL_ATTR_TXN_ISOLATION,&nTxn,sizeof nTxn,&nValueLen),
+ m_aConnectionHandle,SQL_HANDLE_DBC,*this);
+ return nTxn;
+}
+// --------------------------------------------------------------------------------
+Reference< ::com::sun::star::container::XNameAccess > SAL_CALL OConnection::getTypeMap( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+
+ return NULL;
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::setTypeMap( const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFeatureNotImplementedException( "XConnection::setTypeMap", *this );
+}
+// --------------------------------------------------------------------------------
+// XCloseable
+void SAL_CALL OConnection::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OConnection_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// --------------------------------------------------------------------------------
+// XWarningsSupplier
+Any SAL_CALL OConnection::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// --------------------------------------------------------------------------------
+void SAL_CALL OConnection::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+//--------------------------------------------------------------------
+void OConnection::buildTypeInfo() throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XResultSet> xRs = getMetaData ()->getTypeInfo ();
+ if(xRs.is())
+ {
+ Reference< XRow> xRow(xRs,UNO_QUERY);
+ // Information for a single SQL type
+
+ ::connectivity::ORowSetValue aValue;
+ ::std::vector<sal_Int32> aTypes;
+ Reference<XResultSetMetaData> xResultSetMetaData = Reference<XResultSetMetaDataSupplier>(xRs,UNO_QUERY)->getMetaData();
+ sal_Int32 nCount = xResultSetMetaData->getColumnCount();
+ // Loop on the result set until we reach end of file
+ while (xRs->next ())
+ {
+ OTypeInfo aInfo;
+ sal_Int32 nPos = 1;
+ if ( aTypes.empty() )
+ {
+ if ( nCount < 1 )
+ nCount = 18;
+ aTypes.reserve(nCount+1);
+ aTypes.push_back(-1);
+ for (sal_Int32 j = 1; j <= nCount ; ++j)
+ aTypes.push_back(xResultSetMetaData->getColumnType(j));
+ }
+
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.aTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nPrecision = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.aLiteralPrefix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.aLiteralSuffix = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.aCreateParams = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.bNullable = (sal_Int32)aValue == ColumnValue::NULLABLE;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.bCaseSensitive = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nSearchType = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.bUnsigned = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.bCurrency = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.bAutoIncrement = (sal_Bool)aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.aLocalTypeName = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nMinimumScale = aValue;
+ ++nPos;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nMaximumScale = aValue;
+ if ( nCount >= 18 )
+ {
+ nPos = 18;
+ aValue.fill(nPos,aTypes[nPos],xRow);
+ aInfo.nNumPrecRadix = aValue;
+ }
+
+ // check if values are less than zero like it happens in a oracle jdbc driver
+ if( aInfo.nPrecision < 0)
+ aInfo.nPrecision = 0;
+ if( aInfo.nMinimumScale < 0)
+ aInfo.nMinimumScale = 0;
+ if( aInfo.nMaximumScale < 0)
+ aInfo.nMaximumScale = 0;
+ if( aInfo.nNumPrecRadix < 0)
+ aInfo.nNumPrecRadix = 10;
+
+ // Now that we have the type info, save it
+ // in the Hashtable if we don't already have an
+ // entry for this SQL type.
+
+ m_aTypeInfo.push_back(aInfo);
+ }
+
+ // Close the result set/statement.
+
+ Reference< XCloseable> xClose(xRs,UNO_QUERY);
+ if(xClose.is())
+ xClose->close();
+ }
+}
+//------------------------------------------------------------------------------
+void OConnection::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ OConnection_BASE::disposing();
+
+ for (::std::map< SQLHANDLE,OConnection*>::iterator aConIter = m_aConnections.begin();aConIter != m_aConnections.end();++aConIter )
+ aConIter->second->dispose();
+
+ ::std::map< SQLHANDLE,OConnection*>().swap(m_aConnections);
+
+ if(!m_bClosed)
+ N3SQLDisconnect(m_aConnectionHandle);
+ m_bClosed = sal_True;
+
+ dispose_ChildImpl();
+}
+// -----------------------------------------------------------------------------
+OConnection* OConnection::cloneConnection()
+{
+ return new OConnection(m_pDriverHandleCopy,m_pDriver);
+}
+// -----------------------------------------------------------------------------
+SQLHANDLE OConnection::createStatementHandle()
+{
+ OConnection* pConnectionTemp = this;
+ sal_Bool bNew = sal_False;
+ try
+ {
+ sal_Int32 nMaxStatements = getMetaData()->getMaxStatements();
+ if(nMaxStatements && nMaxStatements <= m_nStatementCount)
+ {
+ OConnection* pConnection = cloneConnection();
+ pConnection->acquire();
+ pConnection->Construct(m_sURL,getConnectionInfo());
+ pConnectionTemp = pConnection;
+ bNew = sal_True;
+ }
+ }
+ catch(SQLException&)
+ {
+ }
+
+ SQLHANDLE aStatementHandle = SQL_NULL_HANDLE;
+ SQLRETURN nRetcode = N3SQLAllocHandle(SQL_HANDLE_STMT,pConnectionTemp->getConnection(),&aStatementHandle);
+ OSL_UNUSED( nRetcode );
+ ++m_nStatementCount;
+ if(bNew)
+ m_aConnections.insert(::std::map< SQLHANDLE,OConnection*>::value_type(aStatementHandle,pConnectionTemp));
+
+ return aStatementHandle;
+
+}
+// -----------------------------------------------------------------------------
+void OConnection::freeStatementHandle(SQLHANDLE& _pHandle)
+{
+ ::std::map< SQLHANDLE,OConnection*>::iterator aFind = m_aConnections.find(_pHandle);
+
+ N3SQLFreeStmt(_pHandle,SQL_RESET_PARAMS);
+ N3SQLFreeStmt(_pHandle,SQL_UNBIND);
+ N3SQLFreeStmt(_pHandle,SQL_CLOSE);
+ N3SQLFreeHandle(SQL_HANDLE_STMT,_pHandle);
+
+ _pHandle = SQL_NULL_HANDLE;
+
+ if(aFind != m_aConnections.end())
+ {
+ aFind->second->dispose();
+ m_aConnections.erase(aFind);
+ }
+ --m_nStatementCount;
+}
+// -----------------------------------------------------------------------------
+
+
+
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
new file mode 100644
index 000000000000..dc9349732084
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaData.cxx
@@ -0,0 +1,1743 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/ODatabaseMetaData.hxx"
+#include "odbc/OTools.hxx"
+#ifndef _CONNECTIVITY_ODBC_ORESULTSET_HXX_
+#include "odbc/ODatabaseMetaDataResultSet.hxx"
+#endif
+#include "FDatabaseMetaDataResultSet.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include "odbc/OFunctiondefs.hxx"
+#include "stdio.h"
+#include "TPrivilegesResultSet.hxx"
+#include <connectivity/dbexception.hxx>
+#include <rtl/ustrbuf.hxx>
+
+using namespace connectivity::odbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+
+ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon)
+ : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
+ ,m_aConnectionHandle(_pHandle)
+ ,m_pConnection(_pCon)
+ ,m_bUseCatalog(sal_True)
+ ,m_bOdbc3(sal_True)
+{
+ OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
+ if(!m_pConnection->isCatalogUsed())
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
+ ::rtl::OUString sVersion = getDriverVersion();
+ m_bOdbc3 = sVersion != ::rtl::OUString::createFromAscii("02.50") && sVersion != ::rtl::OUString::createFromAscii("02.00");
+ }
+ catch(SQLException& )
+ { // doesn't matter here
+ }
+ osl_decrementInterlockedCount( &m_refCount );
+ }
+}
+// -------------------------------------------------------------------------
+ODatabaseMetaData::~ODatabaseMetaData()
+{
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openTypeInfo();
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
+ }
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ if(!m_bUseCatalog)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
+ }
+ else
+ {
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openCatalogs();
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
+ }
+ }
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
+{
+ ::rtl::OUString aVal;
+ if ( m_bUseCatalog )
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_NAME_SEPARATOR,aVal,*this,m_pConnection->getTextEncoding());
+
+ return aVal;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openSchemas();
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eSchemas);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openColumnPrivileges(m_bUseCatalog ? catalog : Any(),schema,table,columnNamePattern);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumnPrivileges);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
+ const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,columnNamePattern);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openTables(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,types);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openProcedureColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern,columnNamePattern);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedureColumns);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
+ const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openProcedures(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedures);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ bool bSuccess = false;
+ try
+ {
+ if ( !m_pConnection->preventGetVersionColumns() )
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openVersionColumns(m_bUseCatalog ? catalog : Any(),schema,table);
+ bSuccess = true;
+ }
+ }
+ catch(SQLException&)
+ {
+ }
+
+ if ( !bSuccess )
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
+ }
+
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_BINARY_LITERAL_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CATALOG_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CHAR_LITERAL_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMN_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_INDEX,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CURSOR_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_DRIVER_CONNECTIONS/*SQL_ACTIVE_CONNECTIONS*/,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_TABLE,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_STATEMENT_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLE_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLES_IN_SELECT,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openExportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eExportedKeys);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openImportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eImportedKeys);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openPrimaryKeys(m_bUseCatalog ? catalog : Any(),schema,table);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::ePrimaryKeys);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
+ sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openIndexInfo(m_bUseCatalog ? catalog : Any(),schema,table,unique,approximate);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
+ const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
+ sal_Bool nullable ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openBestRowIdentifier(m_bUseCatalog ? catalog : Any(),schema,table,scope,nullable);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eBestRowIdentifier);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
+ const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
+{
+ if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
+ {
+ return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
+ }
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ Reference< XResultSet > xRef = pResult;
+ pResult->openTablePrivileges(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
+ const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
+ const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
+ const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
+{
+ Reference< XResultSet > xRef;
+ try
+ {
+ ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
+ xRef = pResult;
+ pResult->openForeignKeys(m_bUseCatalog ? primaryCatalog : Any(),primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable,
+ m_bUseCatalog ? foreignCatalog : Any(), foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable);
+ }
+ catch(SQLException&)
+ {
+ xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCrossReference);
+ }
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE_INCLUDES_LONG,aVal,*this,m_pConnection->getTextEncoding());
+ return aVal.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_LOWER;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_LOWER;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_UPPER;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_UPPER;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
+ return (nValue & SQL_AT_ADD_COLUMN) == SQL_AT_ADD_COLUMN;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
+ return ((nValue & SQL_AT_DROP_COLUMN) == SQL_AT_DROP_COLUMN) ||
+ ((nValue & SQL_AT_DROP_COLUMN_CASCADE) == SQL_AT_DROP_COLUMN_CASCADE) ||
+ ((nValue & SQL_AT_DROP_COLUMN_RESTRICT) == SQL_AT_DROP_COLUMN_RESTRICT);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_INDEX_SIZE,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NON_NULLABLE_COLUMNS,nValue,*this);
+ return nValue == SQL_NNC_NON_NULL;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_TERM,aVal,*this,m_pConnection->getTextEncoding());
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
+{
+ ::rtl::OUString aVal;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_QUOTE_CHAR,aVal,*this,m_pConnection->getTextEncoding());
+ return aVal;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aVal;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SPECIAL_CHARACTERS,aVal,*this,m_pConnection->getTextEncoding());
+ return aVal;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ return nValue != SQL_CN_NONE;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
+{
+ SQLUSMALLINT nValue=0;
+ if ( m_bUseCatalog )
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_LOCATION,nValue,*this);
+ return nValue == SQL_CL_START;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
+ return nValue == SQL_TC_DDL_IGNORE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
+ return nValue == SQL_TC_DDL_COMMIT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
+ return nValue == SQL_TC_DML;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
+ return nValue == SQL_TC_ALL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
+ return (nValue & SQL_CA1_POS_DELETE) == SQL_CA1_POS_DELETE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
+ return (nValue & SQL_CA1_POS_UPDATE) == SQL_CA1_POS_UPDATE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
+ return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
+ return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
+ return nValue == SQL_CB_PRESERVE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
+ return nValue == SQL_CB_PRESERVE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_ISOLATION_OPTION,nValue,*this);
+ return (nValue & static_cast<SQLUINTEGER>(level)) == static_cast<SQLUINTEGER>(level);
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
+ return (nValue & SQL_SU_DML_STATEMENTS) == SQL_SU_DML_STATEMENTS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
+ return nValue == SQL_SC_SQL92_FULL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
+ return nValue == SQL_SC_SQL92_ENTRY;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aStr;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_INTEGRITY,aStr,*this,m_pConnection->getTextEncoding());
+ return aStr.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
+ return (nValue & SQL_SU_INDEX_DEFINITION) == SQL_SU_INDEX_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
+ return (nValue & SQL_SU_TABLE_DEFINITION) == SQL_SU_TABLE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
+{
+ SQLUINTEGER nValue=0;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
+ return (nValue & SQL_CU_TABLE_DEFINITION) == SQL_CU_TABLE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue=0;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
+ return (nValue & SQL_CU_INDEX_DEFINITION) == SQL_CU_INDEX_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
+{
+ SQLUINTEGER nValue=0;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
+ return (nValue & SQL_CU_DML_STATEMENTS) == SQL_CU_DML_STATEMENTS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
+ return ((nValue & (SQL_OJ_FULL|SQL_OJ_LEFT|SQL_OJ_RIGHT|SQL_OJ_NESTED|SQL_OJ_NOT_ORDERED|SQL_OJ_ALL_COMPARISON_OPS|SQL_OJ_INNER)) != 0);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
+{
+
+ // there exists no possibility to get table types so we have to check
+ static ::rtl::OUString sTableTypes[] =
+ {
+ ::rtl::OUString::createFromAscii("TABLE"),
+ ::rtl::OUString::createFromAscii("VIEW"),
+ ::rtl::OUString::createFromAscii("SYSTEM TABLE"),
+ ::rtl::OUString::createFromAscii("GLOBAL TEMPORARY"),
+ ::rtl::OUString::createFromAscii("LOCAL TEMPORARY"),
+ ::rtl::OUString::createFromAscii("ALIAS"),
+ ::rtl::OUString::createFromAscii("SYNONYM")
+ };
+ sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
+ ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
+ Reference< XResultSet > xRef = pResult;
+ SQLUINTEGER nValue = 0;
+ try
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CREATE_VIEW,nValue,*this);
+ }
+ catch(const Exception&)
+ {
+ }
+ sal_Bool bViewsSupported = (nValue & SQL_CV_CREATE_VIEW) == SQL_CV_CREATE_VIEW;
+
+ ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
+ for(sal_Int32 i=0;i < nSize;++i)
+ {
+ if( !bViewsSupported && i == 1)
+ continue; // no views supported
+ ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
+ aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue());
+ aRow.push_back(new ::connectivity::ORowSetValueDecorator(sTableTypes[i]));
+ aRows.push_back(aRow);
+ }
+ pResult->setRows(aRows);
+ return xRef;
+}
+// -------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CONCURRENT_ACTIVITIES,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_PROCEDURE_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_SCHEMA_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
+ return nValue != SQL_TC_NONE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
+ return (nValue & SQL_CA1_POSITIONED_UPDATE) == SQL_CA1_POSITIONED_UPDATE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_TABLES,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
+{
+ return m_pConnection->isReadOnly();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
+ return nValue == SQL_FILE_CATALOG;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
+ return nValue == SQL_FILE_TABLE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FUNCTIONS,nValue,*this);
+ return (nValue & SQL_FN_CVT_CONVERT) == SQL_FN_CVT_CONVERT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONCAT_NULL_BEHAVIOR,nValue,*this);
+ return nValue == SQL_CB_NULL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_COLUMN_ALIAS,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ return nValue != SQL_CN_NONE;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException)
+{
+ if(fromType == toType)
+ return sal_True;
+
+ SQLUINTEGER nValue=0;
+ switch(fromType)
+ {
+ case DataType::BIT:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIT,nValue,*this);
+ break;
+ case DataType::TINYINT:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TINYINT,nValue,*this);
+ break;
+ case DataType::SMALLINT:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_SMALLINT,nValue,*this);
+ break;
+ case DataType::INTEGER:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_INTEGER,nValue,*this);
+ break;
+ case DataType::BIGINT:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIGINT,nValue,*this);
+ break;
+ case DataType::FLOAT:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FLOAT,nValue,*this);
+ break;
+ case DataType::REAL:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_REAL,nValue,*this);
+ break;
+ case DataType::DOUBLE:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DOUBLE,nValue,*this);
+ break;
+ case DataType::NUMERIC:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_NUMERIC,nValue,*this);
+ break;
+ case DataType::DECIMAL:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DECIMAL,nValue,*this);
+ break;
+ case DataType::CHAR:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_CHAR,nValue,*this);
+ break;
+ case DataType::VARCHAR:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this);
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this);
+ break;
+ case DataType::DATE:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DATE,nValue,*this);
+ break;
+ case DataType::TIME:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIME,nValue,*this);
+ break;
+ case DataType::TIMESTAMP:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIMESTAMP,nValue,*this);
+ break;
+ case DataType::BINARY:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BINARY,nValue,*this);
+ break;
+ case DataType::VARBINARY:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this);
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this);
+ break;
+ case DataType::SQLNULL:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::OTHER:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::OBJECT:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::DISTINCT:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::STRUCT:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::ARRAY:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ case DataType::REF:
+ // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
+ break;
+ }
+ sal_Bool bConvert = sal_False;
+ switch(toType)
+ {
+ case DataType::BIT:
+ bConvert = (nValue & SQL_CVT_BIT) == SQL_CVT_BIT;
+ break;
+ case DataType::TINYINT:
+ bConvert = (nValue & SQL_CVT_TINYINT) == SQL_CVT_TINYINT;
+ break;
+ case DataType::SMALLINT:
+ bConvert = (nValue & SQL_CVT_SMALLINT) == SQL_CVT_SMALLINT;
+ break;
+ case DataType::INTEGER:
+ bConvert = (nValue & SQL_CVT_INTEGER) == SQL_CVT_INTEGER;
+ break;
+ case DataType::BIGINT:
+ bConvert = (nValue & SQL_CVT_BIGINT) == SQL_CVT_BIGINT;
+ break;
+ case DataType::FLOAT:
+ bConvert = (nValue & SQL_CVT_FLOAT) == SQL_CVT_FLOAT;
+ break;
+ case DataType::REAL:
+ bConvert = (nValue & SQL_CVT_REAL) == SQL_CVT_REAL;
+ break;
+ case DataType::DOUBLE:
+ bConvert = (nValue & SQL_CVT_DOUBLE) == SQL_CVT_DOUBLE;
+ break;
+ case DataType::NUMERIC:
+ bConvert = (nValue & SQL_CVT_NUMERIC) == SQL_CVT_NUMERIC;
+ break;
+ case DataType::DECIMAL:
+ bConvert = (nValue & SQL_CVT_DECIMAL) == SQL_CVT_DECIMAL;
+ break;
+ case DataType::CHAR:
+ bConvert = (nValue & SQL_CVT_CHAR) == SQL_CVT_CHAR;
+ break;
+ case DataType::VARCHAR:
+ bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR;
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR;
+ break;
+ case DataType::DATE:
+ bConvert = (nValue & SQL_CVT_DATE) == SQL_CVT_DATE;
+ break;
+ case DataType::TIME:
+ bConvert = (nValue & SQL_CVT_TIME) == SQL_CVT_TIME;
+ break;
+ case DataType::TIMESTAMP:
+ bConvert = (nValue & SQL_CVT_TIMESTAMP) == SQL_CVT_TIMESTAMP;
+ break;
+ case DataType::BINARY:
+ bConvert = (nValue & SQL_CVT_BINARY) == SQL_CVT_BINARY;
+ break;
+ case DataType::VARBINARY:
+ bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY;
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY;
+ break;
+ }
+
+ return bConvert;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_EXPRESSIONS_IN_ORDERBY,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
+ return nValue != SQL_GB_NOT_SUPPORTED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
+ return nValue != SQL_GB_GROUP_BY_CONTAINS_SELECT;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
+ return nValue == SQL_GB_NO_RELATION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULTIPLE_ACTIVE_TXN,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULT_RESULT_SETS,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_LIKE_ESCAPE_CLAUSE,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'Y';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ORDER_BY_COLUMNS_IN_SELECT,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.toChar() == 'N';
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
+ return (nValue & SQL_U_UNION) == SQL_U_UNION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
+ return (nValue & SQL_U_UNION_ALL) == SQL_U_UNION_ALL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
+ return nValue == SQL_IC_MIXED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
+ return nValue == SQL_NC_END;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
+ return nValue == SQL_NC_START;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
+ return nValue == SQL_NC_HIGH;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
+ return nValue == SQL_NC_LOW;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
+ return (nValue & SQL_SU_PROCEDURE_INVOCATION) == SQL_SU_PROCEDURE_INVOCATION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
+ return (nValue & SQL_SU_PRIVILEGE_DEFINITION) == SQL_SU_PRIVILEGE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue=0;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
+ return (nValue & SQL_CU_PROCEDURE_INVOCATION) == SQL_CU_PROCEDURE_INVOCATION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue=0;
+ if(m_bUseCatalog)
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
+ return (nValue & SQL_CU_PRIVILEGE_DEFINITION) == SQL_CU_PRIVILEGE_DEFINITION;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return (nValue & SQL_SQ_CORRELATED_SUBQUERIES) == SQL_SQ_CORRELATED_SUBQUERIES;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return (nValue & SQL_SQ_COMPARISON) == SQL_SQ_COMPARISON;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return (nValue & SQL_SQ_EXISTS) == SQL_SQ_EXISTS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return (nValue & SQL_SQ_IN) == SQL_SQ_IN;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return (nValue & SQL_SQ_QUANTIFIED) == SQL_SQ_QUANTIFIED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
+ return nValue == SQL_SC_SQL92_INTERMEDIATE;
+}
+// -----------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaData::getURLImpl()
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_NAME,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue = m_pConnection->getURL();
+ if ( !aValue.getLength() )
+ {
+ aValue = ::rtl::OUString::createFromAscii("sdbc:odbc:");
+ aValue += getURLImpl();
+ }
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_USER_NAME,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_NAME,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_ODBC_VER,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DBMS_NAME,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURE_TERM,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_TERM,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.copy(0,aValue.indexOf('.')).toInt32();
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue.copy(0,aValue.lastIndexOf('.')).toInt32();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_KEYWORDS,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OUString aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SEARCH_PATTERN_ESCAPE,aValue,*this,m_pConnection->getTextEncoding());
+ return aValue;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ ::rtl::OUStringBuffer aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
+ if(nValue & SQL_FN_STR_ASCII)
+ aValue.appendAscii("ASCII,");
+ if(nValue & SQL_FN_STR_BIT_LENGTH)
+ aValue.appendAscii("BIT_LENGTH,");
+ if(nValue & SQL_FN_STR_CHAR)
+ aValue.appendAscii("CHAR,");
+ if(nValue & SQL_FN_STR_CHAR_LENGTH)
+ aValue.appendAscii("CHAR_LENGTH,");
+ if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
+ aValue.appendAscii("CHARACTER_LENGTH,");
+ if(nValue & SQL_FN_STR_CONCAT)
+ aValue.appendAscii("CONCAT,");
+ if(nValue & SQL_FN_STR_DIFFERENCE)
+ aValue.appendAscii("DIFFERENCE,");
+ if(nValue & SQL_FN_STR_INSERT)
+ aValue.appendAscii("INSERT,");
+ if(nValue & SQL_FN_STR_LCASE)
+ aValue.appendAscii("LCASE,");
+ if(nValue & SQL_FN_STR_LEFT)
+ aValue.appendAscii("LEFT,");
+ if(nValue & SQL_FN_STR_LENGTH)
+ aValue.appendAscii("LENGTH,");
+ if(nValue & SQL_FN_STR_LOCATE)
+ aValue.appendAscii("LOCATE,");
+ if(nValue & SQL_FN_STR_LOCATE_2)
+ aValue.appendAscii("LOCATE_2,");
+ if(nValue & SQL_FN_STR_LTRIM)
+ aValue.appendAscii("LTRIM,");
+ if(nValue & SQL_FN_STR_OCTET_LENGTH)
+ aValue.appendAscii("OCTET_LENGTH,");
+ if(nValue & SQL_FN_STR_POSITION)
+ aValue.appendAscii("POSITION,");
+ if(nValue & SQL_FN_STR_REPEAT)
+ aValue.appendAscii("REPEAT,");
+ if(nValue & SQL_FN_STR_REPLACE)
+ aValue.appendAscii("REPLACE,");
+ if(nValue & SQL_FN_STR_RIGHT)
+ aValue.appendAscii("RIGHT,");
+ if(nValue & SQL_FN_STR_RTRIM)
+ aValue.appendAscii("RTRIM,");
+ if(nValue & SQL_FN_STR_SOUNDEX)
+ aValue.appendAscii("SOUNDEX,");
+ if(nValue & SQL_FN_STR_SPACE)
+ aValue.appendAscii("SPACE,");
+ if(nValue & SQL_FN_STR_SUBSTRING)
+ aValue.appendAscii("SUBSTRING,");
+ if(nValue & SQL_FN_STR_UCASE)
+ aValue.appendAscii("UCASE,");
+
+
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ ::rtl::OUStringBuffer aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this);
+
+ if(nValue & SQL_FN_TD_CURRENT_DATE)
+ aValue.appendAscii("CURRENT_DATE,");
+ if(nValue & SQL_FN_TD_CURRENT_TIME)
+ aValue.appendAscii("CURRENT_TIME,");
+ if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP)
+ aValue.appendAscii("CURRENT_TIMESTAMP,");
+ if(nValue & SQL_FN_TD_CURDATE)
+ aValue.appendAscii("CURDATE,");
+ if(nValue & SQL_FN_TD_CURTIME)
+ aValue.appendAscii("CURTIME,");
+ if(nValue & SQL_FN_TD_DAYNAME)
+ aValue.appendAscii("DAYNAME,");
+ if(nValue & SQL_FN_TD_DAYOFMONTH)
+ aValue.appendAscii("DAYOFMONTH,");
+ if(nValue & SQL_FN_TD_DAYOFWEEK)
+ aValue.appendAscii("DAYOFWEEK,");
+ if(nValue & SQL_FN_TD_DAYOFYEAR)
+ aValue.appendAscii("DAYOFYEAR,");
+ if(nValue & SQL_FN_TD_EXTRACT)
+ aValue.appendAscii("EXTRACT,");
+ if(nValue & SQL_FN_TD_HOUR)
+ aValue.appendAscii("HOUR,");
+ if(nValue & SQL_FN_TD_MINUTE)
+ aValue.appendAscii("MINUTE,");
+ if(nValue & SQL_FN_TD_MONTH)
+ aValue.appendAscii("MONTH,");
+ if(nValue & SQL_FN_TD_MONTHNAME)
+ aValue.appendAscii("MONTHNAME,");
+ if(nValue & SQL_FN_TD_NOW)
+ aValue.appendAscii("NOW,");
+ if(nValue & SQL_FN_TD_QUARTER)
+ aValue.appendAscii("QUARTER,");
+ if(nValue & SQL_FN_TD_SECOND)
+ aValue.appendAscii("SECOND,");
+ if(nValue & SQL_FN_TD_TIMESTAMPADD)
+ aValue.appendAscii("TIMESTAMPADD,");
+ if(nValue & SQL_FN_TD_TIMESTAMPDIFF)
+ aValue.appendAscii("TIMESTAMPDIFF,");
+ if(nValue & SQL_FN_TD_WEEK)
+ aValue.appendAscii("WEEK,");
+ if(nValue & SQL_FN_TD_YEAR)
+ aValue.appendAscii("YEAR,");
+
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ ::rtl::OUStringBuffer aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this);
+
+ if(nValue & SQL_FN_SYS_DBNAME)
+ aValue.appendAscii("DBNAME,");
+ if(nValue & SQL_FN_SYS_IFNULL)
+ aValue.appendAscii("IFNULL,");
+ if(nValue & SQL_FN_SYS_USERNAME)
+ aValue.appendAscii("USERNAME,");
+
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ ::rtl::OUStringBuffer aValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this);
+
+ if(nValue & SQL_FN_NUM_ABS)
+ aValue.appendAscii("ABS,");
+ if(nValue & SQL_FN_NUM_ACOS)
+ aValue.appendAscii("ACOS,");
+ if(nValue & SQL_FN_NUM_ASIN)
+ aValue.appendAscii("ASIN,");
+ if(nValue & SQL_FN_NUM_ATAN)
+ aValue.appendAscii("ATAN,");
+ if(nValue & SQL_FN_NUM_ATAN2)
+ aValue.appendAscii("ATAN2,");
+ if(nValue & SQL_FN_NUM_CEILING)
+ aValue.appendAscii("CEILING,");
+ if(nValue & SQL_FN_NUM_COS)
+ aValue.appendAscii("COS,");
+ if(nValue & SQL_FN_NUM_COT)
+ aValue.appendAscii("COT,");
+ if(nValue & SQL_FN_NUM_DEGREES)
+ aValue.appendAscii("DEGREES,");
+ if(nValue & SQL_FN_NUM_EXP)
+ aValue.appendAscii("EXP,");
+ if(nValue & SQL_FN_NUM_FLOOR)
+ aValue.appendAscii("FLOOR,");
+ if(nValue & SQL_FN_NUM_LOG)
+ aValue.appendAscii("LOGF,");
+ if(nValue & SQL_FN_NUM_LOG10)
+ aValue.appendAscii("LOG10,");
+ if(nValue & SQL_FN_NUM_MOD)
+ aValue.appendAscii("MOD,");
+ if(nValue & SQL_FN_NUM_PI)
+ aValue.appendAscii("PI,");
+ if(nValue & SQL_FN_NUM_POWER)
+ aValue.appendAscii("POWER,");
+ if(nValue & SQL_FN_NUM_RADIANS)
+ aValue.appendAscii("RADIANS,");
+ if(nValue & SQL_FN_NUM_RAND)
+ aValue.appendAscii("RAND,");
+ if(nValue & SQL_FN_NUM_ROUND)
+ aValue.appendAscii("ROUND,");
+ if(nValue & SQL_FN_NUM_SIGN)
+ aValue.appendAscii("SIGN,");
+ if(nValue & SQL_FN_NUM_SIN)
+ aValue.appendAscii("SIN,");
+ if(nValue & SQL_FN_NUM_SQRT)
+ aValue.appendAscii("SQRT,");
+ if(nValue & SQL_FN_NUM_TAN)
+ aValue.appendAscii("TAN,");
+ if(nValue & SQL_FN_NUM_TRUNCATE)
+ aValue.appendAscii("TRUNCATE,");
+
+ if ( aValue.getLength() )
+ aValue.setLength(aValue.getLength()-1);
+
+ return aValue.makeStringAndClear();
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ if(m_bOdbc3)
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OIC_LEVEL2;
+ }
+ else
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OAC_LEVEL2;
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ if(m_bOdbc3)
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OIC_CORE || nValue == SQL_OIC_LEVEL2 || nValue == SQL_OIC_LEVEL1;
+ }
+ else
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OSC_CORE || nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ if(m_bOdbc3)
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OIC_LEVEL1 || nValue == SQL_OIC_LEVEL2;
+ }
+ else
+ {
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
+ return nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
+ }
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
+ return (nValue & SQL_OJ_FULL) == SQL_OJ_FULL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
+{
+ return supportsFullOuterJoins( );
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_GROUP_BY,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_ORDER_BY,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_SELECT,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
+{
+ SQLUSMALLINT nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_USER_NAME_LEN,nValue,*this);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_SENSITIVITY,nValue,*this);
+ return (nValue & static_cast<SQLUINTEGER>(setType)) == static_cast<SQLUINTEGER>(setType);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
+ switch(setType)
+ {
+ default:
+ case ResultSetType::FORWARD_ONLY:
+ nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
+ break;
+ }
+
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
+ sal_Bool bRet = sal_False;
+ switch(concurrency)
+ {
+ case ResultSetConcurrency::READ_ONLY:
+ bRet = (nValue & SQL_CA2_READ_ONLY_CONCURRENCY) == SQL_CA2_READ_ONLY_CONCURRENCY;
+ break;
+ case ResultSetConcurrency::UPDATABLE:
+ bRet = (nValue & SQL_CA2_OPT_VALUES_CONCURRENCY) == SQL_CA2_OPT_VALUES_CONCURRENCY;
+ break;
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
+ switch(setType)
+ {
+ default:
+ case ResultSetType::FORWARD_ONLY:
+ nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
+ break;
+ }
+
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
+ return (nValue & SQL_CA2_SENSITIVITY_UPDATES) == SQL_CA2_SENSITIVITY_UPDATES;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
+ switch(setType)
+ {
+ default:
+ case ResultSetType::FORWARD_ONLY:
+ nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
+ break;
+ }
+
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
+ return (nValue & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ SQLUINTEGER nValue;
+ SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
+ switch(setType)
+ {
+ default:
+ case ResultSetType::FORWARD_ONLY:
+ nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
+ break;
+ }
+
+ OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
+ return (nValue & SQL_CA2_SENSITIVITY_ADDITIONS) == SQL_CA2_SENSITIVITY_ADDITIONS;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ownUpdatesAreVisible(setType);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ownDeletesAreVisible(setType);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
+{
+ return ownInsertsAreVisible(setType);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
new file mode 100644
index 000000000000..751ab7cf2988
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/ODatabaseMetaDataResultSet.cxx
@@ -0,0 +1,1323 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "TConnection.hxx"
+
+#ifndef _CONNECTIVITY_ADO_ADATABASEMETADATARESULTSET_HXX_
+#include "odbc/ODatabaseMetaDataResultSet.hxx"
+#endif
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/sdbc/KeyRule.hpp>
+#include <com/sun/star/sdbc/ProcedureResult.hpp>
+#include <com/sun/star/sdbc/IndexType.hpp>
+#include <comphelper/property.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include "odbc/OResultSetMetaData.hxx"
+#include "odbc/OTools.hxx"
+#include <comphelper/types.hxx>
+#include "FDatabaseMetaDataResultSetMetaData.hxx"
+#include <connectivity/dbexception.hxx>
+
+using namespace ::comphelper;
+
+
+using namespace connectivity::odbc;
+using namespace cppu;
+//------------------------------------------------------------------------------
+using namespace ::com::sun::star::lang;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet(OConnection* _pConnection)
+ :ODatabaseMetaDataResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(ODatabaseMetaDataResultSet_BASE::rBHelper)
+
+ ,m_aStatementHandle(_pConnection->createStatementHandle())
+ ,m_aStatement(NULL)
+ ,m_xMetaData(NULL)
+ ,m_pRowStatusArray(NULL)
+ ,m_pConnection(_pConnection)
+ ,m_nTextEncoding(_pConnection->getTextEncoding())
+ ,m_nRowPos(-1)
+ ,m_nLastColumnPos(0)
+ ,m_nDriverColumnCount(0)
+ ,m_nCurrentFetchState(0)
+ ,m_bWasNull(sal_True)
+ ,m_bEOF(sal_False)
+ ,m_bFreeHandle(sal_False)
+{
+ OSL_ENSURE(m_pConnection,"ODatabaseMetaDataResultSet::ODatabaseMetaDataResultSet: No parent set!");
+ osl_incrementInterlockedCount( &m_refCount );
+ m_pConnection->acquire();
+ m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
+ osl_decrementInterlockedCount( &m_refCount );
+ // allocBuffer();
+}
+
+// -------------------------------------------------------------------------
+ODatabaseMetaDataResultSet::~ODatabaseMetaDataResultSet()
+{
+ OSL_ENSURE(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed,"Object wasn't disposed!");
+ if(!ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed)
+ {
+ osl_incrementInterlockedCount( &m_refCount );
+ dispose();
+ }
+ delete [] m_pRowStatusArray;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::disposing(void)
+{
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if(m_bFreeHandle)
+ m_pConnection->freeStatementHandle(m_aStatementHandle);
+
+ m_aStatement = NULL;
+m_xMetaData.clear();
+ m_pConnection->release();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : ODatabaseMetaDataResultSet_BASE::queryInterface(rType);
+}
+// -----------------------------------------------------------------------------
+Reference< XPropertySetInfo > SAL_CALL ODatabaseMetaDataResultSet::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::acquire() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::release() throw()
+{
+ ODatabaseMetaDataResultSet_BASE::release();
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL ODatabaseMetaDataResultSet::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),ODatabaseMetaDataResultSet_BASE::getTypes());
+}
+// -----------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::mapColumn (sal_Int32 column)
+{
+ sal_Int32 map = column;
+
+ if (!m_aColMapping.empty())
+ {
+ // Validate column number
+ map = m_aColMapping[column];
+ }
+
+ return map;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBinaryStream", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< ::com::sun::star::io::XInputStream > SAL_CALL ODatabaseMetaDataResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getCharacterStream", *this );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ columnIndex = mapColumn(columnIndex);
+
+ sal_Bool bRet = sal_False;
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
+ switch(nType)
+ {
+ case DataType::BIT:
+ {
+ sal_Int8 nValue = 0;
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BIT,m_bWasNull,**this,&nValue,sizeof nValue);
+ bRet = nValue != 0;
+ }
+ break;
+ default:
+ bRet = getInt(columnIndex) != 0;
+ }
+ }
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL ODatabaseMetaDataResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ sal_Int8 nVal = 0;
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_TINYINT,m_bWasNull,**this,&nVal,sizeof nVal);
+
+ ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
+ if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return sal_Int8((*aValueRangeIter).second[(sal_Int32)nVal]);
+ }
+ else
+ m_bWasNull = sal_True;
+ return nVal;
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL ODatabaseMetaDataResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ sal_Int32 nType = getMetaData()->getColumnType(columnIndex);
+ switch(nType)
+ {
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ {
+ ::rtl::OUString aRet = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this,m_nTextEncoding);
+ return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
+ }
+ }
+ return OTools::getBytesValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
+ }
+ else
+ m_bWasNull = sal_True;
+ return Sequence<sal_Int8>();
+}
+// -------------------------------------------------------------------------
+
+::com::sun::star::util::Date SAL_CALL ODatabaseMetaDataResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ DATE_STRUCT aDate;
+ aDate.day = 0;
+ aDate.month = 0;
+ aDate.year = 0;
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,m_bWasNull,**this,&aDate,sizeof aDate);
+ return Date(aDate.day,aDate.month,aDate.year);
+ }
+ else
+ m_bWasNull = sal_True;
+ return Date();
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL ODatabaseMetaDataResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ double nValue(0.0);
+ if(columnIndex <= m_nDriverColumnCount)
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_DOUBLE,m_bWasNull,**this,&nValue,sizeof nValue);
+ else
+ m_bWasNull = sal_True;
+ return nValue;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL ODatabaseMetaDataResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ float nVal(0);
+ if(columnIndex <= m_nDriverColumnCount)
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_FLOAT,m_bWasNull,**this,&nVal,sizeof nVal);
+ else
+ m_bWasNull = sal_True;
+ return nVal;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ sal_Int32 nVal = 0;
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_LONG,m_bWasNull,**this,&nVal,sizeof nVal);
+
+ ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
+ if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return (*aValueRangeIter).second[(sal_Int32)nVal];
+ }
+ else
+ m_bWasNull = sal_True;
+ return nVal;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL ODatabaseMetaDataResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL ODatabaseMetaDataResultSet::getLong( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getLong", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL ODatabaseMetaDataResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+ return m_xMetaData.is() ? m_xMetaData : (m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle));
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL ODatabaseMetaDataResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XClob > SAL_CALL ODatabaseMetaDataResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL ODatabaseMetaDataResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL ODatabaseMetaDataResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL ODatabaseMetaDataResultSet::getObject( sal_Int32 /*columnIndex*/, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getObject", *this );
+ return Any();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL ODatabaseMetaDataResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ columnIndex = mapColumn(columnIndex);
+ sal_Int16 nVal = 0;
+ if(columnIndex <= m_nDriverColumnCount)
+ {
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,SQL_C_SHORT,m_bWasNull,**this,&nVal,sizeof nVal);
+
+ ::std::map<sal_Int32, ::connectivity::TInt2IntMap >::iterator aValueRangeIter;
+ if ( !m_aValueRange.empty() && (aValueRangeIter = m_aValueRange.find(columnIndex)) != m_aValueRange.end())
+ return sal_Int16((*aValueRangeIter).second[(sal_Int32)nVal]);
+ }
+ else
+ m_bWasNull = sal_True;
+ return nVal;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL ODatabaseMetaDataResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ ::rtl::OUString aVal;
+ if(columnIndex <= m_nDriverColumnCount)
+ aVal = OTools::getStringValue(m_pConnection,m_aStatementHandle,columnIndex,impl_getColumnType_nothrow(columnIndex),m_bWasNull,**this,m_nTextEncoding);
+ else
+ m_bWasNull = sal_True;
+
+ return aVal;
+}
+
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::Time SAL_CALL ODatabaseMetaDataResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ TIME_STRUCT aTime={0,0,0};
+ if(columnIndex <= m_nDriverColumnCount)
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,m_bWasNull,**this,&aTime,sizeof aTime);
+ else
+ m_bWasNull = sal_True;
+ return Time(0,aTime.second,aTime.minute,aTime.hour);
+}
+// -------------------------------------------------------------------------
+
+
+::com::sun::star::util::DateTime SAL_CALL ODatabaseMetaDataResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ columnIndex = mapColumn(columnIndex);
+ TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
+ if(columnIndex <= m_nDriverColumnCount)
+ OTools::getValue(m_pConnection,m_aStatementHandle,columnIndex,m_pConnection->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,m_bWasNull,**this,&aTime,sizeof aTime);
+ else
+ m_bWasNull = sal_True;
+ return DateTime((sal_uInt16)aTime.fraction*1000,aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_nCurrentFetchState == SQL_NO_DATA;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ if(first())
+ previous();
+ m_nCurrentFetchState = SQL_SUCCESS;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL ODatabaseMetaDataResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::first( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_FIRST,0);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ sal_Bool bRet = ( m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO );
+ if( bRet )
+ m_nRowPos = 1;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_LAST,0);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ // here I know definitely that I stand on the last record
+ return (m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_ABSOLUTE,row);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ m_nRowPos = row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,row);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ m_nRowPos += row;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_PRIOR,0);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ sal_Bool bRet = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if(bRet)
+ --m_nRowPos;
+ return bRet;
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL ODatabaseMetaDataResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowDeleted( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_pRowStatusArray[0] == SQL_ROW_DELETED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_pRowStatusArray[0] == SQL_ROW_ADDED;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_nRowPos == 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::next( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ // m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_NEXT,0);
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ OTools::ThrowException(m_pConnection,m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL ODatabaseMetaDataResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ return m_bWasNull;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL ODatabaseMetaDataResultSet::cancel( ) throw(RuntimeException)
+{
+
+ checkDisposed(ODatabaseMetaDataResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL ODatabaseMetaDataResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL ODatabaseMetaDataResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getResultSetConcurrency() const throw(SQLException, RuntimeException)
+{
+ return ResultSetConcurrency::READ_ONLY;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getResultSetType() const throw(SQLException, RuntimeException)
+{
+ return ResultSetType::FORWARD_ONLY;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getFetchDirection() const throw(SQLException, RuntimeException)
+{
+ return FetchDirection::FORWARD;
+}
+//------------------------------------------------------------------------------
+sal_Int32 ODatabaseMetaDataResultSet::getFetchSize() const throw(SQLException, RuntimeException)
+{
+ sal_Int32 nValue=1;
+ return nValue;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString ODatabaseMetaDataResultSet::getCursorName() const throw(SQLException, RuntimeException)
+{
+ return ::rtl::OUString();
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* ODatabaseMetaDataResultSet::createArrayHelper( ) const
+{
+
+ Sequence< com::sun::star::beans::Property > aProps(5);
+ com::sun::star::beans::Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE, sal_Int32);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & ODatabaseMetaDataResultSet::getInfoHelper()
+{
+ return *const_cast<ODatabaseMetaDataResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool ODatabaseMetaDataResultSet::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ case PROPERTY_ID_FETCHDIRECTION:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ case PROPERTY_ID_FETCHSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& /*rValue*/ ) throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ case PROPERTY_ID_FETCHDIRECTION:
+ case PROPERTY_ID_FETCHSIZE:
+ throw Exception();
+ default:
+ OSL_ENSURE(0,"setFastPropertyValue_NoBroadcast: Illegal handle value!");
+ }
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openTypeInfo() throw(SQLException, RuntimeException)
+{
+ TInt2IntMap aMap;
+ aMap[SQL_BIT] = DataType::BIT;
+ aMap[SQL_TINYINT] = DataType::TINYINT;
+ aMap[SQL_SMALLINT] = DataType::SMALLINT;
+ aMap[SQL_INTEGER] = DataType::INTEGER;
+ aMap[SQL_FLOAT] = DataType::FLOAT;
+ aMap[SQL_REAL] = DataType::REAL;
+ aMap[SQL_DOUBLE] = DataType::DOUBLE;
+ aMap[SQL_BIGINT] = DataType::BIGINT;
+
+ aMap[SQL_CHAR] = DataType::CHAR;
+ aMap[SQL_WCHAR] = DataType::CHAR;
+ aMap[SQL_VARCHAR] = DataType::VARCHAR;
+ aMap[SQL_WVARCHAR] = DataType::VARCHAR;
+ aMap[SQL_LONGVARCHAR] = DataType::LONGVARCHAR;
+ aMap[SQL_WLONGVARCHAR] = DataType::LONGVARCHAR;
+
+ aMap[SQL_TYPE_DATE] = DataType::DATE;
+ aMap[SQL_DATE] = DataType::DATE;
+ aMap[SQL_TYPE_TIME] = DataType::TIME;
+ aMap[SQL_TIME] = DataType::TIME;
+ aMap[SQL_TYPE_TIMESTAMP] = DataType::TIMESTAMP;
+ aMap[SQL_TIMESTAMP] = DataType::TIMESTAMP;
+
+ aMap[SQL_DECIMAL] = DataType::DECIMAL;
+ aMap[SQL_NUMERIC] = DataType::NUMERIC;
+
+ aMap[SQL_BINARY] = DataType::BINARY;
+ aMap[SQL_VARBINARY] = DataType::VARBINARY;
+ aMap[SQL_LONGVARBINARY] = DataType::LONGVARBINARY;
+
+ aMap[SQL_GUID] = DataType::VARBINARY;
+
+
+ m_aValueRange[2] = aMap;
+
+ OTools::ThrowException(m_pConnection,N3SQLGetTypeInfo(m_aStatementHandle, SQL_ALL_TYPES),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+//-----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openTables(const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern,
+ const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
+{
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schemaPattern.toChar() != '%')
+ pSchemaPat = &schemaPattern;
+ else
+ pSchemaPat = NULL;
+
+ if ( catalog.hasValue() )
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding).getStr();
+
+
+ const char *pCOL = NULL;
+ const char* pComma = ",";
+ const ::rtl::OUString* pBegin = types.getConstArray();
+ const ::rtl::OUString* pEnd = pBegin + types.getLength();
+ for(;pBegin != pEnd;++pBegin)
+ {
+ aCOL += ::rtl::OUStringToOString(*pBegin,m_nTextEncoding);
+ aCOL += pComma;
+ }
+ if ( aCOL.getLength() )
+ {
+ aCOL = aCOL.replaceAt(aCOL.getLength()-1,1,pComma);
+ pCOL = aCOL.getStr();
+ }
+ else
+ pCOL = SQL_ALL_TABLE_TYPES;
+
+ SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ (SDB_ODBC_CHAR *) pCOL, pCOL ? SQL_NTS : 0);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+
+}
+//-----------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openTablesTypes( ) throw(SQLException, RuntimeException)
+{
+ m_bFreeHandle = sal_True;
+ SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
+ 0,0,
+ 0,0,
+ 0,0,
+ (SDB_ODBC_CHAR *) SQL_ALL_TABLE_TYPES,SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ m_aColMapping.clear();
+ m_aColMapping.push_back(-1);
+ m_aColMapping.push_back(4);
+ m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openCatalogs() throw(SQLException, RuntimeException)
+{
+ m_bFreeHandle = sal_True;
+ SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) SQL_ALL_CATALOGS,SQL_NTS,
+ (SDB_ODBC_CHAR *) "",SQL_NTS,
+ (SDB_ODBC_CHAR *) "",SQL_NTS,
+ (SDB_ODBC_CHAR *) "",SQL_NTS);
+
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ m_aColMapping.clear();
+ m_aColMapping.push_back(-1);
+ m_aColMapping.push_back(1);
+ m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openSchemas() throw(SQLException, RuntimeException)
+{
+ m_bFreeHandle = sal_True;
+ SQLRETURN nRetcode = N3SQLTables(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) "",SQL_NTS,
+ (SDB_ODBC_CHAR *) SQL_ALL_SCHEMAS,SQL_NTS,
+ (SDB_ODBC_CHAR *) "",SQL_NTS,
+ (SDB_ODBC_CHAR *) "",SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ m_aColMapping.clear();
+ m_aColMapping.push_back(-1);
+ m_aColMapping.push_back(2);
+ m_xMetaData = new OResultSetMetaData(m_pConnection,m_aStatementHandle,m_aColMapping);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openColumnPrivileges( const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table, const ::rtl::OUString& columnNamePattern )
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schema.toChar() != '%')
+ pSchemaPat = &schema;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding).getStr(),
+ *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLColumnPrivileges(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openColumns( const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern, const ::rtl::OUString& columnNamePattern )
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schemaPattern.toChar() != '%')
+ pSchemaPat = &schemaPattern;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding).getStr(),
+ *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLColumns(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
+
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ TInt2IntMap aMap;
+ aMap[SQL_BIT] = DataType::BIT;
+ aMap[SQL_TINYINT] = DataType::TINYINT;
+ aMap[SQL_SMALLINT] = DataType::SMALLINT;
+ aMap[SQL_INTEGER] = DataType::INTEGER;
+ aMap[SQL_FLOAT] = DataType::FLOAT;
+ aMap[SQL_REAL] = DataType::REAL;
+ aMap[SQL_DOUBLE] = DataType::DOUBLE;
+ aMap[SQL_BIGINT] = DataType::BIGINT;
+
+ aMap[SQL_CHAR] = DataType::CHAR;
+ aMap[SQL_WCHAR] = DataType::CHAR;
+ aMap[SQL_VARCHAR] = DataType::VARCHAR;
+ aMap[SQL_WVARCHAR] = DataType::VARCHAR;
+ aMap[SQL_LONGVARCHAR] = DataType::LONGVARCHAR;
+ aMap[SQL_WLONGVARCHAR] = DataType::LONGVARCHAR;
+
+ aMap[SQL_TYPE_DATE] = DataType::DATE;
+ aMap[SQL_DATE] = DataType::DATE;
+ aMap[SQL_TYPE_TIME] = DataType::TIME;
+ aMap[SQL_TIME] = DataType::TIME;
+ aMap[SQL_TYPE_TIMESTAMP] = DataType::TIMESTAMP;
+ aMap[SQL_TIMESTAMP] = DataType::TIMESTAMP;
+
+ aMap[SQL_DECIMAL] = DataType::DECIMAL;
+ aMap[SQL_NUMERIC] = DataType::NUMERIC;
+
+ aMap[SQL_BINARY] = DataType::BINARY;
+ aMap[SQL_VARBINARY] = DataType::VARBINARY;
+ aMap[SQL_LONGVARBINARY] = DataType::LONGVARBINARY;
+
+ aMap[SQL_GUID] = DataType::VARBINARY;
+
+ m_aValueRange[5] = aMap;
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openProcedureColumns( const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern,const ::rtl::OUString& columnNamePattern )
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schemaPattern.toChar() != '%')
+ pSchemaPat = &schemaPattern;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding).getStr(),
+ *pCOL = aCOL = ::rtl::OUStringToOString(columnNamePattern,m_nTextEncoding).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLProcedureColumns(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ (SDB_ODBC_CHAR *) pCOL, SQL_NTS);
+
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openProcedures(const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& procedureNamePattern)
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schemaPattern.toChar() != '%')
+ pSchemaPat = &schemaPattern;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(procedureNamePattern,m_nTextEncoding).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLProcedures(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openSpecialColumns(sal_Bool _bRowVer,const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table,sal_Int32 scope, sal_Bool nullable )
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schema.toChar() != '%')
+ pSchemaPat = &schema;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLSpecialColumns(m_aStatementHandle,_bRowVer ? SQL_ROWVER : SQL_BEST_ROWID,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ (SQLSMALLINT)scope,
+ nullable ? SQL_NULLABLE : SQL_NO_NULLS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openVersionColumns(const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table) throw(SQLException, RuntimeException)
+{
+ openSpecialColumns(sal_True,catalog,schema,table,SQL_SCOPE_TRANSACTION,sal_False);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openBestRowIdentifier( const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table,sal_Int32 scope,sal_Bool nullable ) throw(SQLException, RuntimeException)
+{
+ openSpecialColumns(sal_False,catalog,schema,table,scope,nullable);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openForeignKeys( const Any& catalog, const ::rtl::OUString* schema,
+ const ::rtl::OUString* table,
+ const Any& catalog2, const ::rtl::OUString* schema2,
+ const ::rtl::OUString* table2) throw(SQLException, RuntimeException)
+{
+ m_bFreeHandle = sal_True;
+
+ ::rtl::OString aPKQ,aPKO,aPKN, aFKQ, aFKO, aFKN;
+ if ( catalog.hasValue() )
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ if ( catalog2.hasValue() )
+ aFKQ = ::rtl::OUStringToOString(comphelper::getString(catalog2),m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = schema && schema->getLength() ? ::rtl::OUStringToOString(*schema,m_nTextEncoding).getStr() : NULL,
+ *pPKN = table ? (aPKN = ::rtl::OUStringToOString(*table,m_nTextEncoding)).getStr(): NULL,
+ *pFKQ = catalog2.hasValue() && aFKQ.getLength() ? aFKQ.getStr() : NULL,
+ *pFKO = schema2 && schema2->getLength() ? (aFKO = ::rtl::OUStringToOString(*schema2,m_nTextEncoding)).getStr() : NULL,
+ *pFKN = table2 ? (aFKN = ::rtl::OUStringToOString(*table2,m_nTextEncoding)).getStr() : NULL;
+
+
+ SQLRETURN nRetcode = N3SQLForeignKeys(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKN, pPKN ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pFKQ, (catalog2.hasValue() && aFKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pFKO, pFKO ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pFKN, SQL_NTS
+ );
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openImportedKeys(const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table) throw(SQLException, RuntimeException)
+{
+
+ openForeignKeys(Any(),NULL,NULL,catalog,!schema.compareToAscii("%") ? &schema : NULL,&table);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openExportedKeys(const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table) throw(SQLException, RuntimeException)
+{
+ openForeignKeys(catalog,!schema.compareToAscii("%") ? &schema : NULL,&table,Any(),NULL,NULL);
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openPrimaryKeys(const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table) throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schema.toChar() != '%')
+ pSchemaPat = &schema;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN,aCOL;
+
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLPrimaryKeys(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openTablePrivileges(const Any& catalog, const ::rtl::OUString& schemaPattern,
+ const ::rtl::OUString& tableNamePattern) throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schemaPattern.toChar() != '%')
+ pSchemaPat = &schemaPattern;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN;
+
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schemaPattern,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = (aPKN = ::rtl::OUStringToOString(tableNamePattern,m_nTextEncoding)).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLTablePrivileges(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::openIndexInfo( const Any& catalog, const ::rtl::OUString& schema,
+ const ::rtl::OUString& table,sal_Bool unique,sal_Bool approximate )
+ throw(SQLException, RuntimeException)
+{
+ const ::rtl::OUString *pSchemaPat = NULL;
+
+ if(schema.toChar() != '%')
+ pSchemaPat = &schema;
+ else
+ pSchemaPat = NULL;
+
+ m_bFreeHandle = sal_True;
+ ::rtl::OString aPKQ,aPKO,aPKN;
+
+ aPKQ = ::rtl::OUStringToOString(comphelper::getString(catalog),m_nTextEncoding);
+ aPKO = ::rtl::OUStringToOString(schema,m_nTextEncoding);
+
+ const char *pPKQ = catalog.hasValue() && aPKQ.getLength() ? aPKQ.getStr() : NULL,
+ *pPKO = pSchemaPat && pSchemaPat->getLength() ? aPKO.getStr() : NULL,
+ *pPKN = (aPKN = ::rtl::OUStringToOString(table,m_nTextEncoding)).getStr();
+
+
+ SQLRETURN nRetcode = N3SQLStatistics(m_aStatementHandle,
+ (SDB_ODBC_CHAR *) pPKQ, (catalog.hasValue() && aPKQ.getLength()) ? SQL_NTS : 0,
+ (SDB_ODBC_CHAR *) pPKO, pPKO ? SQL_NTS : 0 ,
+ (SDB_ODBC_CHAR *) pPKN, SQL_NTS,
+ unique ? SQL_INDEX_UNIQUE : SQL_INDEX_ALL,
+ approximate);
+ OTools::ThrowException(m_pConnection,nRetcode,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ checkColumnCount();
+}
+// -------------------------------------------------------------------------
+void ODatabaseMetaDataResultSet::checkColumnCount()
+{
+ sal_Int16 nNumResultCols=0;
+ OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ m_nDriverColumnCount = nNumResultCols;
+}
+// -----------------------------------------------------------------------------
+
+SWORD ODatabaseMetaDataResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
+{
+ ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
+ if ( aFind == m_aODBCColumnTypes.end() )
+ aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pConnection,m_aStatementHandle,*this,columnIndex))).first;
+ return aFind->second;
+}
+
diff --git a/connectivity/source/drivers/odbcbase/ODriver.cxx b/connectivity/source/drivers/odbcbase/ODriver.cxx
new file mode 100644
index 000000000000..015e63d960af
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/ODriver.cxx
@@ -0,0 +1,229 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/ODriver.hxx"
+#include "odbc/OConnection.hxx"
+#include "odbc/OFunctions.hxx"
+#include "odbc/OTools.hxx"
+#include "connectivity/dbexception.hxx"
+#include "resource/common_res.hrc"
+#include "resource/sharedresources.hxx"
+
+using namespace connectivity::odbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+// --------------------------------------------------------------------------------
+ODBCDriver::ODBCDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxFactory)
+ :ODriver_BASE(m_aMutex)
+ ,m_xORB(_rxFactory)
+ ,m_pDriverHandle(SQL_NULL_HANDLE)
+{
+}
+// --------------------------------------------------------------------------------
+void ODBCDriver::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+
+ for (OWeakRefArray::iterator i = m_xConnections.begin(); m_xConnections.end() != i; ++i)
+ {
+ Reference< XComponent > xComp(i->get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ }
+ m_xConnections.clear();
+
+ ODriver_BASE::disposing();
+}
+
+// static ServiceInfo
+//------------------------------------------------------------------------------
+rtl::OUString ODBCDriver::getImplementationName_Static( ) throw(RuntimeException)
+{
+ return rtl::OUString::createFromAscii("com.sun.star.comp.sdbc.ODBCDriver");
+ // this name is referenced in the configuration and in the odbc.xml
+ // Please take care when changing it.
+}
+
+typedef Sequence< ::rtl::OUString > SS;
+//------------------------------------------------------------------------------
+SS ODBCDriver::getSupportedServiceNames_Static( ) throw (RuntimeException)
+{
+ SS aSNS( 1 );
+ aSNS[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.Driver");
+ return aSNS;
+}
+
+//------------------------------------------------------------------
+::rtl::OUString SAL_CALL ODBCDriver::getImplementationName( ) throw(RuntimeException)
+{
+ return getImplementationName_Static();
+}
+
+//------------------------------------------------------------------
+sal_Bool SAL_CALL ODBCDriver::supportsService( const ::rtl::OUString& _rServiceName ) throw(RuntimeException)
+{
+ SS aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+//------------------------------------------------------------------
+SS SAL_CALL ODBCDriver::getSupportedServiceNames( ) throw(RuntimeException)
+{
+ return getSupportedServiceNames_Static();
+}
+
+// --------------------------------------------------------------------------------
+Reference< XConnection > SAL_CALL ODBCDriver::connect( const ::rtl::OUString& url, const Sequence< PropertyValue >& info ) throw(SQLException, RuntimeException)
+{
+ if ( ! acceptsURL(url) )
+ return NULL;
+
+ if(!m_pDriverHandle)
+ {
+ ::rtl::OUString aPath;
+ if(!EnvironmentHandle(aPath))
+ throw SQLException(aPath,*this,::rtl::OUString(),1000,Any());
+ }
+ OConnection* pCon = new OConnection(m_pDriverHandle,this);
+ Reference< XConnection > xCon = pCon;
+ pCon->Construct(url,info);
+ m_xConnections.push_back(WeakReferenceHelper(*pCon));
+
+ return xCon;
+}
+// --------------------------------------------------------------------------------
+sal_Bool SAL_CALL ODBCDriver::acceptsURL( const ::rtl::OUString& url )
+ throw(SQLException, RuntimeException)
+{
+ return (!url.compareTo(::rtl::OUString::createFromAscii("sdbc:odbc:"),10));
+}
+// --------------------------------------------------------------------------------
+Sequence< DriverPropertyInfo > SAL_CALL ODBCDriver::getPropertyInfo( const ::rtl::OUString& url, const Sequence< PropertyValue >& /*info*/ ) throw(SQLException, RuntimeException)
+{
+ if ( acceptsURL(url) )
+ {
+ ::std::vector< DriverPropertyInfo > aDriverInfo;
+
+ Sequence< ::rtl::OUString > aBooleanValues(2);
+ aBooleanValues[0] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) );
+ aBooleanValues[1] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) );
+
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CharSet of the database."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UseCatalog"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Use catalog for file-based databases."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SystemDriverSettings"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Driver settings."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParameterNameSubstitution"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Change named parameters with '?'."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IgnoreDriverPrivileges"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Ignore the privileges from the database driver."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IsAutoRetrievingEnabled"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Retrieve generated values."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "false" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoRetrievingStatement"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Auto-increment statement."))
+ ,sal_False
+ ,::rtl::OUString()
+ ,Sequence< ::rtl::OUString >())
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GenerateASBeforeCorrelationName"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Generate AS before table correlation names."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) )
+ ,aBooleanValues)
+ );
+ aDriverInfo.push_back(DriverPropertyInfo(
+ ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EscapeDateTime"))
+ ,::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Escape date time format."))
+ ,sal_False
+ ,::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "true" ) )
+ ,aBooleanValues)
+ );
+
+ return Sequence< DriverPropertyInfo >(&aDriverInfo[0],aDriverInfo.size());
+ }
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sMessage = aResources.getResourceString(STR_URI_SYNTAX_ERROR);
+ ::dbtools::throwGenericSQLException(sMessage ,*this);
+ return Sequence< DriverPropertyInfo >();
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODBCDriver::getMajorVersion( ) throw(RuntimeException)
+{
+ return 1;
+}
+// --------------------------------------------------------------------------------
+sal_Int32 SAL_CALL ODBCDriver::getMinorVersion( ) throw(RuntimeException)
+{
+ return 0;
+}
+// --------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
+
+
diff --git a/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
new file mode 100644
index 000000000000..758b2fb38def
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OPreparedStatement.cxx
@@ -0,0 +1,973 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <string.h>
+#include <osl/diagnose.h>
+#include "odbc/OPreparedStatement.hxx"
+#include "odbc/OBoundParam.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include "odbc/OTools.hxx"
+#include "odbc/ODriver.hxx"
+#include "odbc/OResultSet.hxx"
+#include "odbc/OResultSetMetaData.hxx"
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/sequence.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include "connectivity/dbtools.hxx"
+#include <comphelper/types.hxx>
+#include "connectivity/FValue.hxx"
+#include "resource/common_res.hrc"
+#include "connectivity/sqlparse.hxx"
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::odbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+IMPLEMENT_SERVICE_INFO(OPreparedStatement,"com.sun.star.sdbcx.OPreparedStatement","com.sun.star.sdbc.PreparedStatement");
+
+
+OPreparedStatement::OPreparedStatement( OConnection* _pConnection,const ::rtl::OUString& sql)
+ :OStatement_BASE2(_pConnection)
+ ,numParams(0)
+ ,boundParams(NULL)
+ ,m_bPrepared(sal_False)
+{
+ m_sSqlStatement = sql;
+ try
+ {
+ if(_pConnection->isParameterSubstitutionEnabled())
+ {
+ OSQLParser aParser(_pConnection->getDriver()->getORB());
+ ::rtl::OUString sErrorMessage;
+ ::rtl::OUString sNewSql;
+ ::std::auto_ptr<OSQLParseNode> pNode( aParser.parseTree(sErrorMessage,sql) );
+ if ( pNode.get() )
+ { // special handling for parameters
+ OSQLParseNode::substituteParameterNames(pNode.get());
+ pNode->parseNodeToStr( sNewSql, _pConnection );
+ m_sSqlStatement = sNewSql;
+ }
+ }
+ }
+ catch(Exception&)
+ {
+ }
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+Any SAL_CALL OPreparedStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OStatement_BASE2::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OPreparedStatement_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL OPreparedStatement::getTypes( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::comphelper::concatSequences(OPreparedStatement_BASE::getTypes(),OStatement_BASE2::getTypes());
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ prepareStatement();
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(getOwnConnection(),m_aStatementHandle);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::close( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ // Close/clear our result set
+ clearMyResultSet ();
+
+ // Reset last warning message
+
+ try {
+ clearWarnings ();
+ OStatement_BASE2::close();
+ FreeParams();
+ }
+ catch (SQLException &) {
+ // If we get an error, ignore
+ }
+
+ // Remove this Statement object from the Connection object's
+ // list
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OPreparedStatement::execute( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Bool needData = sal_False;
+
+ // Reset warnings
+
+ clearWarnings ();
+
+ // Reset the statement handle, warning and saved Resultset
+
+ reset();
+
+ // Call SQLExecute
+ prepareStatement();
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ try
+ {
+ SQLRETURN nReturn = N3SQLExecute(m_aStatementHandle);
+
+ OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ needData = nReturn == SQL_NEED_DATA;
+
+ // Now loop while more data is needed (i.e. a data-at-
+ // execution parameter was given). For each parameter
+ // that needs data, put the data from the input stream.
+
+ while (needData) {
+
+ // Get the parameter number that requires data
+
+ sal_Int32* paramIndex = 0;
+ nReturn = N3SQLParamData(m_aStatementHandle,(SQLPOINTER*)&paramIndex);
+
+ // If the parameter index is -1, there is no
+ // more data required
+
+ if ( !paramIndex || ( *paramIndex == -1 ) )
+ needData = sal_False;
+ else
+ {
+ // Now we have the proper parameter
+ // index, get the data from the input
+ // stream and do a SQLPutData
+ putParamData (*paramIndex);
+ }
+ }
+
+ }
+ catch (const SQLWarning&)
+ {
+ }
+
+ // Now loop while more data is needed (i.e. a data-at-
+ // execution parameter was given). For each parameter
+ // that needs data, put the data from the input stream.
+
+ while (needData) {
+
+ // Get the parameter number that requires data
+
+ sal_Int32* paramIndex = 0;
+ N3SQLParamData (m_aStatementHandle,(SQLPOINTER*)&paramIndex);
+
+ // If the parameter index is -1, there is no more
+ // data required
+
+ if (*paramIndex == -1) {
+ needData = sal_False;
+ }
+ else {
+ // Now we have the proper parameter index,
+ // get the data from the input stream
+ // and do a SQLPutData
+ putParamData(*paramIndex);
+ }
+ }
+
+ // Now determine if there is a result set associated with
+ // the SQL statement that was executed. Get the column
+ // count, and if it is not zero, there is a result set.
+
+
+ return getColumnCount() > 0;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OPreparedStatement::executeUpdate( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ sal_Int32 numRows = -1;
+
+ prepareStatement();
+ // Execute the statement. If execute returns sal_False, a
+ // row count exists.
+
+ if (!execute())
+ numRows = getUpdateCount ();
+ else
+ {
+ // No update count was produced (a ResultSet was). Raise
+ // an exception
+ m_pConnection->throwGenericSQLException(STR_NO_ROWCOUNT,*this);
+ }
+ return numRows;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setString( sal_Int32 parameterIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
+ setParameter(parameterIndex,DataType::CHAR,aString.getLength(),(void*)&x);
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OPreparedStatement::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OPreparedStatement::executeQuery( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ Reference< XResultSet > rs = NULL;
+
+ prepareStatement();
+
+ if (execute())
+ rs = getResultSet(sal_False);
+ else
+ {
+ // No ResultSet was produced. Raise an exception
+ m_pConnection->throwGenericSQLException(STR_NO_RESULTSET,*this);
+ }
+ return rs;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBoolean( sal_Int32 parameterIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 value = 0;
+
+ // If the parameter is sal_True, set the value to 1
+ if (x) {
+ value = 1;
+ }
+
+ // Set the parameter as if it were an integer
+ setInt (parameterIndex, value);
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setParameter(sal_Int32 parameterIndex,sal_Int32 _nType,sal_Int32 _nSize,void* _pData)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ prepareStatement();
+ // Allocate a buffer to be used in binding. This will be
+ // a 'permanent' buffer that the bridge will fill in with
+ // the bound data in native format.
+
+
+ checkParameterIndex(parameterIndex);
+ sal_Int32 nRealSize = _nSize;
+ SQLSMALLINT fSqlType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(_nType));
+ switch(fSqlType)
+ {
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ ++nRealSize;
+ break;
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ nRealSize=1; //dummy buffer, binary data isn't copied
+ break;
+ default:
+ break;
+ }
+
+ sal_Int8* bindBuf = allocBindBuf(parameterIndex, nRealSize);
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ OTools::bindParameter( m_pConnection,
+ m_aStatementHandle,
+ parameterIndex,
+ bindBuf,
+ getLengthBuf(parameterIndex),
+ fSqlType,
+ sal_False,
+ m_pConnection->useOldDateFormat(),
+ _pData,
+ (Reference <XInterface>)*this,
+ getOwnConnection()->getTextEncoding());
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setByte( sal_Int32 parameterIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::TINYINT,sizeof(sal_Int8),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDate( sal_Int32 parameterIndex, const Date& aData ) throw(SQLException, RuntimeException)
+{
+ DATE_STRUCT x = OTools::DateToOdbcDate(aData);
+ setParameter(parameterIndex,DataType::DATE,sizeof(DATE_STRUCT),&x);
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setTime( sal_Int32 parameterIndex, const Time& aVal ) throw(SQLException, RuntimeException)
+{
+ TIME_STRUCT x = OTools::TimeToOdbcTime(aVal);
+ setParameter(parameterIndex,DataType::TIME,sizeof(TIME_STRUCT),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setTimestamp( sal_Int32 parameterIndex, const DateTime& aVal ) throw(SQLException, RuntimeException)
+{
+ TIMESTAMP_STRUCT x = OTools::DateTimeToTimestamp(aVal);
+ setParameter(parameterIndex,DataType::TIMESTAMP,sizeof(TIMESTAMP_STRUCT),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setDouble( sal_Int32 parameterIndex, double x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::DOUBLE,sizeof(double),&x);
+}
+
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setFloat( sal_Int32 parameterIndex, float x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::FLOAT,sizeof(float),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setInt( sal_Int32 parameterIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::INTEGER,sizeof(sal_Int32),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setLong( sal_Int32 parameterIndex, sal_Int64 x ) throw(SQLException, RuntimeException)
+{
+ try
+ {
+ setParameter(parameterIndex,DataType::BIGINT,sizeof(sal_Int64),&x);
+ }
+ catch(SQLException&)
+ {
+ setString(parameterIndex,ORowSetValue(x));
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setNull( sal_Int32 parameterIndex, sal_Int32 sqlType ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ prepareStatement();
+ // Get the buffer needed for the length
+ checkParameterIndex(parameterIndex);
+
+ sal_Int8* lenBuf = getLengthBuf (parameterIndex);
+ *(SQLLEN*)lenBuf = SQL_NULL_DATA;
+
+
+ SQLLEN prec = 0;
+ SQLULEN nColumnSize = 0;
+ if (sqlType == SQL_CHAR || sqlType == SQL_VARCHAR || sqlType == SQL_LONGVARCHAR)
+ {
+ prec = 1;
+ nColumnSize = 1;
+ }
+
+ SQLSMALLINT fCType = 0;
+ SQLSMALLINT fSqlType = 0;
+
+ SQLSMALLINT nDecimalDigits = 0;
+ OTools::getBindTypes( sal_False,
+ m_pConnection->useOldDateFormat(),
+ (SQLSMALLINT)sqlType,
+ fCType,
+ fSqlType);
+
+ SQLRETURN nReturn = N3SQLBindParameter( m_aStatementHandle,
+ (SQLUSMALLINT)parameterIndex,
+ (SQLSMALLINT)SQL_PARAM_INPUT,
+ fCType,
+ fSqlType,
+ nColumnSize,
+ nDecimalDigits,
+ NULL,
+ prec,
+ (SQLLEN*)lenBuf
+ );
+ OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setClob( sal_Int32 parameterIndex, const Reference< XClob >& x ) throw(SQLException, RuntimeException)
+{
+ if ( x.is() )
+ setStream(parameterIndex, x->getCharacterStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBlob( sal_Int32 parameterIndex, const Reference< XBlob >& x ) throw(SQLException, RuntimeException)
+{
+ if ( x.is() )
+ setStream(parameterIndex, x->getBinaryStream(), (SQLLEN)x->length(), DataType::LONGVARCHAR);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setArray( sal_Int32 /*parameterIndex*/, const Reference< XArray >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setArray", *this );
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setRef( sal_Int32 /*parameterIndex*/, const Reference< XRef >& /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XParameters::setRef", *this );
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setDecimal( sal_Int32 parameterIndex, const ::rtl::OUString& x )
+{
+ ::rtl::OString aString(::rtl::OUStringToOString(x,getOwnConnection()->getTextEncoding()));
+ setParameter(parameterIndex,DataType::DECIMAL,aString.getLength(),(void*)&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::setObjectWithInfo( sal_Int32 parameterIndex, const Any& x, sal_Int32 sqlType, sal_Int32 scale ) throw(SQLException, RuntimeException)
+{
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ prepareStatement();
+ // For each known SQL Type, call the appropriate
+ // set routine
+
+ switch (sqlType)
+ {
+ case DataType::VARCHAR:
+ case DataType::LONGVARCHAR:
+ if(x.hasValue())
+ {
+ ::rtl::OUString sStr;
+ x >>= sStr;
+ ::rtl::OString aString(::rtl::OUStringToOString(sStr,getOwnConnection()->getTextEncoding()));
+ setParameter(parameterIndex,sqlType,aString.getLength(),&aString);
+ }
+ else
+ setNull(parameterIndex,sqlType);
+ break;
+ case DataType::DECIMAL:
+ {
+ ORowSetValue aValue;
+ aValue.fill(x);
+ setDecimal(parameterIndex,aValue);
+ }
+ break;
+ case DataType::NUMERIC:
+ {
+ ORowSetValue aValue;
+ aValue.fill(x);
+ setString(parameterIndex,aValue);
+ }
+ break;
+ default:
+ ::dbtools::setObjectWithInfo(this,parameterIndex,x,sqlType,scale);
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObjectNull( sal_Int32 parameterIndex, sal_Int32 sqlType, const ::rtl::OUString& /*typeName*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ setNull(parameterIndex,sqlType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setObject( sal_Int32 parameterIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implSetObject(this, parameterIndex, x))
+ { // there is no other setXXX call which can handle the value in x
+ throw SQLException();
+ }
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setShort( sal_Int32 parameterIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::SMALLINT,sizeof(sal_Int16),&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBytes( sal_Int32 parameterIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ setParameter(parameterIndex,DataType::BINARY,x.getLength(),(void*)&x);
+ boundParams[parameterIndex-1].setSequence(x); // this assures that the sequence stays alive
+}
+// -------------------------------------------------------------------------
+
+
+void SAL_CALL OPreparedStatement::setCharacterStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ setStream(parameterIndex, x, length, DataType::LONGVARCHAR);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::setBinaryStream( sal_Int32 parameterIndex, const Reference< ::com::sun::star::io::XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ setStream(parameterIndex, x, length, DataType::LONGVARBINARY);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::clearParameters( ) throw(SQLException, RuntimeException)
+{
+ prepareStatement();
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLRETURN nRet = N3SQLFreeStmt (m_aStatementHandle, SQL_RESET_PARAMS);
+ nRet = N3SQLFreeStmt (m_aStatementHandle, SQL_UNBIND);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OPreparedStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+ // clearParameters( );
+ // m_aBatchList.erase();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OPreparedStatement::addBatch( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int32 > SAL_CALL OPreparedStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ return Sequence< sal_Int32 > ();
+}
+// -------------------------------------------------------------------------
+
+//====================================================================
+// methods
+//====================================================================
+
+//--------------------------------------------------------------------
+// initBoundParam
+// Initialize the bound parameter objects
+//--------------------------------------------------------------------
+
+void OPreparedStatement::initBoundParam () throw(SQLException)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ // Get the number of parameters
+ numParams = 0;
+ N3SQLNumParams (m_aStatementHandle,&numParams);
+
+ // There are parameter markers, allocate the bound
+ // parameter objects
+
+ if (numParams > 0)
+ {
+ // Allocate an array of bound parameter objects
+
+ boundParams = new OBoundParam[numParams];
+
+ // Allocate and initialize each bound parameter
+
+ for (sal_Int32 i = 0; i < numParams; i++)
+ {
+ boundParams[i] = OBoundParam();
+ boundParams[i].initialize ();
+ }
+ }
+}
+// -------------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// allocBindBuf
+// Allocate storage for the permanent data buffer for the bound
+// parameter.
+//--------------------------------------------------------------------
+
+sal_Int8* OPreparedStatement::allocBindBuf( sal_Int32 index,sal_Int32 bufLen)
+{
+ sal_Int8* b = NULL;
+
+ // Sanity check the parameter number
+
+ if ((index >= 1) &&
+ (index <= numParams) && bufLen > 0 )
+ {
+ b = boundParams[index - 1].allocBindDataBuffer(bufLen);
+ }
+
+ return b;
+}
+// -------------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// getDataBuf
+// Gets the data buffer for the given parameter index
+//--------------------------------------------------------------------
+
+sal_Int8* OPreparedStatement::getDataBuf (sal_Int32 index)
+{
+ sal_Int8* b = NULL;
+
+ // Sanity check the parameter number
+
+ if ((index >= 1) &&
+ (index <= numParams))
+ {
+ b = boundParams[index - 1].getBindDataBuffer ();
+ }
+
+ return b;
+}
+// -------------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// getLengthBuf
+// Gets the length buffer for the given parameter index
+//--------------------------------------------------------------------
+
+sal_Int8* OPreparedStatement::getLengthBuf (sal_Int32 index)
+{
+ sal_Int8* b = NULL;
+
+ // Sanity check the parameter number
+
+ if ((index >= 1) &&
+ (index <= numParams))
+ {
+ b = boundParams[index - 1].getBindLengthBuffer ();
+ }
+
+ return b;
+}
+// -------------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// getParamLength
+// Returns the length of the given parameter number. When each
+// parameter was bound, a 4-sal_Int8 buffer was given to hold the
+// length (stored in native format). Get the buffer, convert the
+// buffer from native format, and return it. If the length is -1,
+// the column is considered to be NULL.
+//--------------------------------------------------------------------
+
+sal_Int32 OPreparedStatement::getParamLength ( sal_Int32 index)
+{
+ sal_Int32 paramLen = SQL_NULL_DATA;
+
+ // Sanity check the parameter number
+
+ if ((index >= 1) &&
+ (index <= numParams)) {
+
+ // Now get the length of the parameter from the
+ // bound param array. -1 is returned if it is NULL.
+ long n = 0;
+ memcpy (&n, boundParams[index -1].getBindLengthBuffer (), sizeof (n));
+ paramLen = n;
+ }
+ return paramLen;
+}
+// -------------------------------------------------------------------------
+
+//--------------------------------------------------------------------
+// putParamData
+// Puts parameter data from a previously bound input stream. The
+// input stream was bound using SQL_LEN_DATA_AT_EXEC.
+//--------------------------------------------------------------------
+
+void OPreparedStatement::putParamData (sal_Int32 index) throw(SQLException)
+{
+ // Sanity check the parameter index
+ if ((index < 1) ||
+ (index > numParams))
+ {
+ return;
+ }
+
+ // We'll transfer up to MAX_PUT_DATA_LENGTH at a time
+ Sequence< sal_Int8 > buf( MAX_PUT_DATA_LENGTH );
+
+ // Get the information about the input stream
+
+ Reference< XInputStream> inputStream = boundParams[index - 1].getInputStream ();
+ if ( !inputStream.is() )
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_INPUTSTREAM));
+ throw SQLException (sError, *this,::rtl::OUString(),0,Any());
+ }
+
+ sal_Int32 maxBytesLeft = boundParams[index - 1].getInputStreamLen ();
+
+ // Loop while more data from the input stream
+ sal_Int32 haveRead = 0;
+ try
+ {
+
+ do
+ {
+ sal_Int32 toReadThisRound = ::std::min( MAX_PUT_DATA_LENGTH, maxBytesLeft );
+
+ // Read some data from the input stream
+ haveRead = inputStream->readBytes( buf, toReadThisRound );
+ OSL_ENSURE( haveRead == buf.getLength(), "OPreparedStatement::putParamData: inconsistency!" );
+
+ if ( !haveRead )
+ // no more data in the stream - the given stream length was a maximum which could not be
+ // fulfilled by the stream
+ break;
+
+ // Put the data
+ OSL_ENSURE( m_aStatementHandle, "OPreparedStatement::putParamData: StatementHandle is null!" );
+ N3SQLPutData ( m_aStatementHandle, buf.getArray(), buf.getLength() );
+
+ // decrement the number of bytes still needed
+ maxBytesLeft -= haveRead;
+ }
+ while ( maxBytesLeft > 0 );
+ }
+ catch (const IOException& ex)
+ {
+
+ // If an I/O exception was generated, turn
+ // it into a SQLException
+
+ throw SQLException(ex.Message,*this,::rtl::OUString(),0,Any());
+ }
+}
+// -------------------------------------------------------------------------
+//--------------------------------------------------------------------
+// getPrecision
+// Given a SQL type, return the maximum precision for the column.
+// Returns -1 if not known
+//--------------------------------------------------------------------
+
+sal_Int32 OPreparedStatement::getPrecision ( sal_Int32 sqlType)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ sal_Int32 prec = -1;
+ const TTypeInfoVector& rTypeInfo = m_pConnection->getTypeInfo();
+ if ( !rTypeInfo.empty() )
+ {
+ m_pConnection->buildTypeInfo();
+ }
+
+ if ( !rTypeInfo.empty() )
+ {
+ OTypeInfo aInfo;
+ aInfo.nType = (sal_Int16)sqlType;
+ TTypeInfoVector::const_iterator aIter = ::std::find(rTypeInfo.begin(),rTypeInfo.end(),aInfo);
+ if(aIter != rTypeInfo.end())
+ prec = (*aIter).nPrecision;
+ }
+ return prec;
+}
+
+//--------------------------------------------------------------------
+// setStream
+// Sets an input stream as a parameter, using the given SQL type
+//--------------------------------------------------------------------
+
+void OPreparedStatement::setStream(
+ sal_Int32 ParameterIndex,
+ const Reference< XInputStream>& x,
+ SQLLEN length,
+ sal_Int32 SQLtype)
+ throw(SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ prepareStatement();
+
+ checkParameterIndex(ParameterIndex);
+ // Get the buffer needed for the length
+
+ sal_Int8* lenBuf = getLengthBuf(ParameterIndex);
+
+ // Allocate a new buffer for the parameter data. This buffer
+ // will be returned by SQLParamData (it is set to the parameter
+ // number, a 4-sal_Int8 integer)
+
+ sal_Int8* dataBuf = allocBindBuf (ParameterIndex, 4);
+
+ // Bind the parameter with SQL_LEN_DATA_AT_EXEC
+ SQLSMALLINT Ctype = SQL_C_CHAR;
+ SQLLEN atExec = SQL_LEN_DATA_AT_EXEC (length);
+ memcpy (dataBuf, &ParameterIndex, sizeof(ParameterIndex));
+ memcpy (lenBuf, &atExec, sizeof (atExec));
+
+ if ((SQLtype == SQL_BINARY) || (SQLtype == SQL_VARBINARY) || (SQLtype == SQL_LONGVARBINARY))
+ Ctype = SQL_C_BINARY;
+
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ N3SQLBindParameter(m_aStatementHandle,
+ (SQLUSMALLINT)ParameterIndex,
+ (SQLUSMALLINT)SQL_PARAM_INPUT,
+ Ctype,
+ (SQLSMALLINT)SQLtype,
+ (SQLULEN)length,
+ 0,
+ dataBuf,
+ sizeof(ParameterIndex),
+ (SQLLEN*)lenBuf);
+
+ // Save the input stream
+ boundParams[ParameterIndex - 1].setInputStream (x, length);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+
+void OPreparedStatement::FreeParams()
+{
+ numParams = 0;
+ delete [] boundParams;
+ boundParams = NULL;
+}
+// -------------------------------------------------------------------------
+void OPreparedStatement::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ if(!isPrepared())
+ setResultSetConcurrency(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ if(!isPrepared())
+ setResultSetType(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ if(!isPrepared())
+ setFetchDirection(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ if(!isPrepared())
+ setUsingBookmarks(comphelper::getBOOL(rValue));
+ break;
+ default:
+ OStatement_Base::setFastPropertyValue_NoBroadcast(nHandle,rValue);
+ }
+ }
+ catch(const SQLException&)
+ {
+ // throw Exception(e.Message,*this);
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::prepareStatement()
+{
+ if(!isPrepared())
+ {
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ ::rtl::OString aSql(::rtl::OUStringToOString(m_sSqlStatement,getOwnConnection()->getTextEncoding()));
+ SQLRETURN nReturn = N3SQLPrepare(m_aStatementHandle,(SDB_ODBC_CHAR *) aSql.getStr(),aSql.getLength());
+ OTools::ThrowException(m_pConnection,nReturn,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ m_bPrepared = sal_True;
+ initBoundParam();
+ }
+}
+// -----------------------------------------------------------------------------
+void OPreparedStatement::checkParameterIndex(sal_Int32 _parameterIndex)
+{
+ if( !_parameterIndex || _parameterIndex > numParams)
+ {
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceStringWithSubstitution(STR_WRONG_PARAM_INDEX,
+ "$pos$", ::rtl::OUString::valueOf(_parameterIndex),
+ "$count$", ::rtl::OUString::valueOf((sal_Int32)numParams)
+ ));
+ SQLException aNext(sError,*this, ::rtl::OUString(),0,Any());
+
+ ::dbtools::throwInvalidIndexException(*this,makeAny(aNext));
+ }
+}
+// -----------------------------------------------------------------------------
+OResultSet* OPreparedStatement::createResulSet()
+{
+ OResultSet* pReturn = new OResultSet(m_aStatementHandle,this);
+ pReturn->setMetaData(getMetaData());
+ return pReturn;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/OResultSet.cxx b/connectivity/source/drivers/odbcbase/OResultSet.cxx
new file mode 100644
index 000000000000..7055bd273370
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OResultSet.cxx
@@ -0,0 +1,1755 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/OResultSet.hxx"
+#include "odbc/OTools.hxx"
+#include "odbc/OResultSetMetaData.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sdbcx/CompareBookmark.hpp>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <comphelper/property.hxx>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/types.hxx>
+#include "connectivity/dbtools.hxx"
+#include "connectivity/dbexception.hxx"
+#include "diagnose_ex.h"
+#include <rtl/logfile.hxx>
+
+using namespace ::comphelper;
+using namespace connectivity;
+using namespace connectivity::odbc;
+using namespace cppu;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+
+#define ODBC_SQL_NOT_DEFINED 99UL
+
+//------------------------------------------------------------------------------
+// IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
+::rtl::OUString SAL_CALL OResultSet::getImplementationName( ) throw ( RuntimeException)
+{
+ return ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.odbc.ResultSet");
+}
+// -------------------------------------------------------------------------
+ Sequence< ::rtl::OUString > SAL_CALL OResultSet::getSupportedServiceNames( ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(2);
+ aSupported[0] = ::rtl::OUString::createFromAscii("com.sun.star.sdbc.ResultSet");
+ aSupported[1] = ::rtl::OUString::createFromAscii("com.sun.star.sdbcx.ResultSet");
+ return aSupported;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::supportsService( const ::rtl::OUString& _rServiceName ) throw( RuntimeException)
+{
+ Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
+ const ::rtl::OUString* pSupported = aSupported.getConstArray();
+ const ::rtl::OUString* pEnd = pSupported + aSupported.getLength();
+ for (;pSupported != pEnd && !pSupported->equals(_rServiceName); ++pSupported)
+ ;
+
+ return pSupported != pEnd;
+}
+
+// -------------------------------------------------------------------------
+OResultSet::OResultSet(SQLHANDLE _pStatementHandle ,OStatement_Base* pStmt) : OResultSet_BASE(m_aMutex)
+ ,OPropertySetHelper(OResultSet_BASE::rBHelper)
+ ,m_aStatementHandle(_pStatementHandle)
+ ,m_aConnectionHandle(pStmt->getConnectionHandle())
+ ,m_pStatement(pStmt)
+ ,m_pSkipDeletedSet(NULL)
+ ,m_xStatement(*pStmt)
+ ,m_xMetaData(NULL)
+ ,m_pRowStatusArray( NULL )
+ ,m_nTextEncoding(pStmt->getOwnConnection()->getTextEncoding())
+ ,m_nRowPos(0)
+ ,m_nLastColumnPos(0)
+ ,m_nUseBookmarks(ODBC_SQL_NOT_DEFINED)
+ ,m_nCurrentFetchState(0)
+ ,m_bWasNull(sal_True)
+ ,m_bEOF(sal_True)
+ ,m_bLastRecord(sal_False)
+ ,m_bFreeHandle(sal_False)
+ ,m_bInserting(sal_False)
+ ,m_bFetchData(sal_True)
+ ,m_bRowInserted(sal_False)
+ ,m_bRowDeleted(sal_False)
+ ,m_bUseFetchScroll(sal_False)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ try
+ {
+ m_pRowStatusArray = new SQLUSMALLINT[1]; // the default value
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+ }
+ catch(Exception&)
+ { // we don't want our result destroy here
+ }
+ SQLINTEGER nCurType = 0;
+ try
+ {
+ N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
+ SQLUINTEGER nValueLen = m_pStatement->getCursorProperties(nCurType,sal_False);
+ if( (nValueLen & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS ||
+ (nValueLen & SQL_CA2_CRC_EXACT) != SQL_CA2_CRC_EXACT)
+ m_pSkipDeletedSet = new OSkipDeletedSet(this);
+ }
+ catch(Exception&)
+ { // we don't want our result destroy here
+ }
+ try
+ {
+ SQLUINTEGER nValueLen = 0;
+ OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_GETDATA_EXTENSIONS,nValueLen,NULL);
+ m_bFetchData = !((SQL_GD_ANY_ORDER & nValueLen) == SQL_GD_ANY_ORDER && nCurType != SQL_CURSOR_FORWARD_ONLY);
+ }
+ catch(Exception&)
+ { // we don't want our result destroy here
+ m_bFetchData = sal_True;
+ }
+ try
+ {
+ if ( getOdbcFunction(ODBC3SQLGetFunctions) )
+ {
+ SQLUSMALLINT nSupported = 0;
+ m_bUseFetchScroll = ( N3SQLGetFunctions(m_aConnectionHandle,SQL_API_SQLFETCHSCROLL,&nSupported) == SQL_SUCCESS && nSupported == 1 );
+ }
+ }
+ catch(Exception&)
+ {
+ m_bUseFetchScroll = sal_False;
+ }
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+OResultSet::~OResultSet()
+{
+ delete [] m_pRowStatusArray;
+ delete m_pSkipDeletedSet;
+}
+// -----------------------------------------------------------------------------
+void OResultSet::construct()
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ allocBuffer();
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -------------------------------------------------------------------------
+void OResultSet::disposing(void)
+{
+ SQLRETURN nRet = N3SQLCloseCursor(m_aStatementHandle);
+ OSL_UNUSED( nRet );
+ OPropertySetHelper::disposing();
+
+ ::osl::MutexGuard aGuard(m_aMutex);
+ if(!m_aBindVector.empty())
+ releaseBuffer();
+ if(m_bFreeHandle)
+ m_pStatement->getOwnConnection()->freeStatementHandle(m_aStatementHandle);
+
+m_xStatement.clear();
+m_xMetaData.clear();
+}
+// -------------------------------------------------------------------------
+SQLRETURN OResultSet::unbind(sal_Bool _bUnbindHandle)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::unbind" );
+ SQLRETURN nRet = 0;
+ if ( _bUnbindHandle )
+ nRet = N3SQLFreeStmt(m_aStatementHandle,SQL_UNBIND);
+
+ if ( m_aBindVector.size() > 1 )
+ {
+ TVoidVector::iterator pValue = m_aBindVector.begin() + 1;
+ TVoidVector::iterator pEnd = m_aBindVector.end();
+ for(; pValue != pEnd; ++pValue)
+ {
+ switch (pValue->second)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::BIGINT:
+ delete static_cast< sal_Int64* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ delete static_cast< ::rtl::OString* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ delete static_cast< double* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ delete [] static_cast< char* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::DATE:
+ delete static_cast< DATE_STRUCT* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::TIME:
+ delete static_cast< TIME_STRUCT* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::TIMESTAMP:
+ delete static_cast< TIMESTAMP_STRUCT* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::BIT:
+ case DataType::TINYINT:
+ delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::SMALLINT:
+ delete static_cast< sal_Int16* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::INTEGER:
+ delete static_cast< sal_Int32* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::FLOAT:
+ delete static_cast< float* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ delete static_cast< sal_Int8* >(reinterpret_cast< void * >(pValue->first));
+ break;
+ }
+ }
+ m_aBindVector.clear();
+ m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+TVoidPtr OResultSet::allocBindColumn(sal_Int32 _nType,sal_Int32 _nColumnIndex)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBindColumn" );
+ TVoidPtr aPair;
+ switch (_nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
+ break;
+ case DataType::BIGINT:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int64(0)),_nType);
+ break;
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new ::rtl::OString()),_nType);
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new double(0.0)),_nType);
+ break;
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new char[2]),_nType); // dient nur zum auffinden
+ break;
+ case DataType::DATE:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new DATE_STRUCT),_nType);
+ break;
+ case DataType::TIME:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIME_STRUCT),_nType);
+ break;
+ case DataType::TIMESTAMP:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new TIMESTAMP_STRUCT),_nType);
+ break;
+ case DataType::BIT:
+ case DataType::TINYINT:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8(0)),_nType);
+ break;
+ case DataType::SMALLINT:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int16(0)),_nType);
+ break;
+ case DataType::INTEGER:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int32(0)),_nType);
+ break;
+ case DataType::FLOAT:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new float(0)),_nType);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ aPair = TVoidPtr(reinterpret_cast< sal_Int64 >(new sal_Int8[m_aRow[_nColumnIndex].getSequence().getLength()]),_nType);
+ break;
+ default:
+ OSL_ENSURE(0,"Unknown type");
+ aPair = TVoidPtr(0,_nType);
+ }
+ return aPair;
+}
+// -------------------------------------------------------------------------
+void OResultSet::allocBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::allocBuffer" );
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+
+ m_aBindVector.reserve(nLen+1);
+ m_aBindVector.push_back(TVoidPtr(0,0)); // the first is reserved for the bookmark
+ m_aRow.resize(nLen+1);
+
+ for(sal_Int32 i = 1;i<=nLen;++i)
+ {
+ sal_Int32 nType = xMeta->getColumnType(i);
+ m_aRow[i].setTypeKind( nType );
+ }
+ m_aLengthVector.resize(nLen + 1);
+}
+// -------------------------------------------------------------------------
+void OResultSet::releaseBuffer()
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::releaseBuffer" );
+ unbind(sal_False);
+ m_aLengthVector.clear();
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = OPropertySetHelper::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+ Sequence< Type > SAL_CALL OResultSet::getTypes( ) throw( RuntimeException)
+{
+ OTypeCollection aTypes( ::getCppuType( (const Reference< ::com::sun::star::beans::XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< ::com::sun::star::beans::XPropertySet > *)0 ));
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),OResultSet_BASE::getTypes());
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::findColumn( const ::rtl::OUString& columnName ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::findColumn" );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ Reference< XResultSetMetaData > xMeta = getMetaData();
+ sal_Int32 nLen = xMeta->getColumnCount();
+ sal_Int32 i = 1;
+ for(;i<=nLen;++i)
+ if(xMeta->isCaseSensitive(i) ? columnName == xMeta->getColumnName(i) :
+ columnName.equalsIgnoreAsciiCase(xMeta->getColumnName(i)))
+ break;
+ return i;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // TODO use getBytes instead of
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // TODO use getBytes instead of
+ return NULL;
+}
+// -----------------------------------------------------------------------------
+const ORowSetValue& OResultSet::getValue(sal_Int32 _nColumnIndex,SQLSMALLINT _nType,void* _pValue,SQLINTEGER _rSize)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(m_bFetchData)
+ {
+ if(_nColumnIndex > m_nLastColumnPos)
+ fillRow(_nColumnIndex);
+ return m_aRow[_nColumnIndex];
+ }
+ else
+ OTools::getValue(m_pStatement->getOwnConnection(),m_aStatementHandle,_nColumnIndex,_nType,m_bWasNull,**this,_pValue,_rSize);
+
+ return m_aEmptyValue;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::getBoolean( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ sal_Int8 nVal(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_BIT,&nVal,sizeof nVal);
+ return (&aValue == &m_aEmptyValue) ? (sal_Bool)nVal : (sal_Bool)aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int8 SAL_CALL OResultSet::getByte( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ sal_Int8 nRet(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_TINYINT,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int8)aValue;
+}
+// -------------------------------------------------------------------------
+
+Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBytes" );
+
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+
+ if(m_bFetchData)
+ {
+ if(columnIndex > m_nLastColumnPos)
+ fillRow(columnIndex);
+ Sequence< sal_Int8 > nRet;
+ switch(m_aRow[columnIndex].getTypeKind())
+ {
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ nRet = m_aRow[columnIndex];
+ break;
+ default:
+ {
+ ::rtl::OUString sRet;
+ sRet = m_aRow[columnIndex].getString();
+ nRet = Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(sRet.getStr()),sizeof(sal_Unicode)*sRet.getLength());
+ }
+ }
+ return nRet;
+ }
+
+ const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
+
+ switch(nColumnType)
+ {
+ case SQL_WVARCHAR:
+ case SQL_WCHAR:
+ case SQL_WLONGVARCHAR:
+ case SQL_VARCHAR:
+ case SQL_CHAR:
+ case SQL_LONGVARCHAR:
+ {
+ ::rtl::OUString aRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
+ return Sequence<sal_Int8>(reinterpret_cast<const sal_Int8*>(aRet.getStr()),sizeof(sal_Unicode)*aRet.getLength());
+ }
+ default:
+ ;
+ }
+ return OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_C_BINARY,m_bWasNull,**this);
+}
+// -------------------------------------------------------------------------
+
+Date SAL_CALL OResultSet::getDate( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getDate" );
+ DATE_STRUCT aDate;
+ aDate.day = 0;
+ aDate.month = 0;
+ aDate.year = 0;
+
+ const ORowSetValue& aValue = getValue( columnIndex,
+ m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_DATE : SQL_C_TYPE_DATE,
+ &aDate,sizeof aDate);
+ return (&aValue == &m_aEmptyValue) ? Date(aDate.day,aDate.month,aDate.year) : (Date)aValue;
+}
+// -------------------------------------------------------------------------
+
+double SAL_CALL OResultSet::getDouble( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ double nRet(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_DOUBLE,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (double)aValue;
+}
+// -------------------------------------------------------------------------
+
+float SAL_CALL OResultSet::getFloat( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ float nRet(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_FLOAT,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (float)aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getInt( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nRet(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_LONG,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int32)aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSet::getRow( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_pSkipDeletedSet ? m_pSkipDeletedSet->getMappedPosition(getDriverPos()) : getDriverPos();
+}
+// -------------------------------------------------------------------------
+
+sal_Int64 SAL_CALL OResultSet::getLong( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ sal_Int64 nRet(0);
+ try
+ {
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_SBIGINT,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int64)aValue;
+ }
+ catch(SQLException&)
+ {
+ nRet = getString(columnIndex).toInt64();
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getMetaData" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(!m_xMetaData.is())
+ m_xMetaData = new OResultSetMetaData(m_pStatement->getOwnConnection(),m_aStatementHandle);
+ return m_xMetaData;
+}
+// -------------------------------------------------------------------------
+Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getArray", *this );
+ return NULL;
+}
+
+// -------------------------------------------------------------------------
+
+Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getClob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+Reference< XBlob > SAL_CALL OResultSet::getBlob( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getBlob", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 /*columnIndex*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRow::getRef", *this );
+ return NULL;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const Reference< ::com::sun::star::container::XNameAccess >& /*typeMap*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getObject" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ fillRow(columnIndex);
+ return m_aRow[columnIndex].makeAny();
+}
+// -------------------------------------------------------------------------
+
+sal_Int16 SAL_CALL OResultSet::getShort( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ sal_Int16 nRet(0);
+ const ORowSetValue& aValue = getValue(columnIndex,SQL_C_SHORT,&nRet,sizeof nRet);
+ return (&aValue == &m_aEmptyValue) ? nRet : (sal_Int16)aValue;
+}
+// -------------------------------------------------------------------------
+
+
+::rtl::OUString SAL_CALL OResultSet::getString( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getString" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ ::rtl::OUString nRet;
+ if ( m_bFetchData )
+ nRet = getValue(columnIndex,0,NULL,0);
+ else
+ {
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ const SWORD nColumnType = impl_getColumnType_nothrow(columnIndex);
+ nRet = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,nColumnType,m_bWasNull,**this,m_nTextEncoding);
+ }
+ return nRet;
+}
+// -------------------------------------------------------------------------
+
+Time SAL_CALL OResultSet::getTime( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTime" );
+ TIME_STRUCT aTime={0,0,0};
+ const ORowSetValue& aValue = getValue(columnIndex,
+ m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIME : SQL_C_TYPE_TIME,
+ &aTime,sizeof aTime);
+ return (&aValue == &m_aEmptyValue) ? Time(0,aTime.second,aTime.minute,aTime.hour) : (Time)aValue;
+}
+// -------------------------------------------------------------------------
+
+
+DateTime SAL_CALL OResultSet::getTimestamp( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getTimestamp" );
+ TIMESTAMP_STRUCT aTime={0,0,0,0,0,0,0};
+ const ORowSetValue& aValue = getValue(columnIndex,
+ m_pStatement->getOwnConnection()->useOldDateFormat() ? SQL_C_TIMESTAMP : SQL_C_TYPE_TIMESTAMP,
+ &aTime,sizeof aTime);
+ return (&aValue == &m_aEmptyValue)
+ ?
+ DateTime(static_cast<sal_uInt16>(aTime.fraction*1000),aTime.second,aTime.minute,aTime.hour,aTime.day,aTime.month,aTime.year)
+ :
+ (DateTime)aValue;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::isBeforeFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_nRowPos == 0;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isAfterLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nRowPos != 0 && m_nCurrentFetchState == SQL_NO_DATA;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isFirst( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return m_nRowPos == 1;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::isLast( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bEOF && m_nCurrentFetchState != SQL_NO_DATA;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::beforeFirst( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::beforeFirst" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ if(first())
+ previous();
+ m_nCurrentFetchState = SQL_SUCCESS;
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::afterLast( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::afterLast" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ if(last())
+ next();
+ m_bEOF = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::first( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::first" );
+ return moveImpl(IResultSetHelper::FIRST,0,sal_True);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::last( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::last" );
+ return moveImpl(IResultSetHelper::LAST,0,sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::absolute( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::absolute" );
+ return moveImpl(IResultSetHelper::ABSOLUTE,row,sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::relative( sal_Int32 row ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::relative" );
+ return moveImpl(IResultSetHelper::RELATIVE,row,sal_True);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::previous( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::previous" );
+ return moveImpl(IResultSetHelper::PRIOR,0,sal_True);
+}
+// -------------------------------------------------------------------------
+Reference< XInterface > SAL_CALL OResultSet::getStatement( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return m_xStatement;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::rowDeleted() throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowDeleted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Bool bRet = m_bRowDeleted;
+ m_bRowDeleted = sal_False;
+
+ return bRet;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowInserted( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowInserted" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ sal_Bool bInserted = m_bRowInserted;
+ m_bRowInserted = sal_False;
+
+ return bInserted;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::rowUpdated( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::rowUpdated" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_pRowStatusArray[0] == SQL_ROW_UPDATED;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::next( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::next" );
+ return moveImpl(IResultSetHelper::NEXT,1,sal_True);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSet::wasNull( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::wasNull" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ return m_bFetchData ? m_aRow[m_nLastColumnPos].isNull() : m_bWasNull;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ OTools::ThrowException(m_pStatement->getOwnConnection(),N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+Any SAL_CALL OResultSet::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ return Any();
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::insertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::insertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ SQLLEN nMaxLen = 20;
+ SQLLEN nRealLen = 0;
+ Sequence<sal_Int8> aBookmark(nMaxLen);
+
+ SQLRETURN nRet = N3SQLBindCol(m_aStatementHandle,
+ 0,
+ SQL_C_VARBOOKMARK,
+ aBookmark.getArray(),
+ nMaxLen,
+ &nRealLen
+ );
+ // Sequence<sal_Int8> aRealBookmark(nMaxLen);
+
+ sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
+ if ( bPositionByBookmark )
+ {
+ nRet = N3SQLBulkOperations( m_aStatementHandle, SQL_ADD );
+ fillNeededData( nRet );
+ }
+ else
+ {
+ if(isBeforeFirst())
+ next(); // must be done
+ nRet = N3SQLSetPos( m_aStatementHandle, 1, SQL_ADD, SQL_LOCK_NO_CHANGE );
+ fillNeededData( nRet );
+ }
+ try
+ {
+ OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ }
+ catch(SQLException e)
+ {
+ nRet = unbind();
+ throw;
+ }
+
+
+ if ( bPositionByBookmark )
+ {
+ nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,aBookmark.getArray(),SQL_IS_POINTER); // SQL_LEN_BINARY_ATTR(aBookmark.getLength())
+
+ nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
+ }
+ else
+ nRet = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0); // OJ 06.03.2004
+ // sometimes we got an error but we are not interested in anymore #106047# OJ
+ // OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ nRet = unbind();
+ OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ if(m_pSkipDeletedSet)
+ {
+ aBookmark.realloc(nRealLen);
+ if(moveToBookmark(makeAny(aBookmark)))
+ {
+ sal_Int32 nRowPos = getDriverPos();
+ if ( -1 == m_nRowPos )
+ {
+ nRowPos = m_aPosToBookmarks.size() + 1;
+ }
+ if ( nRowPos == m_nRowPos )
+ ++nRowPos;
+ m_nRowPos = nRowPos;
+ m_pSkipDeletedSet->insertNewPosition(nRowPos);
+ m_aPosToBookmarks[aBookmark] = nRowPos;
+ }
+ }
+ m_bRowInserted = sal_True;
+
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ SQLRETURN nRet;
+
+ sal_Bool bPositionByBookmark = ( NULL != getOdbcFunction( ODBC3SQLBulkOperations ) );
+ if ( bPositionByBookmark )
+ {
+ SQLLEN nRealLen = 0;
+ nRet = N3SQLBindCol(m_aStatementHandle,
+ 0,
+ SQL_C_VARBOOKMARK,
+ m_aBookmark.getArray(),
+ m_aBookmark.getLength(),
+ &nRealLen
+ );
+ fillNeededData(nRet = N3SQLBulkOperations(m_aStatementHandle, SQL_UPDATE_BY_BOOKMARK));
+ }
+ else
+ fillNeededData(nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_UPDATE,SQL_LOCK_NO_CHANGE));
+ OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ // now unbind all columns so we can fetch all columns again with SQLGetData
+ nRet = unbind();
+ OSL_ENSURE(nRet == SQL_SUCCESS,"Could not unbind the columns!");
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::deleteRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::deleteRow" );
+ SQLRETURN nRet = SQL_SUCCESS;
+ sal_Int32 nPos = getDriverPos();
+ nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_DELETE,SQL_LOCK_NO_CHANGE);
+ OTools::ThrowException(m_pStatement->getOwnConnection(),nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ m_bRowDeleted = ( m_pRowStatusArray[0] == SQL_ROW_DELETED );
+ if ( m_bRowDeleted )
+ {
+ TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
+ TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->second == nPos )
+ {
+ m_aPosToBookmarks.erase(aIter);
+ break;
+ }
+ }
+ }
+ if ( m_pSkipDeletedSet )
+ m_pSkipDeletedSet->deletePosition(nPos);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::cancelRowUpdates( ) throw(SQLException, RuntimeException)
+{
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToInsertRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToInsertRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ // first unbound all columns
+ OSL_VERIFY_EQUALS( unbind(), SQL_SUCCESS, "Could not unbind columns!" );
+ // SQLRETURN nRet = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE ,(SQLPOINTER)1,SQL_IS_INTEGER);
+ m_bInserting = sal_True;
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::moveToCurrentRow( ) throw(SQLException, RuntimeException)
+{
+ m_nLastColumnPos = 0;
+}
+// -------------------------------------------------------------------------
+void OResultSet::updateValue(sal_Int32 columnIndex,SQLSMALLINT _nType,void* _pValue) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::updateValue" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_aBindVector.push_back(allocBindColumn(OTools::MapOdbcType2Jdbc(_nType),columnIndex));
+ void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
+ OSL_ENSURE(pData != NULL,"Data for update is NULL!");
+ OTools::bindValue( m_pStatement->getOwnConnection(),
+ m_aStatementHandle,
+ columnIndex,
+ _nType,
+ 0,
+ _pValue,
+ pData,
+ &m_aLengthVector[columnIndex],
+ **this,
+ m_nTextEncoding,
+ m_pStatement->getOwnConnection()->useOldDateFormat());
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateNull( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_aBindVector.push_back(allocBindColumn(DataType::CHAR,columnIndex));
+ void* pData = reinterpret_cast<void*>(m_aBindVector.rbegin()->first);
+ OTools::bindValue(m_pStatement->getOwnConnection(),m_aStatementHandle,columnIndex,SQL_CHAR,0,(sal_Int8*)NULL,pData,&m_aLengthVector[columnIndex],**this,m_nTextEncoding,m_pStatement->getOwnConnection()->useOldDateFormat());
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBoolean( sal_Int32 columnIndex, sal_Bool x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_BIT,&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateByte( sal_Int32 columnIndex, sal_Int8 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_CHAR,&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateShort( sal_Int32 columnIndex, sal_Int16 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_TINYINT,&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateInt( sal_Int32 columnIndex, sal_Int32 x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_INTEGER,&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateLong( sal_Int32 /*columnIndex*/, sal_Int64 /*x*/ ) throw(SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRowUpdate::updateLong", *this );
+}
+// -----------------------------------------------------------------------
+void SAL_CALL OResultSet::updateFloat( sal_Int32 columnIndex, float x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_REAL,&x);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateDouble( sal_Int32 columnIndex, double x ) throw(SQLException, RuntimeException)
+{
+ updateValue(columnIndex,SQL_DOUBLE,&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateString( sal_Int32 columnIndex, const ::rtl::OUString& x ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
+ SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
+ m_aRow[columnIndex] = x;
+ m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarchar will be recognized by fillNeededData
+ updateValue(columnIndex,nOdbcType,(void*)&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateBytes( sal_Int32 columnIndex, const Sequence< sal_Int8 >& x ) throw(SQLException, RuntimeException)
+{
+ sal_Int32 nType = m_aRow[columnIndex].getTypeKind();
+ SQLSMALLINT nOdbcType = static_cast<SQLSMALLINT>(OTools::jdbcTypeToOdbc(nType));
+ m_aRow[columnIndex] = x;
+ m_aRow[columnIndex].setTypeKind(nType); // OJ: otherwise longvarbinary will be recognized by fillNeededData
+ updateValue(columnIndex,nOdbcType,(void*)&x);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateDate( sal_Int32 columnIndex, const Date& x ) throw(SQLException, RuntimeException)
+{
+ DATE_STRUCT aVal = OTools::DateToOdbcDate(x);
+ updateValue(columnIndex,SQL_DATE,&aVal);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTime( sal_Int32 columnIndex, const Time& x ) throw(SQLException, RuntimeException)
+{
+ TIME_STRUCT aVal = OTools::TimeToOdbcTime(x);
+ updateValue(columnIndex,SQL_TIME,&aVal);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateTimestamp( sal_Int32 columnIndex, const DateTime& x ) throw(SQLException, RuntimeException)
+{
+ TIMESTAMP_STRUCT aVal = OTools::DateTimeToTimestamp(x);
+ updateValue(columnIndex,SQL_TIMESTAMP,&aVal);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateBinaryStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ if(!x.is())
+ ::dbtools::throwFunctionSequenceException(*this);
+
+ Sequence<sal_Int8> aSeq;
+ x->readBytes(aSeq,length);
+ updateBytes(columnIndex,aSeq);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateCharacterStream( sal_Int32 columnIndex, const Reference< XInputStream >& x, sal_Int32 length ) throw(SQLException, RuntimeException)
+{
+ updateBinaryStream(columnIndex,x,length);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::refreshRow( ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::refreshRow" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ // SQLRETURN nRet = N3SQLSetPos(m_aStatementHandle,1,SQL_REFRESH,SQL_LOCK_NO_CHANGE);
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_RELATIVE,0);
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -------------------------------------------------------------------------
+void SAL_CALL OResultSet::updateObject( sal_Int32 columnIndex, const Any& x ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OResultSet::updateNumericObject( sal_Int32 columnIndex, const Any& x, sal_Int32 /*scale*/ ) throw(SQLException, RuntimeException)
+{
+ if (!::dbtools::implUpdateObject(this, columnIndex, x))
+ throw SQLException();
+}
+// -------------------------------------------------------------------------
+// XRowLocate
+Any SAL_CALL OResultSet::getBookmark( ) throw( SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::getBookmark" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ TBookmarkPosMap::iterator aFind = ::std::find_if(m_aPosToBookmarks.begin(),m_aPosToBookmarks.end(),
+ ::std::compose1(::std::bind2nd(::std::equal_to<sal_Int32>(),m_nRowPos),::std::select2nd<TBookmarkPosMap::value_type>()));
+
+ if ( aFind == m_aPosToBookmarks.end() )
+ {
+ if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
+ m_nUseBookmarks = SQL_UB_OFF;
+ SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+ OSL_UNUSED( nRet );
+ }
+ if(m_nUseBookmarks == SQL_UB_OFF)
+ throw SQLException();
+
+ m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
+ m_aPosToBookmarks[m_aBookmark] = m_nRowPos;
+ OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
+ }
+ else
+ m_aBookmark = aFind->first;
+ return makeAny(m_aBookmark);
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::moveToBookmark( const Any& bookmark ) throw( SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveToBookmark" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ m_nLastColumnPos = 0;
+ bookmark >>= m_aBookmark;
+ OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
+ if(m_aBookmark.getLength())
+ {
+ SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,m_aBookmark.getArray(),SQL_IS_POINTER); // SQL_LEN_BINARY_ATTR(aBookmark.getLength())
+ OSL_UNUSED( nReturn );
+
+ if ( SQL_INVALID_HANDLE != nReturn && SQL_ERROR != nReturn )
+ {
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,0);
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ TBookmarkPosMap::iterator aFind = m_aPosToBookmarks.find(m_aBookmark);
+ if(aFind != m_aPosToBookmarks.end())
+ m_nRowPos = aFind->second;
+ else
+ m_nRowPos = -1;
+ return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ }
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::moveRelativeToBookmark( const Any& bookmark, sal_Int32 rows ) throw( SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::moveRelativeToBookmark" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+
+ m_nLastColumnPos = 0;
+ bookmark >>= m_aBookmark;
+ SQLRETURN nReturn = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_FETCH_BOOKMARK_PTR,m_aBookmark.getArray(),SQL_IS_POINTER);
+ OSL_UNUSED( nReturn );
+
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,SQL_FETCH_BOOKMARK,rows);
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ return m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::compareBookmarks( const Any& lhs, const Any& rhs ) throw( SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::compareBookmarks" );
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+
+ return (lhs == rhs) ? CompareBookmark::EQUAL : CompareBookmark::NOT_EQUAL;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSet::hasOrderedBookmarks( ) throw( SQLException, RuntimeException)
+{
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSet::hashBookmark( const Any& /*bookmark*/ ) throw( SQLException, RuntimeException)
+{
+ ::dbtools::throwFunctionNotSupportedException( "XRowLocate::hashBookmark", *this );
+ return 0;
+}
+// -------------------------------------------------------------------------
+// XDeleteRows
+Sequence< sal_Int32 > SAL_CALL OResultSet::deleteRows( const Sequence< Any >& rows ) throw( SQLException, RuntimeException)
+{
+ Sequence< sal_Int32 > aRet(rows.getLength());
+ sal_Int32 *pRet = aRet.getArray();
+
+ const Any *pBegin = rows.getConstArray();
+ const Any *pEnd = pBegin + rows.getLength();
+
+ for(;pBegin != pEnd;++pBegin,++pRet)
+ {
+ try
+ {
+ if(moveToBookmark(*pBegin))
+ {
+ deleteRow();
+ *pRet = 1;
+ }
+ }
+ catch(SQLException&)
+ {
+ *pRet = 0;
+ }
+ }
+ return aRet;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getResultSetConcurrency() const
+{
+ sal_uInt32 nValue = 0;
+ SQLRETURN nReturn = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0);
+ OSL_UNUSED( nReturn );
+ if(SQL_CONCUR_READ_ONLY == nValue)
+ nValue = ResultSetConcurrency::READ_ONLY;
+ else
+ nValue = ResultSetConcurrency::UPDATABLE;
+
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getResultSetType() const
+{
+ sal_uInt32 nValue = 0;
+ N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0);
+ if(SQL_SENSITIVE == nValue)
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ else if(SQL_INSENSITIVE == nValue)
+ nValue = ResultSetType::SCROLL_INSENSITIVE;
+ else
+ {
+ SQLINTEGER nCurType = 0;
+ N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nCurType,SQL_IS_UINTEGER,0);
+ if(SQL_CURSOR_KEYSET_DRIVEN == nCurType)
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ else if(SQL_CURSOR_STATIC == nCurType)
+ nValue = ResultSetType::SCROLL_INSENSITIVE;
+ else if(SQL_CURSOR_FORWARD_ONLY == nCurType)
+ nValue = ResultSetType::FORWARD_ONLY;
+ else if(SQL_CURSOR_DYNAMIC == nCurType)
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ }
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getFetchDirection() const
+{
+ return FetchDirection::FORWARD;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OResultSet::getFetchSize() const
+{
+ sal_uInt32 nValue = 0;
+ N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0);
+ return nValue;
+}
+//------------------------------------------------------------------------------
+::rtl::OUString OResultSet::getCursorName() const
+{
+ SQLCHAR pName[258];
+ SQLSMALLINT nRealLen = 0;
+ N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen);
+ return ::rtl::OUString::createFromAscii((const char*)pName);
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::isBookmarkable() const
+{
+ if(!m_aConnectionHandle)
+ return sal_False;
+
+ sal_uInt32 nValue = 0;
+ N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0);
+
+ sal_Int32 nAttr = 0;
+ try
+ {
+ switch(nValue)
+ {
+ case SQL_CURSOR_FORWARD_ONLY:
+ return sal_False;
+ case SQL_CURSOR_STATIC:
+ OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_STATIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
+ break;
+ case SQL_CURSOR_KEYSET_DRIVEN:
+ OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_KEYSET_CURSOR_ATTRIBUTES1,nAttr,NULL);
+ break;
+ case SQL_CURSOR_DYNAMIC:
+ OTools::GetInfo(m_pStatement->getOwnConnection(),m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nAttr,NULL);
+ break;
+ }
+ }
+ catch(Exception&)
+ {
+ return sal_False;
+ }
+
+ if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+ {
+ m_nUseBookmarks = SQL_UB_OFF;
+ SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+ OSL_UNUSED( nRet );
+ }
+
+ return (m_nUseBookmarks != SQL_UB_OFF) && (nAttr & SQL_CA1_BOOKMARK) == SQL_CA1_BOOKMARK;
+}
+//------------------------------------------------------------------------------
+void OResultSet::setFetchDirection(sal_Int32 _par0)
+{
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+}
+//------------------------------------------------------------------------------
+void OResultSet::setFetchSize(sal_Int32 _par0)
+{
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ delete m_pRowStatusArray;
+ m_pRowStatusArray = new SQLUSMALLINT[_par0];
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper* OResultSet::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(6);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP1IMPL(CURSORNAME, ::rtl::OUString) PropertyAttribute::READONLY);
+ DECL_PROP0(FETCHDIRECTION, sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETCONCURRENCY,sal_Int32) PropertyAttribute::READONLY);
+ DECL_PROP1IMPL(RESULTSETTYPE, sal_Int32) PropertyAttribute::READONLY);
+
+ return new OPropertyArrayHelper(aProps);
+}
+// -------------------------------------------------------------------------
+IPropertyArrayHelper & OResultSet::getInfoHelper()
+{
+ return *const_cast<OResultSet*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OResultSet::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw ::com::sun::star::lang::IllegalArgumentException();
+ case PROPERTY_ID_FETCHDIRECTION:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ case PROPERTY_ID_FETCHSIZE:
+ return ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ default:
+ ;
+ }
+ return sal_False;
+}
+// -------------------------------------------------------------------------
+void OResultSet::setFastPropertyValue_NoBroadcast(
+ sal_Int32 nHandle,
+ const Any& rValue
+ )
+ throw (Exception)
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ case PROPERTY_ID_CURSORNAME:
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ case PROPERTY_ID_RESULTSETTYPE:
+ throw Exception();
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(getINT32(rValue));
+ break;
+ default:
+ ;
+ }
+}
+// -------------------------------------------------------------------------
+void OResultSet::getFastPropertyValue(
+ Any& rValue,
+ sal_Int32 nHandle
+ ) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_ISBOOKMARKABLE:
+ rValue = bool2any(isBookmarkable());
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+void OResultSet::fillRow(sal_Int32 _nToColumn)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillRow" );
+ if((sal_Int32)m_aRow.size() <= _nToColumn)
+ {
+ m_aRow.resize(_nToColumn+1);
+ m_aRow[_nToColumn].setBound(sal_True);
+ }
+ m_bFetchData = sal_False;
+
+ sal_Int32 nColumn = m_nLastColumnPos + 1;
+ TDataRow::iterator pColumn = m_aRow.begin() + nColumn;
+ TDataRow::iterator pColumnEnd = m_aRow.begin() + _nToColumn + 1;
+
+ for (; pColumn < pColumnEnd; ++nColumn, ++pColumn)
+ {
+ const sal_Int32 nType = pColumn->getTypeKind();
+ switch (nType)
+ {
+ case DataType::CHAR:
+ case DataType::VARCHAR:
+ case DataType::DECIMAL:
+ case DataType::NUMERIC:
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ {
+ const SWORD nColumnType = impl_getColumnType_nothrow(nColumn);
+ *pColumn = OTools::getStringValue(m_pStatement->getOwnConnection(),m_aStatementHandle,nColumn,nColumnType,m_bWasNull,**this,m_nTextEncoding);
+ }
+ break;
+ case DataType::BIGINT:
+ *pColumn = getLong(nColumn);
+ break;
+ case DataType::REAL:
+ case DataType::DOUBLE:
+ *pColumn = getDouble(nColumn);
+ break;
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ *pColumn = getBytes(nColumn);
+ break;
+ case DataType::DATE:
+ *pColumn = getDate(nColumn);
+ break;
+ case DataType::TIME:
+ *pColumn = getTime(nColumn);
+ break;
+ case DataType::TIMESTAMP:
+ *pColumn = getTimestamp(nColumn);
+ break;
+ case DataType::BIT:
+ *pColumn = getBoolean(nColumn);
+ break;
+ case DataType::TINYINT:
+ *pColumn = getByte(nColumn);
+ break;
+ case DataType::SMALLINT:
+ *pColumn = getShort(nColumn);
+ break;
+ case DataType::INTEGER:
+ *pColumn = getInt(nColumn);
+ break;
+ case DataType::FLOAT:
+ *pColumn = getFloat(nColumn);
+ break;
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ *pColumn = getBytes(nColumn);
+ break;
+ }
+
+ if ( m_bWasNull )
+ pColumn->setNull();
+ if(nType != pColumn->getTypeKind())
+ {
+ pColumn->setTypeKind(nType);
+ }
+ }
+ m_nLastColumnPos = _nToColumn;
+ m_bFetchData = sal_True;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::acquire() throw()
+{
+ OResultSet_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OResultSet::release() throw()
+{
+ OResultSet_BASE::release();
+}
+// -----------------------------------------------------------------------------
+::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::move(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool /*_bRetrieveData*/)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::move" );
+ SQLSMALLINT nFetchOrientation = SQL_FETCH_NEXT;
+ switch(_eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ nFetchOrientation = SQL_FETCH_NEXT;
+ break;
+ case IResultSetHelper::PRIOR:
+ nFetchOrientation = SQL_FETCH_PRIOR;
+ break;
+ case IResultSetHelper::FIRST:
+ nFetchOrientation = SQL_FETCH_FIRST;
+ break;
+ case IResultSetHelper::LAST:
+ nFetchOrientation = SQL_FETCH_LAST;
+ break;
+ case IResultSetHelper::RELATIVE:
+ nFetchOrientation = SQL_FETCH_RELATIVE;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ nFetchOrientation = SQL_FETCH_ABSOLUTE;
+ break;
+ case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
+ {
+ TBookmarkPosMap::iterator aIter = m_aPosToBookmarks.begin();
+ TBookmarkPosMap::iterator aEnd = m_aPosToBookmarks.end();
+ for (; aIter != aEnd; ++aIter)
+ {
+ if ( aIter->second == _nOffset )
+ return moveToBookmark(makeAny(aIter->first));
+ }
+ OSL_ENSURE(0,"Bookmark not found!");
+ }
+ return sal_False;
+ }
+
+ m_bEOF = sal_False;
+ m_nLastColumnPos = 0;
+
+ SQLRETURN nOldFetchStatus = m_nCurrentFetchState;
+ if ( !m_bUseFetchScroll && _eCursorPosition == IResultSetHelper::NEXT )
+ m_nCurrentFetchState = N3SQLFetch(m_aStatementHandle);
+ else
+ m_nCurrentFetchState = N3SQLFetchScroll(m_aStatementHandle,nFetchOrientation,_nOffset);
+
+ OSL_TRACE( __FILE__": OSkipDeletedSet::OResultSet::move(%d,%d), FetchState = %d",nFetchOrientation,_nOffset,m_nCurrentFetchState);
+ OTools::ThrowException(m_pStatement->getOwnConnection(),m_nCurrentFetchState,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+
+ const bool bSuccess = m_nCurrentFetchState == SQL_SUCCESS || m_nCurrentFetchState == SQL_SUCCESS_WITH_INFO;
+ if ( bSuccess )
+ {
+ switch(_eCursorPosition)
+ {
+ case IResultSetHelper::NEXT:
+ ++m_nRowPos;
+ break;
+ case IResultSetHelper::PRIOR:
+ --m_nRowPos;
+ break;
+ case IResultSetHelper::FIRST:
+ m_nRowPos = 1;
+ break;
+ case IResultSetHelper::LAST:
+ m_bEOF = sal_True;
+ break;
+ case IResultSetHelper::RELATIVE:
+ m_nRowPos += _nOffset;
+ break;
+ case IResultSetHelper::ABSOLUTE:
+ case IResultSetHelper::BOOKMARK: // special case here because we are only called with position numbers
+ m_nRowPos = _nOffset;
+ break;
+ } // switch(_eCursorPosition)
+ if ( m_nUseBookmarks == ODBC_SQL_NOT_DEFINED )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "SQLGetStmtAttr" );
+ m_nUseBookmarks = SQL_UB_OFF;
+ SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&m_nUseBookmarks,SQL_IS_UINTEGER,NULL);
+ OSL_UNUSED( nRet );
+ }
+ if ( m_nUseBookmarks != SQL_UB_OFF )
+ {
+ RTL_LOGFILE_CONTEXT_TRACE( aLogger, "OTools::getBytesValue" );
+ m_aBookmark = OTools::getBytesValue(m_pStatement->getOwnConnection(),m_aStatementHandle,0,SQL_C_VARBOOKMARK,m_bWasNull,**this);
+ m_aPosToBookmarks[m_aBookmark] = m_nRowPos;
+ OSL_ENSURE(m_aBookmark.getLength(),"Invalid bookmark from length 0!");
+ }
+ }
+ else if ( IResultSetHelper::PRIOR == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA )
+ m_nRowPos = 0;
+ else if(IResultSetHelper::NEXT == _eCursorPosition && m_nCurrentFetchState == SQL_NO_DATA && nOldFetchStatus != SQL_NO_DATA)
+ ++m_nRowPos;
+
+ return bSuccess;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 OResultSet::getDriverPos() const
+{
+ sal_Int32 nValue = 0;
+ SQLRETURN nRet = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_NUMBER,&nValue,SQL_IS_UINTEGER,0);
+ OSL_UNUSED( nRet );
+ OSL_TRACE( __FILE__": OResultSet::getDriverPos() = Ret = %d, RowNum = %d, RowPos = %d",nRet,nValue , m_nRowPos);
+ return nValue ? nValue : m_nRowPos;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::deletedVisible() const
+{
+ return sal_False;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::isRowDeleted() const
+{
+ return m_pRowStatusArray[0] == SQL_ROW_DELETED;
+}
+// -----------------------------------------------------------------------------
+sal_Bool OResultSet::moveImpl(IResultSetHelper::Movement _eCursorPosition, sal_Int32 _nOffset, sal_Bool _bRetrieveData)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
+ return (m_pSkipDeletedSet != NULL)
+ ? m_pSkipDeletedSet->skipDeleted(_eCursorPosition,_nOffset,_bRetrieveData)
+ : move(_eCursorPosition,_nOffset,_bRetrieveData);
+}
+// -----------------------------------------------------------------------------
+void OResultSet::fillNeededData(SQLRETURN _nRet)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSet::fillNeededData" );
+ SQLRETURN nRet = _nRet;
+ if( nRet == SQL_NEED_DATA)
+ {
+ void* pColumnIndex = 0;
+ nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
+
+ do
+ {
+ if (nRet != SQL_SUCCESS && nRet != SQL_SUCCESS_WITH_INFO && nRet != SQL_NEED_DATA)
+ break;
+
+ sal_IntPtr nColumnIndex ( reinterpret_cast<sal_IntPtr>(pColumnIndex));
+ Sequence< sal_Int8 > aSeq;
+ switch(m_aRow[nColumnIndex].getTypeKind())
+ {
+ case DataType::BINARY:
+ case DataType::VARBINARY:
+ case DataType::LONGVARBINARY:
+ case DataType::BLOB:
+ aSeq = m_aRow[nColumnIndex];
+ N3SQLPutData (m_aStatementHandle, aSeq.getArray(), aSeq.getLength());
+ break;
+ case SQL_WLONGVARCHAR:
+ {
+ ::rtl::OUString sRet;
+ sRet = m_aRow[nColumnIndex].getString();
+ nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)sRet.getStr(), sizeof(sal_Unicode)*sRet.getLength());
+ break;
+ }
+ case DataType::LONGVARCHAR:
+ case DataType::CLOB:
+ {
+ ::rtl::OUString sRet;
+ sRet = m_aRow[nColumnIndex].getString();
+ ::rtl::OString aString(::rtl::OUStringToOString(sRet,m_nTextEncoding));
+ nRet = N3SQLPutData (m_aStatementHandle, (SQLPOINTER)aString.getStr(), aString.getLength());
+ break;
+ }
+ default:
+ OSL_ENSURE(0,"Not supported at the moment!");
+ }
+ nRet = N3SQLParamData(m_aStatementHandle,&pColumnIndex);
+ }
+ while (nRet == SQL_NEED_DATA);
+ }
+}
+// -----------------------------------------------------------------------------
+SWORD OResultSet::impl_getColumnType_nothrow(sal_Int32 columnIndex)
+{
+ ::std::map<sal_Int32,SWORD>::iterator aFind = m_aODBCColumnTypes.find(columnIndex);
+ if ( aFind == m_aODBCColumnTypes.end() )
+ aFind = m_aODBCColumnTypes.insert(::std::map<sal_Int32,SWORD>::value_type(columnIndex,OResultSetMetaData::getColumnODBCType(m_pStatement->getOwnConnection(),m_aStatementHandle,*this,columnIndex))).first;
+ return aFind->second;
+}
+
diff --git a/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
new file mode 100644
index 000000000000..db4538b76e10
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OResultSetMetaData.cxx
@@ -0,0 +1,312 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/OResultSetMetaData.hxx"
+#include "odbc/OTools.hxx"
+#include <rtl/logfile.hxx>
+
+using namespace connectivity::odbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::sdbc;
+
+// -------------------------------------------------------------------------
+OResultSetMetaData::~OResultSetMetaData()
+{
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OResultSetMetaData::getCharColAttrib(sal_Int32 _column,sal_Int32 ident) throw(SQLException, RuntimeException)
+{
+ sal_Int32 column = _column;
+ if(_column <(sal_Int32) m_vMapping.size()) // use mapping
+ column = m_vMapping[_column];
+
+ SQLSMALLINT BUFFER_LEN = 128;
+ char *pName = new char[BUFFER_LEN+1];
+ SQLSMALLINT nRealLen=0;
+ SQLRETURN nRet = N3SQLColAttribute(m_aStatementHandle,
+ (SQLUSMALLINT)column,
+ (SQLUSMALLINT)ident,
+ (SQLPOINTER)pName,
+ BUFFER_LEN,
+ &nRealLen,
+ NULL
+ );
+ ::rtl::OUString sValue;
+ if ( nRet == SQL_SUCCESS )
+ sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding());
+ delete [] pName;
+ OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ if(nRealLen > BUFFER_LEN)
+ {
+ pName = new char[nRealLen+1];
+ nRet = N3SQLColAttribute(m_aStatementHandle,
+ (SQLUSMALLINT)column,
+ (SQLUSMALLINT)ident,
+ (SQLPOINTER)pName,
+ nRealLen,
+ &nRealLen,
+ NULL
+ );
+ if ( nRet == SQL_SUCCESS )
+ sValue = ::rtl::OUString(pName,nRealLen,m_pConnection->getTextEncoding());
+ delete [] pName;
+ OTools::ThrowException(m_pConnection,nRet,m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ }
+
+ return sValue;
+}
+// -------------------------------------------------------------------------
+SQLLEN OResultSetMetaData::getNumColAttrib(OConnection* _pConnection
+ ,SQLHANDLE _aStatementHandle
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface
+ ,sal_Int32 _column
+ ,sal_Int32 _ident) throw(SQLException, RuntimeException)
+{
+ SQLLEN nValue=0;
+ OTools::ThrowException(_pConnection,(*(T3SQLColAttribute)_pConnection->getOdbcFunction(ODBC3SQLColAttribute))(_aStatementHandle,
+ (SQLUSMALLINT)_column,
+ (SQLUSMALLINT)_ident,
+ NULL,
+ 0,
+ NULL,
+ &nValue),_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ return nValue;
+}
+// -------------------------------------------------------------------------
+sal_Int32 OResultSetMetaData::getNumColAttrib(sal_Int32 _column,sal_Int32 ident) throw(SQLException, RuntimeException)
+{
+ sal_Int32 column = _column;
+ if(_column < (sal_Int32)m_vMapping.size()) // use mapping
+ column = m_vMapping[_column];
+
+ return getNumColAttrib(m_pConnection,m_aStatementHandle,*this,column,ident);
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnDisplaySize( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getNumColAttrib(column,SQL_DESC_DISPLAY_SIZE);
+}
+// -------------------------------------------------------------------------
+SQLSMALLINT OResultSetMetaData::getColumnODBCType(OConnection* _pConnection
+ ,SQLHANDLE _aStatementHandle
+ ,const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface
+ ,sal_Int32 column)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ SQLSMALLINT nType = 0;
+ try
+ {
+ nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE);
+ if(nType == SQL_UNKNOWN_TYPE)
+ nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column, SQL_DESC_TYPE);
+ }
+ catch(SQLException& ) // in this case we have an odbc 2.0 driver
+ {
+ nType = (SQLSMALLINT)getNumColAttrib(_pConnection,_aStatementHandle,_xInterface,column,SQL_DESC_CONCISE_TYPE );
+ }
+
+ return nType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnType( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ ::std::map<sal_Int32,sal_Int32>::iterator aFind = m_aColumnTypes.find(column);
+ if ( aFind == m_aColumnTypes.end() )
+ {
+ sal_Int32 nType = 0;
+ if(!m_bUseODBC2Types)
+ {
+ try
+ {
+ nType = getNumColAttrib(column,SQL_DESC_CONCISE_TYPE);
+ if(nType == SQL_UNKNOWN_TYPE)
+ nType = getNumColAttrib(column, SQL_DESC_TYPE);
+ nType = OTools::MapOdbcType2Jdbc(nType);
+ }
+ catch(SQLException& ) // in this case we have an odbc 2.0 driver
+ {
+ m_bUseODBC2Types = sal_True;
+ nType = OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_CONCISE_TYPE ));
+ }
+ }
+ else
+ nType = OTools::MapOdbcType2Jdbc(getNumColAttrib(column,SQL_DESC_CONCISE_TYPE ));
+ aFind = m_aColumnTypes.insert(::std::map<sal_Int32,sal_Int32>::value_type(column,nType)).first;
+ }
+
+
+ return aFind->second;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::getColumnCount( ) throw(SQLException, RuntimeException)
+{
+ if(m_nColCount != -1)
+ return m_nColCount;
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnCount" );
+ sal_Int16 nNumResultCols=0;
+ OTools::ThrowException(m_pConnection,N3SQLNumResultCols(m_aStatementHandle,&nNumResultCols),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+ return m_nColCount = nNumResultCols;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCaseSensitive( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getNumColAttrib(column,SQL_DESC_CASE_SENSITIVE) == SQL_TRUE;
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getSchemaName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getCharColAttrib(column,SQL_DESC_SCHEMA_NAME);
+}
+// -------------------------------------------------------------------------
+
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getCharColAttrib(column,SQL_DESC_NAME);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getTableName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getCharColAttrib(column,SQL_DESC_TABLE_NAME);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getCatalogName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getCharColAttrib(column,SQL_DESC_CATALOG_NAME);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnTypeName( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnTypeName" );
+ return getCharColAttrib(column,SQL_DESC_TYPE_NAME);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnLabel( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnLabel" );
+ return getCharColAttrib(column,SQL_DESC_LABEL);
+}
+// -------------------------------------------------------------------------
+::rtl::OUString SAL_CALL OResultSetMetaData::getColumnServiceName( sal_Int32 /*column*/ ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getColumnServiceName" );
+ return ::rtl::OUString();
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isCurrency( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getNumColAttrib(column,SQL_DESC_FIXED_PREC_SCALE) == SQL_TRUE;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isAutoIncrement( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ return getNumColAttrib(column,SQL_DESC_AUTO_UNIQUE_VALUE) == SQL_TRUE;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Bool SAL_CALL OResultSetMetaData::isSigned( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSigned" );
+ return getNumColAttrib(column,SQL_DESC_UNSIGNED) == SQL_FALSE;
+}
+// -------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getPrecision( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getPrecision" );
+ sal_Int32 nType = 0;
+ try
+ {
+ nType = getNumColAttrib(column,SQL_DESC_PRECISION);
+ }
+ catch(const SQLException& ) // in this case we have an odbc 2.0 driver
+ {
+ m_bUseODBC2Types = sal_True;
+ nType = getNumColAttrib(column,SQL_COLUMN_PRECISION );
+ }
+ return nType;
+}
+// -----------------------------------------------------------------------------
+sal_Int32 SAL_CALL OResultSetMetaData::getScale( sal_Int32 column ) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::getScale" );
+ sal_Int32 nType = 0;
+ try
+ {
+ nType = getNumColAttrib(column,SQL_DESC_SCALE);
+ }
+ catch(const SQLException& ) // in this case we have an odbc 2.0 driver
+ {
+ m_bUseODBC2Types = sal_True;
+ nType = getNumColAttrib(column,SQL_COLUMN_SCALE );
+ }
+ return nType;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OResultSetMetaData::isNullable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isNullable" );
+ return getNumColAttrib(column,SQL_DESC_NULLABLE);
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isSearchable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isSearchable" );
+ return getNumColAttrib(column,SQL_DESC_SEARCHABLE) != SQL_PRED_NONE;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isReadOnly( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isReadOnly" );
+ return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_READONLY;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OResultSetMetaData::isDefinitelyWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isDefinitelyWritable" );
+ return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE;
+;
+}
+// -------------------------------------------------------------------------
+sal_Bool SAL_CALL OResultSetMetaData::isWritable( sal_Int32 column ) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OResultSetMetaData::isWritable" );
+ return getNumColAttrib(column,SQL_DESC_UPDATABLE) == SQL_ATTR_WRITE;
+}
+// -------------------------------------------------------------------------
+
diff --git a/connectivity/source/drivers/odbcbase/OStatement.cxx b/connectivity/source/drivers/odbcbase/OStatement.cxx
new file mode 100644
index 000000000000..874e24c20e75
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OStatement.cxx
@@ -0,0 +1,1154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+
+#include <stdio.h>
+#include <osl/diagnose.h>
+#include "odbc/OStatement.hxx"
+#include "odbc/OConnection.hxx"
+#include "odbc/OResultSet.hxx"
+#include <comphelper/property.hxx>
+#include "odbc/OTools.hxx"
+#include <comphelper/uno3.hxx>
+#include <osl/thread.h>
+#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
+#include <com/sun/star/sdbc/ResultSetType.hpp>
+#include <com/sun/star/sdbc/FetchDirection.hpp>
+#include <com/sun/star/lang/DisposedException.hpp>
+#include <comphelper/sequence.hxx>
+#include <cppuhelper/typeprovider.hxx>
+#include <comphelper/extract.hxx>
+#include <comphelper/types.hxx>
+#include "diagnose_ex.h"
+#include <algorithm>
+#include "resource/common_res.hrc"
+#include "connectivity/dbexception.hxx"
+
+using namespace ::comphelper;
+
+#define THROW_SQL(x) \
+ OTools::ThrowException(m_pConnection,x,m_aStatementHandle,SQL_HANDLE_STMT,*this)
+
+#if OSL_DEBUG_LEVEL > 1
+#define DEBUG_THROW \
+ try \
+ { \
+ THROW_SQL(nRetCode); \
+ } \
+ catch(SQLException&) \
+ { \
+ OSL_ENSURE(0,"Exception in odbc catched"); \
+ }
+#endif
+
+
+
+using namespace connectivity::odbc;
+//------------------------------------------------------------------------------
+using namespace com::sun::star::uno;
+using namespace com::sun::star::lang;
+using namespace com::sun::star::beans;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::sdbcx;
+using namespace com::sun::star::container;
+using namespace com::sun::star::io;
+using namespace com::sun::star::util;
+//------------------------------------------------------------------------------
+OStatement_Base::OStatement_Base(OConnection* _pConnection )
+ :OStatement_BASE(m_aMutex)
+ ,OPropertySetHelper(OStatement_BASE::rBHelper)
+ ,m_pConnection(_pConnection)
+ ,m_aStatementHandle(SQL_NULL_HANDLE)
+ ,m_pRowStatusArray(0)
+ ,rBHelper(OStatement_BASE::rBHelper)
+{
+ osl_incrementInterlockedCount( &m_refCount );
+ m_pConnection->acquire();
+ m_aStatementHandle = m_pConnection->createStatementHandle();
+
+ //setMaxFieldSize(0);
+ // Don't do this. By ODBC spec, "0" is the default for the SQL_ATTR_MAX_LENGTH attribute. We once introduced
+ // this line since an PostgreSQL ODBC driver had a default other than 0. However, current drivers (at least 8.3
+ // and later) have a proper default of 0, so there should be no need anymore.
+ // On the other hand, the NotesSQL driver (IBM's ODBC driver for the Lotus Notes series) wrongly interprets
+ // "0" as "0", whereas the ODBC spec says it should in fact mean "unlimited".
+ // So, removing this line seems to be the best option for now.
+ // If we ever again encounter a ODBC driver which needs this option, then we should introduce a data source
+ // setting for it, instead of unconditionally doing it.
+
+ osl_decrementInterlockedCount( &m_refCount );
+}
+// -----------------------------------------------------------------------------
+OStatement_Base::~OStatement_Base()
+{
+ OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::disposeResultSet()
+{
+ // free the cursor if alive
+ Reference< XComponent > xComp(m_xResultSet.get(), UNO_QUERY);
+ if (xComp.is())
+ xComp->dispose();
+ m_xResultSet = Reference< XResultSet>();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::disposing(void)
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ disposeResultSet();
+ ::comphelper::disposeComponent(m_xGeneratedStatement);
+
+ OSL_ENSURE(m_aStatementHandle,"OStatement_BASE2::disposing: StatementHandle is null!");
+ if (m_pConnection)
+ {
+ m_pConnection->freeStatementHandle(m_aStatementHandle);
+ m_pConnection->release();
+ m_pConnection = NULL;
+ }
+ OSL_ENSURE(!m_aStatementHandle,"Sohould ne null here!");
+
+ OStatement_BASE::disposing();
+}
+//------------------------------------------------------------------------------
+void OStatement_BASE2::disposing()
+{
+ ::osl::MutexGuard aGuard(m_aMutex);
+
+ dispose_ChildImpl();
+ OStatement_Base::disposing();
+}
+//-----------------------------------------------------------------------------
+void SAL_CALL OStatement_BASE2::release() throw()
+{
+ relase_ChildImpl();
+}
+//-----------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() && rType == ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ) )
+ return Any();
+ Any aRet = OStatement_BASE::queryInterface(rType);
+ return aRet.hasValue() ? aRet : OPropertySetHelper::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+Sequence< Type > SAL_CALL OStatement_Base::getTypes( ) throw(RuntimeException)
+{
+ ::cppu::OTypeCollection aTypes( ::getCppuType( (const Reference< XMultiPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XFastPropertySet > *)0 ),
+ ::getCppuType( (const Reference< XPropertySet > *)0 ));
+ Sequence< Type > aOldTypes = OStatement_BASE::getTypes();
+ if ( m_pConnection && !m_pConnection->isAutoRetrievingEnabled() )
+ {
+ ::std::remove(aOldTypes.getArray(),aOldTypes.getArray() + aOldTypes.getLength(),
+ ::getCppuType( (const Reference< XGeneratedResultSet > *)0 ));
+ aOldTypes.realloc(aOldTypes.getLength() - 1);
+ }
+
+ return ::comphelper::concatSequences(aTypes.getTypes(),aOldTypes);
+}
+// -------------------------------------------------------------------------
+Reference< XResultSet > SAL_CALL OStatement_Base::getGeneratedValues( ) throw (SQLException, RuntimeException)
+{
+ OSL_ENSURE( m_pConnection && m_pConnection->isAutoRetrievingEnabled(),"Illegal call here. isAutoRetrievingEnabled is false!");
+ Reference< XResultSet > xRes;
+ if ( m_pConnection )
+ {
+ ::rtl::OUString sStmt = m_pConnection->getTransformedGeneratedStatement(m_sSqlStatement);
+ if ( sStmt.getLength() )
+ {
+ ::comphelper::disposeComponent(m_xGeneratedStatement);
+ m_xGeneratedStatement = m_pConnection->createStatement();
+ xRes = m_xGeneratedStatement->executeQuery(sStmt);
+ }
+ }
+ return xRes;
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::cancel( ) throw(RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ OTools::ThrowException(m_pConnection,N3SQLCancel(m_aStatementHandle),m_aStatementHandle,SQL_HANDLE_STMT,*this);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement_Base::close( ) throw(SQLException, RuntimeException)
+{
+ {
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ }
+ dispose();
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement::clearBatch( ) throw(SQLException, RuntimeException)
+{
+
+}
+// -------------------------------------------------------------------------
+
+void OStatement_Base::reset() throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ clearWarnings ();
+
+ if (m_xResultSet.get().is())
+ {
+ clearMyResultSet();
+ }
+ if(m_aStatementHandle)
+ {
+ THROW_SQL(N3SQLFreeStmt(m_aStatementHandle, SQL_CLOSE));
+ }
+}
+//--------------------------------------------------------------------
+// clearMyResultSet
+// If a ResultSet was created for this Statement, close it
+//--------------------------------------------------------------------
+
+void OStatement_Base::clearMyResultSet () throw (SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ try
+ {
+ Reference<XCloseable> xCloseable;
+ if ( ::comphelper::query_interface( m_xResultSet.get(), xCloseable ) )
+ xCloseable->close();
+ }
+ catch( const DisposedException& ) { }
+
+ m_xResultSet = Reference< XResultSet >();
+}
+//--------------------------------------------------------------------
+SQLLEN OStatement_Base::getRowCount () throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ SQLLEN numRows = 0;
+
+ try {
+ THROW_SQL(N3SQLRowCount(m_aStatementHandle,&numRows));
+ }
+ catch (SQLException&)
+ {
+ }
+ return numRows;
+}
+//--------------------------------------------------------------------
+// lockIfNecessary
+// If the given SQL statement contains a 'FOR UPDATE' clause, change
+// the concurrency to lock so that the row can then be updated. Returns
+// true if the concurrency has been changed
+//--------------------------------------------------------------------
+
+sal_Bool OStatement_Base::lockIfNecessary (const ::rtl::OUString& sql) throw( SQLException)
+{
+ sal_Bool rc = sal_False;
+
+ // First, convert the statement to upper case
+
+ ::rtl::OUString sqlStatement = sql.toAsciiUpperCase ();
+
+ // Now, look for the FOR UPDATE keywords. If there is any extra white
+ // space between the FOR and UPDATE, this will fail.
+
+ sal_Int32 index = sqlStatement.indexOf(::rtl::OUString::createFromAscii(" FOR UPDATE"));
+
+ // We found it. Change our concurrency level to ensure that the
+ // row can be updated.
+
+ if (index > 0)
+ {
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ try
+ {
+ SQLINTEGER nLock = SQL_CONCUR_LOCK;
+ THROW_SQL(N3SQLSetStmtAttr(m_aStatementHandle, SQL_CONCURRENCY,(SQLPOINTER)nLock,SQL_IS_UINTEGER));
+ }
+ catch (SQLWarning& warn)
+ {
+ // Catch any warnings and place on the warning stack
+ setWarning (warn);
+ }
+ rc = sal_True;
+ }
+
+ return rc;
+}
+//--------------------------------------------------------------------
+// setWarning
+// Sets the warning
+//--------------------------------------------------------------------
+
+void OStatement_Base::setWarning (const SQLWarning &ex) throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = ex;
+}
+
+//--------------------------------------------------------------------
+// getColumnCount
+// Return the number of columns in the ResultSet
+//--------------------------------------------------------------------
+
+sal_Int32 OStatement_Base::getColumnCount () throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int16 numCols = 0;
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+
+ try {
+ THROW_SQL(N3SQLNumResultCols(m_aStatementHandle,&numCols));
+ }
+ catch (SQLException&)
+ {
+ }
+ return numCols;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OStatement_Base::execute( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+ m_sSqlStatement = sql;
+
+
+ ::rtl::OString aSql(::rtl::OUStringToOString(sql,getOwnConnection()->getTextEncoding()));
+
+ sal_Bool hasResultSet = sal_False;
+ SQLWarning aWarning;
+
+ // Reset the statement handle and warning
+
+ reset();
+
+ // Check for a 'FOR UPDATE' statement. If present, change
+ // the concurrency to lock
+
+ lockIfNecessary (sql);
+
+ // Call SQLExecDirect
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+
+ try {
+ THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aSql.getStr(),aSql.getLength()));
+ }
+ catch (SQLWarning& ex) {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ aWarning = ex;
+ }
+
+ // Now determine if there is a result set associated with
+ // the SQL statement that was executed. Get the column
+ // count, and if it is not zero, there is a result set.
+
+ if (getColumnCount () > 0)
+ {
+ hasResultSet = sal_True;
+ }
+
+ return hasResultSet;
+}
+//--------------------------------------------------------------------
+// getResultSet
+// getResultSet returns the current result as a ResultSet. It
+// returns NULL if the current result is not a ResultSet.
+//--------------------------------------------------------------------
+Reference< XResultSet > OStatement_Base::getResultSet (sal_Bool checkCount) throw( SQLException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ if (m_xResultSet.get().is()) // if resultset already retrieved,
+ {
+ // throw exception to avoid sequence error
+ ::dbtools::throwFunctionSequenceException(*this,Any());
+ }
+
+ OResultSet* pRs = NULL;
+ sal_Int32 numCols = 1;
+
+ // If we already know we have result columns, checkCount
+ // is false. This is an optimization to prevent unneeded
+ // calls to getColumnCount
+
+ if (checkCount)
+ numCols = getColumnCount ();
+
+ // Only return a result set if there are result columns
+
+ if (numCols > 0)
+ {
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ pRs = createResulSet();
+ pRs->construct();
+
+ // Save a copy of our last result set
+ // Changed to save copy at getResultSet.
+ //m_xResultSet = rs;
+ }
+ else
+ clearMyResultSet ();
+
+ return pRs;
+}
+//--------------------------------------------------------------------
+// getStmtOption
+// Invoke SQLGetStmtOption with the given option.
+//--------------------------------------------------------------------
+
+sal_Int32 OStatement_Base::getStmtOption (short fOption) const
+{
+ sal_Int32 result = 0;
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ N3SQLGetStmtAttr(m_aStatementHandle, fOption,&result,SQL_IS_INTEGER,NULL);
+ return result;
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OStatement_Base::executeQuery( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ Reference< XResultSet > xRS = NULL;
+
+ // Execute the statement. If execute returns true, a result
+ // set exists.
+
+ if (execute (sql))
+ {
+ xRS = getResultSet (sal_False);
+ m_xResultSet = xRS;
+ }
+ else
+ {
+ // No ResultSet was produced. Raise an exception
+ m_pConnection->throwGenericSQLException(STR_NO_RESULTSET,*this);
+ }
+ return xRS;
+}
+// -------------------------------------------------------------------------
+
+Reference< XConnection > SAL_CALL OStatement_Base::getConnection( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+ return (Reference< XConnection >)m_pConnection;
+}
+// -------------------------------------------------------------------------
+
+Any SAL_CALL OStatement::queryInterface( const Type & rType ) throw(RuntimeException)
+{
+ Any aRet = ::cppu::queryInterface(rType,static_cast< XBatchExecution*> (this));
+ return aRet.hasValue() ? aRet : OStatement_Base::queryInterface(rType);
+}
+// -------------------------------------------------------------------------
+
+void SAL_CALL OStatement::addBatch( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aBatchList.push_back(sql);
+}
+// -------------------------------------------------------------------------
+Sequence< sal_Int32 > SAL_CALL OStatement::executeBatch( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ ::rtl::OString aBatchSql;
+ sal_Int32 nLen = 0;
+ for(::std::list< ::rtl::OUString>::const_iterator i=m_aBatchList.begin();i != m_aBatchList.end();++i,++nLen)
+ {
+ aBatchSql += ::rtl::OUStringToOString(*i,getOwnConnection()->getTextEncoding());
+ aBatchSql += ";";
+ }
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ THROW_SQL(N3SQLExecDirect(m_aStatementHandle, (SDB_ODBC_CHAR*)aBatchSql.getStr(),aBatchSql.getLength()));
+
+ Sequence< sal_Int32 > aRet(nLen);
+ sal_Int32* pArray = aRet.getArray();
+ for(sal_Int32 j=0;j<nLen;++j)
+ {
+ SQLRETURN nError = N3SQLMoreResults(m_aStatementHandle);
+ if(nError == SQL_SUCCESS)
+ {
+ SQLLEN nRowCount=0;
+ N3SQLRowCount(m_aStatementHandle,&nRowCount);
+ pArray[j] = nRowCount;
+ }
+ }
+ return aRet;
+}
+// -------------------------------------------------------------------------
+
+
+sal_Int32 SAL_CALL OStatement_Base::executeUpdate( const ::rtl::OUString& sql ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 numRows = -1;
+
+ // Execute the statement. If execute returns false, a
+ // row count exists.
+
+ if (!execute (sql)) {
+ numRows = getUpdateCount();
+ }
+ else {
+
+ // No update count was produced (a ResultSet was). Raise
+ // an exception
+
+ ::connectivity::SharedResources aResources;
+ const ::rtl::OUString sError( aResources.getResourceString(STR_NO_ROWCOUNT));
+ throw SQLException (sError, *this,::rtl::OUString(),0,Any());
+ }
+ return numRows;
+
+}
+// -------------------------------------------------------------------------
+
+Reference< XResultSet > SAL_CALL OStatement_Base::getResultSet( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_xResultSet = getResultSet(sal_True);
+ return m_xResultSet;
+}
+// -------------------------------------------------------------------------
+
+sal_Int32 SAL_CALL OStatement_Base::getUpdateCount( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ sal_Int32 rowCount = -1;
+
+ // Only return a row count for SQL statements that did not
+ // return a result set.
+
+ if (getColumnCount () == 0)
+ rowCount = getRowCount ();
+
+ return rowCount;
+}
+// -------------------------------------------------------------------------
+
+sal_Bool SAL_CALL OStatement_Base::getMoreResults( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ SQLWarning warning;
+ sal_Bool hasResultSet = sal_False;
+
+ // clear previous warnings
+
+ clearWarnings ();
+
+ // Call SQLMoreResults
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+
+ try {
+ hasResultSet = N3SQLMoreResults(m_aStatementHandle) == SQL_SUCCESS;
+ }
+ catch (SQLWarning &ex) {
+
+ // Save pointer to warning and save with ResultSet
+ // object once it is created.
+
+ warning = ex;
+ }
+
+ // There are more results (it may not be a result set, though)
+
+ if (hasResultSet)
+ {
+
+ // Now determine if there is a result set associated
+ // with the SQL statement that was executed. Get the
+ // column count, and if it is zero, there is not a
+ // result set.
+
+ if (getColumnCount () == 0)
+ hasResultSet = sal_False;
+ }
+
+ // Set the warning for the statement, if one was generated
+
+ setWarning (warning);
+
+ // Return the result set indicator
+
+ return hasResultSet;
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+Any SAL_CALL OStatement_Base::getWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ return makeAny(m_aLastWarning);
+}
+// -------------------------------------------------------------------------
+
+// -------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::clearWarnings( ) throw(SQLException, RuntimeException)
+{
+ ::osl::MutexGuard aGuard( m_aMutex );
+ checkDisposed(OStatement_BASE::rBHelper.bDisposed);
+
+
+ m_aLastWarning = SQLWarning();
+}
+// -------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getQueryTimeOut() const
+{
+ return getStmtOption(SQL_ATTR_QUERY_TIMEOUT);
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getMaxRows() const
+{
+ return getStmtOption(SQL_ATTR_MAX_ROWS);
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getResultSetConcurrency() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CONCURRENCY,&nValue,SQL_IS_UINTEGER,0);
+ OSL_UNUSED( nRetCode );
+ if(nValue == SQL_CONCUR_READ_ONLY)
+ nValue = ResultSetConcurrency::READ_ONLY;
+ else
+ nValue = ResultSetConcurrency::UPDATABLE;
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getResultSetType() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue = SQL_CURSOR_FORWARD_ONLY;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SENSITIVITY,&nValue,SQL_IS_UINTEGER,0);
+ nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_TYPE,&nValue,SQL_IS_UINTEGER,0);
+ switch(nValue)
+ {
+ case SQL_CURSOR_FORWARD_ONLY:
+ nValue = ResultSetType::FORWARD_ONLY;
+ break;
+ case SQL_CURSOR_KEYSET_DRIVEN:
+ case SQL_CURSOR_STATIC:
+ nValue = ResultSetType::SCROLL_INSENSITIVE;
+ break;
+ case SQL_CURSOR_DYNAMIC:
+ nValue = ResultSetType::SCROLL_SENSITIVE;
+ break;
+ }
+
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getFetchDirection() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue = 0;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SCROLLABLE,&nValue,SQL_IS_UINTEGER,0);
+ OSL_UNUSED( nRetCode );
+
+ switch(nValue)
+ {
+ case SQL_SCROLLABLE:
+ nValue = FetchDirection::REVERSE;
+ break;
+ default:
+ nValue = FetchDirection::FORWARD;
+ break;
+ }
+
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getFetchSize() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,&nValue,SQL_IS_UINTEGER,0);
+ OSL_UNUSED( nRetCode );
+ return nValue;
+}
+//------------------------------------------------------------------------------
+sal_Int32 OStatement_Base::getMaxFieldSize() const
+{
+ return getStmtOption(SQL_ATTR_MAX_LENGTH);
+}
+//------------------------------------------------------------------------------
+::rtl::OUString OStatement_Base::getCursorName() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLCHAR pName[258];
+ SQLSMALLINT nRealLen = 0;
+ SQLRETURN nRetCode = N3SQLGetCursorName(m_aStatementHandle,(SQLCHAR*)pName,256,&nRealLen);
+ OSL_UNUSED( nRetCode );
+ return ::rtl::OUString::createFromAscii((const char*)pName);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setQueryTimeOut(sal_Int32 seconds)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_QUERY_TIMEOUT,(SQLPOINTER)seconds,SQL_IS_UINTEGER);
+ OSL_UNUSED( nRetCode );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setMaxRows(sal_Int32 _par0)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_MAX_ROWS, (SQLPOINTER)_par0,SQL_IS_UINTEGER);
+ OSL_UNUSED( nRetCode );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setResultSetConcurrency(sal_Int32 _par0)
+{
+ SQLINTEGER nSet;
+ if(_par0 == ResultSetConcurrency::READ_ONLY)
+ nSet = SQL_CONCUR_READ_ONLY;
+ else
+ nSet = SQL_CONCUR_VALUES;
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CONCURRENCY,(SQLPOINTER)nSet,SQL_IS_UINTEGER);
+
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setResultSetType(sal_Int32 _par0)
+{
+
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_ROW_BIND_TYPE,(SQLPOINTER)SQL_BIND_BY_COLUMN,SQL_IS_UINTEGER);
+ OSL_UNUSED( nRetCode );
+
+ sal_Bool bUseBookmark = isUsingBookmarks();
+ SQLUINTEGER nSet( SQL_UNSPECIFIED );
+ switch(_par0)
+ {
+ case ResultSetType::FORWARD_ONLY:
+ nSet = SQL_UNSPECIFIED;
+ break;
+ case ResultSetType::SCROLL_INSENSITIVE:
+ nSet = SQL_INSENSITIVE;
+ N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)SQL_CURSOR_KEYSET_DRIVEN,SQL_IS_UINTEGER);
+ break;
+ case ResultSetType::SCROLL_SENSITIVE:
+ if(bUseBookmark)
+ {
+ SQLUINTEGER nCurProp = getCursorProperties(SQL_CURSOR_DYNAMIC,sal_True);
+ if((nCurProp & SQL_CA1_BOOKMARK) != SQL_CA1_BOOKMARK) // check if bookmark for this type isn't supported
+ { // we have to test the next one
+ nCurProp = getCursorProperties(SQL_CURSOR_KEYSET_DRIVEN,sal_True);
+ sal_Bool bNotBookmarks = ((nCurProp & SQL_CA1_BOOKMARK) != SQL_CA1_BOOKMARK);
+ nCurProp = getCursorProperties(SQL_CURSOR_KEYSET_DRIVEN,sal_False);
+ nSet = SQL_CURSOR_KEYSET_DRIVEN;
+ if( bNotBookmarks ||
+ ((nCurProp & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS) ||
+ ((nCurProp & SQL_CA2_SENSITIVITY_ADDITIONS) != SQL_CA2_SENSITIVITY_ADDITIONS))
+ {
+ // bookmarks for keyset isn't supported so reset bookmark setting
+ setUsingBookmarks(sal_False);
+ nSet = SQL_CURSOR_DYNAMIC;
+ }
+ }
+ else
+ nSet = SQL_CURSOR_DYNAMIC;
+ }
+ else
+ nSet = SQL_CURSOR_DYNAMIC;
+ if(N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)nSet,SQL_IS_UINTEGER) != SQL_SUCCESS)
+ {
+ nSet = SQL_CURSOR_KEYSET_DRIVEN;
+ N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_TYPE,(SQLPOINTER)nSet,SQL_IS_UINTEGER);
+ }
+ nSet = SQL_SENSITIVE;
+ break;
+ default:
+ OSL_ENSURE( false, "OStatement_Base::setResultSetType: invalid result set type!" );
+ break;
+ }
+
+
+ N3SQLSetStmtAttr(m_aStatementHandle, SQL_ATTR_CURSOR_SENSITIVITY,(SQLPOINTER)nSet,SQL_IS_UINTEGER);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setEscapeProcessing( const sal_Bool _bEscapeProc )
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ SQLUINTEGER nEscapeProc( _bEscapeProc ? SQL_NOSCAN_OFF : SQL_NOSCAN_ON );
+ SQLRETURN nRetCode = N3SQLSetStmtAttr( m_aStatementHandle, SQL_ATTR_NOSCAN, (SQLPOINTER)nEscapeProc, SQL_IS_UINTEGER );
+ (void)nRetCode;
+}
+
+//------------------------------------------------------------------------------
+void OStatement_Base::setFetchDirection(sal_Int32 _par0)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_Int32 nCursType = 0;
+ SQLRETURN nRetCode = SQL_SUCCESS;
+ if(_par0 == FetchDirection::FORWARD)
+ {
+ nCursType = SQL_NONSCROLLABLE;
+ nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SCROLLABLE,(SQLPOINTER)nCursType,SQL_IS_UINTEGER);
+ }
+ else if(_par0 == FetchDirection::REVERSE)
+ {
+ nCursType = SQL_SCROLLABLE;
+ nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_CURSOR_SCROLLABLE,(SQLPOINTER)nCursType,SQL_IS_UINTEGER);
+ }
+ OSL_UNUSED( nRetCode );
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setFetchSize(sal_Int32 _par0)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_ARRAY_SIZE,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+
+ delete m_pRowStatusArray;
+ m_pRowStatusArray = new SQLUSMALLINT[_par0];
+ nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_ROW_STATUS_PTR,m_pRowStatusArray,SQL_IS_POINTER);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setMaxFieldSize(sal_Int32 _par0)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_MAX_LENGTH,(SQLPOINTER)_par0,SQL_IS_UINTEGER);
+}
+//------------------------------------------------------------------------------
+void OStatement_Base::setCursorName(const ::rtl::OUString &_par0)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ ::rtl::OString aName(::rtl::OUStringToOString(_par0,getOwnConnection()->getTextEncoding()));
+ N3SQLSetCursorName(m_aStatementHandle,(SDB_ODBC_CHAR*)aName.getStr(),(SQLSMALLINT)aName.getLength());
+}
+// -------------------------------------------------------------------------
+sal_Bool OStatement_Base::isUsingBookmarks() const
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue = SQL_UB_OFF;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,&nValue,SQL_IS_UINTEGER,NULL);
+ OSL_UNUSED( nRetCode );
+ return nValue != SQL_UB_OFF;
+}
+// -------------------------------------------------------------------------
+sal_Bool OStatement_Base::getEscapeProcessing() const
+{
+ OSL_ENSURE( m_aStatementHandle, "StatementHandle is null!" );
+ sal_uInt32 nValue = SQL_NOSCAN_OFF;
+ SQLRETURN nRetCode = N3SQLGetStmtAttr( m_aStatementHandle, SQL_ATTR_NOSCAN, &nValue, SQL_IS_UINTEGER, NULL );
+ (void)nRetCode;
+ return nValue == SQL_NOSCAN_OFF;
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::setUsingBookmarks(sal_Bool _bUseBookmark)
+{
+ OSL_ENSURE(m_aStatementHandle,"StatementHandle is null!");
+ sal_uInt32 nValue = _bUseBookmark ? SQL_UB_VARIABLE : SQL_UB_OFF;
+ SQLRETURN nRetCode = N3SQLSetStmtAttr(m_aStatementHandle,SQL_ATTR_USE_BOOKMARKS,(SQLPOINTER)nValue,SQL_IS_UINTEGER);
+ OSL_UNUSED( nRetCode );
+}
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper* OStatement_Base::createArrayHelper( ) const
+{
+ Sequence< Property > aProps(10);
+ Property* pProperties = aProps.getArray();
+ sal_Int32 nPos = 0;
+ DECL_PROP0(CURSORNAME, ::rtl::OUString);
+ DECL_BOOL_PROP0(ESCAPEPROCESSING);
+ DECL_PROP0(FETCHDIRECTION,sal_Int32);
+ DECL_PROP0(FETCHSIZE, sal_Int32);
+ DECL_PROP0(MAXFIELDSIZE,sal_Int32);
+ DECL_PROP0(MAXROWS, sal_Int32);
+ DECL_PROP0(QUERYTIMEOUT,sal_Int32);
+ DECL_PROP0(RESULTSETCONCURRENCY,sal_Int32);
+ DECL_PROP0(RESULTSETTYPE,sal_Int32);
+ DECL_BOOL_PROP0(USEBOOKMARKS);
+
+ return new ::cppu::OPropertyArrayHelper(aProps);
+}
+
+// -------------------------------------------------------------------------
+::cppu::IPropertyArrayHelper & OStatement_Base::getInfoHelper()
+{
+ return *const_cast<OStatement_Base*>(this)->getArrayHelper();
+}
+// -------------------------------------------------------------------------
+sal_Bool OStatement_Base::convertFastPropertyValue(
+ Any & rConvertedValue,
+ Any & rOldValue,
+ sal_Int32 nHandle,
+ const Any& rValue )
+ throw (::com::sun::star::lang::IllegalArgumentException)
+{
+ sal_Bool bConverted = sal_False;
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getQueryTimeOut());
+ break;
+
+ case PROPERTY_ID_MAXFIELDSIZE:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxFieldSize());
+ break;
+
+ case PROPERTY_ID_MAXROWS:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getMaxRows());
+ break;
+
+ case PROPERTY_ID_CURSORNAME:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getCursorName());
+ break;
+
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetConcurrency());
+ break;
+
+ case PROPERTY_ID_RESULTSETTYPE:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getResultSetType());
+ break;
+
+ case PROPERTY_ID_FETCHDIRECTION:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchDirection());
+ break;
+
+ case PROPERTY_ID_FETCHSIZE:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, getFetchSize());
+ break;
+
+ case PROPERTY_ID_USEBOOKMARKS:
+ bConverted = ::comphelper::tryPropertyValue(rConvertedValue, rOldValue, rValue, isUsingBookmarks());
+ break;
+
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ bConverted = ::comphelper::tryPropertyValue( rConvertedValue, rOldValue, rValue, getEscapeProcessing() );
+ break;
+
+ }
+ }
+ catch(const SQLException&)
+ {
+ // throw Exception(e.Message,*this);
+ }
+ return bConverted;
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::setFastPropertyValue_NoBroadcast(sal_Int32 nHandle,const Any& rValue) throw (Exception)
+{
+ try
+ {
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ setQueryTimeOut(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ setMaxFieldSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_MAXROWS:
+ setMaxRows(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ setCursorName(comphelper::getString(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ setResultSetConcurrency(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ setResultSetType(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ setFetchDirection(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ setFetchSize(comphelper::getINT32(rValue));
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ setUsingBookmarks(comphelper::getBOOL(rValue));
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ setEscapeProcessing( ::comphelper::getBOOL( rValue ) );
+ break;
+ default:
+ OSL_ENSURE( false, "OStatement_Base::setFastPropertyValue_NoBroadcast: what property?" );
+ break;
+ }
+ }
+ catch(const SQLException& )
+ {
+ // throw Exception(e.Message,*this);
+ }
+}
+// -------------------------------------------------------------------------
+void OStatement_Base::getFastPropertyValue(Any& rValue,sal_Int32 nHandle) const
+{
+ switch(nHandle)
+ {
+ case PROPERTY_ID_QUERYTIMEOUT:
+ rValue <<= getQueryTimeOut();
+ break;
+ case PROPERTY_ID_MAXFIELDSIZE:
+ rValue <<= getMaxFieldSize();
+ break;
+ case PROPERTY_ID_MAXROWS:
+ rValue <<= getMaxRows();
+ break;
+ case PROPERTY_ID_CURSORNAME:
+ rValue <<= getCursorName();
+ break;
+ case PROPERTY_ID_RESULTSETCONCURRENCY:
+ rValue <<= getResultSetConcurrency();
+ break;
+ case PROPERTY_ID_RESULTSETTYPE:
+ rValue <<= getResultSetType();
+ break;
+ case PROPERTY_ID_FETCHDIRECTION:
+ rValue <<= getFetchDirection();
+ break;
+ case PROPERTY_ID_FETCHSIZE:
+ rValue <<= getFetchSize();
+ break;
+ case PROPERTY_ID_USEBOOKMARKS:
+ rValue <<= isUsingBookmarks();
+ break;
+ case PROPERTY_ID_ESCAPEPROCESSING:
+ rValue <<= getEscapeProcessing();
+ break;
+ default:
+ OSL_ENSURE( false, "OStatement_Base::getFastPropertyValue: what property?" );
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+IMPLEMENT_SERVICE_INFO(OStatement,"com.sun.star.sdbcx.OStatement","com.sun.star.sdbc.Statement");
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::acquire() throw()
+{
+ OStatement_BASE::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement_Base::release() throw()
+{
+ OStatement_BASE::release();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::acquire() throw()
+{
+ OStatement_BASE2::acquire();
+}
+// -----------------------------------------------------------------------------
+void SAL_CALL OStatement::release() throw()
+{
+ OStatement_BASE2::release();
+}
+// -----------------------------------------------------------------------------
+OResultSet* OStatement_Base::createResulSet()
+{
+ return new OResultSet(m_aStatementHandle,this);
+}
+// -----------------------------------------------------------------------------
+Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatement_Base::getPropertySetInfo( ) throw(RuntimeException)
+{
+ return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
+}
+// -----------------------------------------------------------------------------
+SQLUINTEGER OStatement_Base::getCursorProperties(SQLINTEGER _nCursorType,sal_Bool bFirst)
+{
+ SQLUINTEGER nValueLen = 0;
+ try
+ {
+ SQLUSMALLINT nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ if(SQL_CURSOR_KEYSET_DRIVEN == _nCursorType)
+ nAskFor = bFirst ? SQL_KEYSET_CURSOR_ATTRIBUTES1 : SQL_KEYSET_CURSOR_ATTRIBUTES2;
+ else if(SQL_CURSOR_STATIC == _nCursorType)
+ nAskFor = bFirst ? SQL_STATIC_CURSOR_ATTRIBUTES1 : SQL_STATIC_CURSOR_ATTRIBUTES2;
+ else if(SQL_CURSOR_FORWARD_ONLY == _nCursorType)
+ nAskFor = bFirst ? SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1 : SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
+ else if(SQL_CURSOR_DYNAMIC == _nCursorType)
+ nAskFor = bFirst ? SQL_DYNAMIC_CURSOR_ATTRIBUTES1 : SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
+
+
+ OTools::GetInfo(getOwnConnection(),getConnectionHandle(),nAskFor,nValueLen,NULL);
+ }
+ catch(Exception&)
+ { // we don't want our result destroy here
+ nValueLen = 0;
+ }
+ return nValueLen;
+}
+// -----------------------------------------------------------------------------
diff --git a/connectivity/source/drivers/odbcbase/OTools.cxx b/connectivity/source/drivers/odbcbase/OTools.cxx
new file mode 100644
index 000000000000..43de55e3505c
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/OTools.cxx
@@ -0,0 +1,946 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_connectivity.hxx"
+#include "odbc/OTools.hxx"
+#include "odbc/OFunctions.hxx"
+#include <com/sun/star/sdbc/DataType.hpp>
+#include <osl/diagnose.h>
+#include "odbc/OConnection.hxx"
+#include "diagnose_ex.h"
+#include <rtl/logfile.hxx>
+#include <rtl/ustrbuf.hxx>
+
+
+#include <string.h>
+#include <string>
+#include <algorithm>
+
+using namespace connectivity::odbc;
+using namespace com::sun::star::uno;
+using namespace com::sun::star::sdbc;
+using namespace com::sun::star::util;
+
+void OTools::getValue( OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _nType,
+ sal_Bool &_bWasNull,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ void* _pValue,
+ SQLLEN _nSize) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getValue" );
+ SQLLEN pcbValue = SQL_NULL_DATA;
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ _nType,
+ _pValue,
+ _nSize,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface,sal_False);
+ _bWasNull = pcbValue == SQL_NULL_DATA;
+}
+// -----------------------------------------------------------------------------
+void OTools::bindParameter( OConnection* _pConnection,
+ SQLHANDLE _hStmt,
+ sal_Int32 nPos,
+ sal_Int8*& pDataBuffer,
+ sal_Int8* pLenBuffer,
+ SQLSMALLINT _nODBCtype,
+ sal_Bool _bUseWChar,
+ sal_Bool _bUseOldTimeDate,
+ const void* _pValue,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ rtl_TextEncoding _nTextEncoding)
+ throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindParameter" );
+ SQLRETURN nRetcode;
+ SQLSMALLINT fSqlType;
+ SQLSMALLINT fCType;
+ SQLLEN nMaxLen = 0;
+ // void*& pData = pDataBuffer;
+ SQLLEN* pLen = (SQLLEN*)pLenBuffer;
+ SQLULEN nColumnSize=0;
+ SQLSMALLINT nDecimalDigits=0;
+
+ OTools::getBindTypes(_bUseWChar,_bUseOldTimeDate,_nODBCtype,fCType,fSqlType);
+
+ OTools::bindData(_nODBCtype,_bUseWChar,pDataBuffer,pLen,_pValue,_nTextEncoding,nColumnSize);
+ if ((nColumnSize == 0) && (fSqlType == SQL_CHAR || fSqlType == SQL_VARCHAR || fSqlType == SQL_LONGVARCHAR))
+ nColumnSize = 1;
+
+ if(fSqlType == SQL_LONGVARCHAR || fSqlType == SQL_LONGVARBINARY)
+ memcpy(pDataBuffer,&nPos,sizeof(nPos));
+
+ // 20.09.2001 OJ: Problems with mysql. mysql returns only CHAR as parameter type
+ // nRetcode = (*(T3SQLDescribeParam)_pConnection->getOdbcFunction(ODBC3SQLDescribeParam))(_hStmt,(SQLUSMALLINT)nPos,&fSqlType,&nColumnSize,&nDecimalDigits,&nNullable);
+
+ nRetcode = (*(T3SQLBindParameter)_pConnection->getOdbcFunction(ODBC3SQLBindParameter))(_hStmt,
+ (SQLUSMALLINT)nPos,
+ SQL_PARAM_INPUT,
+ fCType,
+ fSqlType,
+ nColumnSize,
+ nDecimalDigits,
+ pDataBuffer,
+ nMaxLen,
+ pLen);
+
+ OTools::ThrowException(_pConnection,nRetcode,_hStmt,SQL_HANDLE_STMT,_xInterface);
+}
+// -----------------------------------------------------------------------------
+void OTools::bindData( SQLSMALLINT _nOdbcType,
+ sal_Bool _bUseWChar,
+ sal_Int8 *&_pData,
+ SQLLEN*& pLen,
+ const void* _pValue,
+ rtl_TextEncoding _nTextEncoding,
+ SQLULEN& _nColumnSize)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindData" );
+ _nColumnSize = 0;
+
+ switch (_nOdbcType)
+ {
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ case SQL_DECIMAL:
+ if(_bUseWChar)
+ {
+ *pLen = SQL_NTS;
+ ::rtl::OUString sStr(*(::rtl::OUString*)_pValue);
+ _nColumnSize = sStr.getLength();
+ *((rtl::OUString*)_pData) = sStr;
+
+ // Zeiger auf Char*
+ _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
+ }
+ else
+ {
+ ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
+ *pLen = SQL_NTS;
+ _nColumnSize = aString.getLength();
+ memcpy(_pData,aString.getStr(),aString.getLength());
+ ((sal_Int8*)_pData)[aString.getLength()] = '\0';
+ }
+ break;
+
+ case SQL_BIGINT:
+ *((sal_Int64*)_pData) = *(sal_Int64*)_pValue;
+ *pLen = sizeof(sal_Int64);
+ _nColumnSize = *pLen;
+ break;
+
+ case SQL_NUMERIC:
+ if(_bUseWChar)
+ {
+ ::rtl::OUString aString = rtl::OUString::valueOf(*(double*)_pValue);
+ _nColumnSize = aString.getLength();
+ *pLen = _nColumnSize;
+ *((rtl::OUString*)_pData) = aString;
+ // Zeiger auf Char*
+ _pData = (sal_Int8*)((rtl::OUString*)_pData)->getStr();
+ }
+ else
+ {
+ ::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue);
+ _nColumnSize = aString.getLength();
+ *pLen = _nColumnSize;
+ memcpy(_pData,aString.getStr(),aString.getLength());
+ ((sal_Int8*)_pData)[_nColumnSize] = '\0';
+ } break;
+ case SQL_BIT:
+ case SQL_TINYINT:
+ *((sal_Int8*)_pData) = *(sal_Int8*)_pValue;
+ *pLen = sizeof(sal_Int8);
+ break;
+
+ case SQL_SMALLINT:
+ *((sal_Int16*)_pData) = *(sal_Int16*)_pValue;
+ *pLen = sizeof(sal_Int16);
+ break;
+ case SQL_INTEGER:
+ *((sal_Int32*)_pData) = *(sal_Int32*)_pValue;
+ *pLen = sizeof(sal_Int32);
+ break;
+ case SQL_FLOAT:
+ *((float*)_pData) = *(float*)_pValue;
+ *pLen = sizeof(float);
+ break;
+ case SQL_REAL:
+ case SQL_DOUBLE:
+ *((double*)_pData) = *(double*)_pValue;
+ *pLen = sizeof(double);
+ break;
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ {
+ const ::com::sun::star::uno::Sequence< sal_Int8 >* pSeq = static_cast< const ::com::sun::star::uno::Sequence< sal_Int8 >* >(_pValue);
+ OSL_ENSURE(pSeq,"OTools::bindData: Sequence is null!");
+
+ if(pSeq)
+ {
+ _pData = (sal_Int8*)pSeq->getConstArray();
+ *pLen = pSeq->getLength();
+ }
+ }
+ break;
+ case SQL_LONGVARBINARY:
+ {
+ sal_Int32 nLen = 0;
+ nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
+ *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+ }
+ break;
+ case SQL_LONGVARCHAR:
+ {
+ sal_Int32 nLen = 0;
+ if(_bUseWChar)
+ nLen = sizeof(sal_Unicode) * ((::rtl::OUString*)_pValue)->getLength();
+ else
+ {
+ ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
+ nLen = aString.getLength();
+ }
+ *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+ } break;
+ case SQL_DATE:
+ *(DATE_STRUCT*)_pData = *(DATE_STRUCT*)_pValue;
+ *pLen = (SQLLEN)sizeof(DATE_STRUCT);
+ _nColumnSize = 10;
+ break;
+ case SQL_TIME:
+ *(TIME_STRUCT*)_pData = *(TIME_STRUCT*)_pValue;
+ *pLen = (SQLLEN)sizeof(TIME_STRUCT);
+ _nColumnSize = 8;
+ break;
+ case SQL_TIMESTAMP:
+ *(TIMESTAMP_STRUCT*)_pData = *(TIMESTAMP_STRUCT*)_pValue;
+ *pLen = (SQLLEN)sizeof(TIMESTAMP_STRUCT);
+ _nColumnSize = 19;
+ break;
+ }
+}
+// -------------------------------------------------------------------------
+void OTools::bindValue( OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _nType,
+ SQLSMALLINT _nMaxLen,
+ const void* _pValue,
+ void* _pData,
+ SQLLEN *pLen,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xInterface,
+ rtl_TextEncoding _nTextEncoding,
+ sal_Bool _bUseOldTimeDate) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::bindValue" );
+ SQLRETURN nRetcode;
+ SQLSMALLINT fSqlType;
+ SQLSMALLINT fCType;
+ SQLLEN nMaxLen = _nMaxLen;
+
+ OTools::getBindTypes( sal_False,
+ _bUseOldTimeDate,
+ _nType,
+ fCType,
+ fSqlType);
+
+ if (columnIndex != 0 && !_pValue)
+ {
+ *pLen = SQL_NULL_DATA;
+ nRetcode = (*(T3SQLBindCol)_pConnection->getOdbcFunction(ODBC3SQLBindCol))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ fCType,
+ _pData,
+ nMaxLen,
+ pLen
+ );
+ }
+ else
+ {
+ try
+ {
+ switch (_nType)
+ {
+ case SQL_CHAR:
+ case SQL_VARCHAR:
+ //if(GetODBCConnection()->m_bUserWChar)
+// {
+// _nMaxLen = rCol.GetPrecision();
+// *pLen = SQL_NTS;
+// *((rtl::OUString*)pData) = (rtl::OUString)_aValue;
+//
+// // Zeiger auf Char*
+// pData = (void*)((rtl::OUString*)pData)->getStr();
+// }
+// else
+ {
+ ::rtl::OString aString(::rtl::OUStringToOString(*(::rtl::OUString*)_pValue,_nTextEncoding));
+ *pLen = SQL_NTS;
+ *((::rtl::OString*)_pData) = aString;
+ _nMaxLen = (SQLSMALLINT)aString.getLength();
+
+ // Zeiger auf Char*
+ _pData = (void*)aString.getStr();
+ } break;
+ case SQL_BIGINT:
+ *((sal_Int64*)_pData) = *(sal_Int64*)_pValue;
+ *pLen = sizeof(sal_Int64);
+ break;
+ case SQL_DECIMAL:
+ case SQL_NUMERIC:
+ //if(GetODBCConnection()->m_bUserWChar)
+// {
+// rtl::OUString aString(rtl::OUString(SdbTools::ToString(ODbTypeConversion::toDouble(*pVariable),rCol.GetScale())));
+// *pLen = _nMaxLen;
+// *((rtl::OUString*)_pData) = aString;
+// // Zeiger auf Char*
+// _pData = (void*)((rtl::OUString*)_pData)->getStr();
+// }
+// else
+ {
+ ::rtl::OString aString = ::rtl::OString::valueOf(*(double*)_pValue);
+ _nMaxLen = (SQLSMALLINT)aString.getLength();
+ *pLen = _nMaxLen;
+ *((::rtl::OString*)_pData) = aString;
+ // Zeiger auf Char*
+ _pData = (void*)((::rtl::OString*)_pData)->getStr();
+ } break;
+ case SQL_BIT:
+ case SQL_TINYINT:
+ *((sal_Int8*)_pData) = *(sal_Int8*)_pValue;
+ *pLen = sizeof(sal_Int8);
+ break;
+
+ case SQL_SMALLINT:
+ *((sal_Int16*)_pData) = *(sal_Int16*)_pValue;
+ *pLen = sizeof(sal_Int16);
+ break;
+ case SQL_INTEGER:
+ *((sal_Int32*)_pData) = *(sal_Int32*)_pValue;
+ *pLen = sizeof(sal_Int32);
+ break;
+ case SQL_FLOAT:
+ *((float*)_pData) = *(float*)_pValue;
+ *pLen = sizeof(float);
+ break;
+ case SQL_REAL:
+ case SQL_DOUBLE:
+ *((double*)_pData) = *(double*)_pValue;
+ *pLen = sizeof(double);
+ break;
+ case SQL_BINARY:
+ case SQL_VARBINARY:
+ // if (_pValue == ::getCppuType((const ::com::sun::star::uno::Sequence< sal_Int8 > *)0))
+ {
+ _pData = (void*)((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getConstArray();
+ *pLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
+ } break;
+ case SQL_LONGVARBINARY:
+ {
+ _pData = (void*)(columnIndex);
+ sal_Int32 nLen = 0;
+ nLen = ((const ::com::sun::star::uno::Sequence< sal_Int8 > *)_pValue)->getLength();
+ *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+ }
+ break;
+ case SQL_LONGVARCHAR:
+ {
+ _pData = (void*)(columnIndex);
+ sal_Int32 nLen = 0;
+ nLen = ((::rtl::OUString*)_pValue)->getLength();
+ *pLen = (SQLLEN)SQL_LEN_DATA_AT_EXEC(nLen);
+ } break;
+ case SQL_DATE:
+ *pLen = sizeof(DATE_STRUCT);
+ *((DATE_STRUCT*)_pData) = *(DATE_STRUCT*)_pValue;
+ break;
+ case SQL_TIME:
+ *pLen = sizeof(TIME_STRUCT);
+ *((TIME_STRUCT*)_pData) = *(TIME_STRUCT*)_pValue;
+ break;
+ case SQL_TIMESTAMP:
+ *pLen = sizeof(TIMESTAMP_STRUCT);
+ *((TIMESTAMP_STRUCT*)_pData) = *(TIMESTAMP_STRUCT*)_pValue;
+ break;
+ }
+ }
+ catch ( ... )
+ {
+ }
+
+ nRetcode = (*(T3SQLBindCol)_pConnection->getOdbcFunction(ODBC3SQLBindCol))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ fCType,
+ _pData,
+ nMaxLen,
+ pLen
+ );
+ }
+
+ OTools::ThrowException(_pConnection,nRetcode,_aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+}
+// -----------------------------------------------------------------------------
+void OTools::ThrowException(OConnection* _pConnection,
+ SQLRETURN _rRetCode,
+ SQLHANDLE _pContext,
+ SQLSMALLINT _nHandleType,
+ const Reference< XInterface >& _xInterface,
+ sal_Bool _bNoFound,
+ rtl_TextEncoding _nTextEncoding) throw(SQLException)
+{
+ switch(_rRetCode)
+ {
+ case SQL_NEED_DATA:
+ case SQL_STILL_EXECUTING:
+ case SQL_SUCCESS:
+
+ case SQL_SUCCESS_WITH_INFO:
+ return;
+ case SQL_NO_DATA_FOUND:
+ if(_bNoFound)
+ return; // no need to throw a exception
+ case SQL_ERROR: break;
+
+
+ case SQL_INVALID_HANDLE: OSL_ENSURE(0,"SdbODBC3_SetStatus: SQL_INVALID_HANDLE");
+ throw SQLException();
+ }
+
+
+ // Zusaetliche Informationen zum letzten ODBC-Funktionsaufruf vorhanden.
+ // SQLError liefert diese Informationen.
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::ThrowException" );
+
+ SDB_ODBC_CHAR szSqlState[5];
+ SQLINTEGER pfNativeError;
+ SDB_ODBC_CHAR szErrorMessage[SQL_MAX_MESSAGE_LENGTH];
+ szErrorMessage[0] = '\0';
+ SQLSMALLINT pcbErrorMsg = 0;
+
+ // Informationen zur letzten Operation:
+ // wenn hstmt != SQL_NULL_HSTMT ist (Benutzung von SetStatus in SdbCursor, SdbTable, ...),
+ // dann wird der Status des letzten Statements erfragt, sonst der Status des letzten
+ // Statements zu dieser Verbindung [was in unserem Fall wahrscheinlich gleichbedeutend ist,
+ // aber das Reference Manual drueckt sich da nicht so klar aus ...].
+ // Entsprechend bei hdbc.
+ SQLRETURN n = (*(T3SQLGetDiagRec)_pConnection->getOdbcFunction(ODBC3SQLGetDiagRec))(_nHandleType,_pContext,1,
+ szSqlState,
+ &pfNativeError,
+ szErrorMessage,sizeof szErrorMessage - 1,&pcbErrorMsg);
+ OSL_UNUSED( n );
+ OSL_ENSURE(n != SQL_INVALID_HANDLE,"SdbODBC3_SetStatus: SQLError returned SQL_INVALID_HANDLE");
+ OSL_ENSURE(n == SQL_SUCCESS || n == SQL_SUCCESS_WITH_INFO || n == SQL_NO_DATA_FOUND || n == SQL_ERROR,"SdbODBC3_SetStatus: SQLError failed");
+
+ // Zum Return Code von SQLError siehe ODBC 2.0 Programmer's Reference Seite 287ff
+ throw SQLException( ::rtl::OUString((char *)szErrorMessage,pcbErrorMsg,_nTextEncoding),
+ _xInterface,
+ ::rtl::OUString((char *)szSqlState,5,_nTextEncoding),
+ pfNativeError,
+ Any()
+ );
+
+}
+// -------------------------------------------------------------------------
+Sequence<sal_Int8> OTools::getBytesValue(OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _fSqlType,
+ sal_Bool &_bWasNull,
+ const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBytesValue" );
+ char aCharArray[2048];
+ // Erstmal versuchen, die Daten mit dem kleinen Puffer
+ // abzuholen:
+ SQLLEN nMaxLen = sizeof aCharArray - 1;
+ // GETDATA(SQL_C_CHAR,aCharArray,nMaxLen);
+ SQLLEN pcbValue = 0;
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ _fSqlType,
+ (SQLPOINTER)aCharArray,
+ nMaxLen,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+
+ _bWasNull = pcbValue == SQL_NULL_DATA;
+ if(_bWasNull)
+ return Sequence<sal_Int8>();
+
+ SQLINTEGER nBytes = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : nMaxLen;
+ if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nBytes-1] == 0 && nBytes > 0 )
+ --nBytes;
+ Sequence<sal_Int8> aData((sal_Int8*)aCharArray, nBytes);
+
+
+ // Es handelt sich um Binaerdaten, um einen String, der fuer
+ // StarView zu lang ist oder der Treiber kann die Laenge der
+ // Daten nicht im voraus bestimmen - also als MemoryStream
+ // speichern.
+ while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen)
+ {
+ // Bei Strings wird der Puffer nie ganz ausgenutzt
+ // (das letzte Byte ist immer ein NULL-Byte, das
+ // aber bei pcbValue nicht mitgezaehlt wird)
+ if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen)
+ nBytes = pcbValue - nMaxLen;
+ else
+ nBytes = nMaxLen;
+
+ // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
+ // GETDATA(SQL_C_CHAR,aCharArray, nLen + 1);
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ SQL_C_BINARY,
+ &aCharArray,
+ (SQLINTEGER)nBytes,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ sal_Int32 nLen = aData.getLength();
+ aData.realloc(nLen + nBytes);
+ memcpy(aData.getArray() + nLen, aCharArray, nBytes);
+ }
+ return aData;
+}
+// -------------------------------------------------------------------------
+::rtl::OUString OTools::getStringValue(OConnection* _pConnection,
+ SQLHANDLE _aStatementHandle,
+ sal_Int32 columnIndex,
+ SQLSMALLINT _fSqlType,
+ sal_Bool &_bWasNull,
+ const Reference< XInterface >& _xInterface,
+ rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getStringValue" );
+ ::rtl::OUStringBuffer aData;
+ switch(_fSqlType)
+ {
+ case SQL_WVARCHAR:
+ case SQL_WCHAR:
+ case SQL_WLONGVARCHAR:
+ {
+ sal_Unicode waCharArray[2048];
+ // read the unicode data
+ SQLLEN nMaxLen = (sizeof(waCharArray) / sizeof(sal_Unicode)) - 1;
+ // GETDATA(SQL_C_WCHAR, waCharArray, nMaxLen + sizeof(sal_Unicode));
+
+ SQLLEN pcbValue=0;
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ SQL_C_WCHAR,
+ &waCharArray,
+ (SQLLEN)nMaxLen*sizeof(sal_Unicode),
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ _bWasNull = pcbValue == SQL_NULL_DATA;
+ if(_bWasNull)
+ return ::rtl::OUString();
+ // Bei Fehler bricht der GETDATA-Makro mit return ab,
+ // bei NULL mit break!
+ SQLLEN nRealSize = 0;
+ if ( pcbValue > -1 )
+ nRealSize = pcbValue / sizeof(sal_Unicode);
+ SQLLEN nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
+ waCharArray[nLen] = 0;
+ aData.append(waCharArray,nLen);
+
+ // Es handelt sich um Binaerdaten, um einen String, der fuer
+ // StarView zu lang ist oder der Treiber kann die Laenge der
+ // Daten nicht im voraus bestimmen - also als MemoryStream
+ // speichern.
+ while ((pcbValue == SQL_NO_TOTAL ) || pcbValue > nMaxLen)
+ {
+ // Bei Strings wird der Puffer nie ganz ausgenutzt
+ // (das letzte Byte ist immer ein NULL-Byte, das
+ // aber bei pcbValue nicht mitgezaehlt wird)
+ if (pcbValue != SQL_NO_TOTAL && (pcbValue - nMaxLen) < nMaxLen)
+ nLen = pcbValue - nMaxLen;
+ else
+ nLen = nMaxLen;
+
+ // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
+ // GETDATA(SQL_C_CHAR,waCharArray, nLen + 1);
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ SQL_C_WCHAR,
+ &waCharArray,
+ (SQLLEN)nLen+1,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ nRealSize = 0;
+ if ( pcbValue > -1 )
+ nRealSize = pcbValue / sizeof(sal_Unicode);
+ nLen = pcbValue != SQL_NO_TOTAL ? std::min(nRealSize, nMaxLen) : (nMaxLen-1);
+ waCharArray[nLen] = 0;
+
+ aData.append(::rtl::OUString(waCharArray));
+ }
+ }
+ break;
+ default:
+ {
+ char aCharArray[2048];
+ // Erstmal versuchen, die Daten mit dem kleinen Puffer
+ // abzuholen:
+ SQLLEN nMaxLen = sizeof aCharArray - 1;
+ // GETDATA(SQL_C_CHAR,aCharArray,nMaxLen);
+ SQLLEN pcbValue = 0;
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ SQL_C_CHAR,
+ &aCharArray,
+ nMaxLen,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ _bWasNull = pcbValue == SQL_NULL_DATA;
+ if(_bWasNull)
+ return ::rtl::OUString();
+
+ SQLLEN nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
+ aCharArray[nLen] = 0;
+ if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nLen-1] == 0 && nLen > 0 )
+ --nLen;
+ aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen, _nTextEncoding));
+
+ // Es handelt sich um Binaerdaten, um einen String, der fuer
+ // StarView zu lang ist oder der Treiber kann die Laenge der
+ // Daten nicht im voraus bestimmen - also als MemoryStream
+ // speichern.
+ while ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen)
+ {
+ // Solange eine "truncation"-Warnung vorliegt, weiter Daten abholen
+ // GETDATA(SQL_C_CHAR,aCharArray, nLen + 1);
+ OTools::ThrowException(_pConnection,(*(T3SQLGetData)_pConnection->getOdbcFunction(ODBC3SQLGetData))(_aStatementHandle,
+ (SQLUSMALLINT)columnIndex,
+ SQL_C_CHAR,
+ &aCharArray,
+ (SQLINTEGER)nMaxLen,
+ &pcbValue),
+ _aStatementHandle,SQL_HANDLE_STMT,_xInterface);
+ nLen = pcbValue != SQL_NO_TOTAL ? std::min(pcbValue, nMaxLen) : (nMaxLen-1);
+ if ( ((pcbValue == SQL_NO_TOTAL) || pcbValue > nMaxLen) && aCharArray[nLen-1] == 0 && nLen > 0 )
+ --nLen;
+ aCharArray[nLen] = 0;
+
+ aData.append(::rtl::OUString((const sal_Char*)aCharArray,nLen,_nTextEncoding));
+ }
+
+ // delete all blanks
+ // aData.EraseTrailingChars();
+ }
+ }
+
+ return aData.makeStringAndClear();
+}
+// -------------------------------------------------------------------------
+void OTools::GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ ::rtl::OUString &_rValue,
+ const Reference< XInterface >& _xInterface,
+ rtl_TextEncoding _nTextEncoding) throw(SQLException, RuntimeException)
+{
+ char aValue[512];
+ SQLSMALLINT nValueLen=0;
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,aValue,(sizeof aValue)-1,&nValueLen),
+ _aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
+
+ _rValue = ::rtl::OUString(aValue,nValueLen,_nTextEncoding);
+}
+// -------------------------------------------------------------------------
+void OTools::GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ sal_Int32 &_rValue,
+ const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ SQLSMALLINT nValueLen;
+ _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
+ _aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
+}
+// -------------------------------------------------------------------------
+void OTools::GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ SQLUINTEGER &_rValue,
+ const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ SQLSMALLINT nValueLen;
+ _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
+ _aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
+}
+// -------------------------------------------------------------------------
+void OTools::GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ SQLUSMALLINT &_rValue,
+ const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ SQLSMALLINT nValueLen;
+ _rValue = 0; // in case the driver uses only 16 of the 32 bits (as it does, for example, for SQL_CATALOG_LOCATION)
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
+ _aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
+}
+// -------------------------------------------------------------------------
+void OTools::GetInfo(OConnection* _pConnection,
+ SQLHANDLE _aConnectionHandle,
+ SQLUSMALLINT _nInfo,
+ sal_Bool &_rValue,
+ const Reference< XInterface >& _xInterface) throw(SQLException, RuntimeException)
+{
+ SQLSMALLINT nValueLen;
+ OTools::ThrowException(_pConnection,
+ (*(T3SQLGetInfo)_pConnection->getOdbcFunction(ODBC3SQLGetInfo))(_aConnectionHandle,_nInfo,&_rValue,sizeof _rValue,&nValueLen),
+ _aConnectionHandle,SQL_HANDLE_DBC,_xInterface);
+}
+// -------------------------------------------------------------------------
+sal_Int32 OTools::MapOdbcType2Jdbc(sal_Int32 _nType)
+{
+ sal_Int32 nValue = DataType::VARCHAR;
+ switch(_nType)
+ {
+ case SQL_BIT:
+ nValue = DataType::BIT;
+ break;
+ case SQL_TINYINT:
+ nValue = DataType::TINYINT;
+ break;
+ case SQL_SMALLINT:
+ nValue = DataType::SMALLINT;
+ break;
+ case SQL_INTEGER:
+ nValue = DataType::INTEGER;
+ break;
+ case SQL_BIGINT:
+ nValue = DataType::BIGINT;
+ break;
+ case SQL_FLOAT:
+ nValue = DataType::FLOAT;
+ break;
+ case SQL_REAL:
+ nValue = DataType::REAL;
+ break;
+ case SQL_DOUBLE:
+ nValue = DataType::DOUBLE;
+ break;
+ case SQL_NUMERIC:
+ nValue = DataType::NUMERIC;
+ break;
+ case SQL_DECIMAL:
+ nValue = DataType::DECIMAL;
+ break;
+ case SQL_WCHAR:
+ case SQL_CHAR:
+ nValue = DataType::CHAR;
+ break;
+ case SQL_WVARCHAR:
+ case SQL_VARCHAR:
+ nValue = DataType::VARCHAR;
+ break;
+ case SQL_WLONGVARCHAR:
+ case SQL_LONGVARCHAR:
+ nValue = DataType::LONGVARCHAR;
+ break;
+ case SQL_TYPE_DATE:
+ case SQL_DATE:
+ nValue = DataType::DATE;
+ break;
+ case SQL_TYPE_TIME:
+ case SQL_TIME:
+ nValue = DataType::TIME;
+ break;
+ case SQL_TYPE_TIMESTAMP:
+ case SQL_TIMESTAMP:
+ nValue = DataType::TIMESTAMP;
+ break;
+ case SQL_BINARY:
+ nValue = DataType::BINARY;
+ break;
+ case SQL_VARBINARY:
+ case SQL_GUID:
+ nValue = DataType::VARBINARY;
+ break;
+ case SQL_LONGVARBINARY:
+ nValue = DataType::LONGVARBINARY;
+ break;
+ default:
+ OSL_ASSERT(!"Invalid type");
+ }
+ return nValue;
+}
+//--------------------------------------------------------------------
+// jdbcTypeToOdbc
+// Convert the JDBC SQL type to the correct ODBC type
+//--------------------------------------------------------------------
+sal_Int32 OTools::jdbcTypeToOdbc(sal_Int32 jdbcType)
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::jdbcTypeToOdbc" );
+ // For the most part, JDBC types match ODBC types. We'll
+ // just convert the ones that we know are different
+
+ sal_Int32 odbcType = jdbcType;
+
+ switch (jdbcType)
+ {
+ case DataType::DATE:
+ odbcType = SQL_DATE;
+ break;
+ case DataType::TIME:
+ odbcType = SQL_TIME;
+ break;
+ case DataType::TIMESTAMP:
+ odbcType = SQL_TIMESTAMP;
+ break;
+ }
+
+ return odbcType;
+}
+//-----------------------------------------------------------------------------
+void OTools::getBindTypes(sal_Bool _bUseWChar,
+ sal_Bool _bUseOldTimeDate,
+ SQLSMALLINT _nOdbcType,
+ SQLSMALLINT& fCType,
+ SQLSMALLINT& fSqlType
+ )
+{
+ RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "odbc", "Ocke.Janssen@sun.com", "OTools::getBindTypes" );
+ switch(_nOdbcType)
+ {
+ case SQL_CHAR: if(_bUseWChar)
+ {
+ fCType = SQL_C_WCHAR;
+ fSqlType = SQL_WCHAR;
+ }
+ else
+ {
+ fCType = SQL_C_CHAR;
+ fSqlType = SQL_CHAR;
+ }
+ break;
+ case SQL_VARCHAR: if(_bUseWChar)
+ {
+ fCType = SQL_C_WCHAR;
+ fSqlType = SQL_WVARCHAR;
+ }
+ else
+ {
+ fCType = SQL_C_CHAR;
+ fSqlType = SQL_VARCHAR;
+ }
+ break;
+ case SQL_LONGVARCHAR: if(_bUseWChar)
+ {
+ fCType = SQL_C_WCHAR;
+ fSqlType = SQL_WLONGVARCHAR;
+ }
+ else
+ {
+ fCType = SQL_C_CHAR;
+ fSqlType = SQL_LONGVARCHAR;
+ }
+ break;
+ case SQL_DECIMAL: fCType = _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR;
+ fSqlType = SQL_DECIMAL; break;
+ case SQL_NUMERIC: fCType = _bUseWChar ? SQL_C_WCHAR : SQL_C_CHAR;
+ fSqlType = SQL_NUMERIC; break;
+ case SQL_BIT: fCType = SQL_C_TINYINT;
+ fSqlType = SQL_INTEGER; break;
+ case SQL_TINYINT: fCType = SQL_C_TINYINT;
+ fSqlType = SQL_TINYINT; break;
+ case SQL_SMALLINT: fCType = SQL_C_SHORT;
+ fSqlType = SQL_SMALLINT; break;
+ case SQL_INTEGER: fCType = SQL_C_LONG;
+ fSqlType = SQL_INTEGER; break;
+ case SQL_BIGINT: fCType = SQL_C_SBIGINT;
+ fSqlType = SQL_BIGINT; break;
+ case SQL_FLOAT: fCType = SQL_C_FLOAT;
+ fSqlType = SQL_FLOAT; break;
+ case SQL_REAL: fCType = SQL_C_DOUBLE;
+ fSqlType = SQL_REAL; break;
+ case SQL_DOUBLE: fCType = SQL_C_DOUBLE;
+ fSqlType = SQL_DOUBLE; break;
+ case SQL_BINARY: fCType = SQL_C_BINARY;
+ fSqlType = SQL_BINARY; break;
+ case SQL_VARBINARY:
+ fCType = SQL_C_BINARY;
+ fSqlType = SQL_VARBINARY; break;
+ case SQL_LONGVARBINARY: fCType = SQL_C_BINARY;
+ fSqlType = SQL_LONGVARBINARY; break;
+ case SQL_DATE:
+ if(_bUseOldTimeDate)
+ {
+ fCType = SQL_C_DATE;
+ fSqlType = SQL_DATE;
+ }
+ else
+ {
+ fCType = SQL_C_TYPE_DATE;
+ fSqlType = SQL_TYPE_DATE;
+ }
+ break;
+ case SQL_TIME:
+ if(_bUseOldTimeDate)
+ {
+ fCType = SQL_C_TIME;
+ fSqlType = SQL_TIME;
+ }
+ else
+ {
+ fCType = SQL_C_TYPE_TIME;
+ fSqlType = SQL_TYPE_TIME;
+ }
+ break;
+ case SQL_TIMESTAMP:
+ if(_bUseOldTimeDate)
+ {
+ fCType = SQL_C_TIMESTAMP;
+ fSqlType = SQL_TIMESTAMP;
+ }
+ else
+ {
+ fCType = SQL_C_TYPE_TIMESTAMP;
+ fSqlType = SQL_TYPE_TIMESTAMP;
+ }
+ break;
+ default: fCType = SQL_C_BINARY;
+ fSqlType = SQL_LONGVARBINARY; break;
+ }
+}
+
+
diff --git a/connectivity/source/drivers/odbcbase/makefile.mk b/connectivity/source/drivers/odbcbase/makefile.mk
new file mode 100644
index 000000000000..798517c8f948
--- /dev/null
+++ b/connectivity/source/drivers/odbcbase/makefile.mk
@@ -0,0 +1,90 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=..$/..
+PRJNAME=connectivity
+TARGET=odbcbase
+
+ENABLE_EXCEPTIONS=TRUE
+VISIBILITY_HIDDEN=TRUE
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/version.mk
+
+CDEFS += -DOOO_DLLIMPLEMENTATION_ODBCBASE
+
+.IF "$(SYSTEM_ODBC_HEADERS)" == "YES"
+CFLAGS+=-DSYSTEM_ODBC_HEADERS
+.ENDIF
+
+# --- Files -------------------------------------
+
+SLOFILES=\
+ $(SLO)$/OPreparedStatement.obj \
+ $(SLO)$/OStatement.obj \
+ $(SLO)$/OResultSetMetaData.obj \
+ $(SLO)$/OResultSet.obj \
+ $(SLO)$/OTools.obj \
+ $(SLO)$/ODatabaseMetaDataResultSet.obj \
+ $(SLO)$/ODatabaseMetaData.obj \
+ $(SLO)$/ODriver.obj \
+ $(SLO)$/OConnection.obj
+
+# --- ODBC BASE Library -----------------------------------
+
+SHL1TARGET= $(ODBC2_TARGET)$(DLLPOSTFIX)
+SHL1OBJS=$(SLOFILES)
+SHL1STDLIBS=\
+ $(DBTOOLSLIB) \
+ $(COMPHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(VOSLIB) \
+ $(SALLIB)
+
+SHL1DEPN=
+SHL1IMPLIB= i$(ODBC2_TARGET)
+SHL1USE_EXPORTS=name
+
+SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME= $(SHL1TARGET)
+DEF1DEPN= $(MISC)$/$(SHL1TARGET).flt \
+ $(SLB)$/$(TARGET).lib
+DEFLIB1NAME=$(TARGET)
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
+# --- filter file ------------------------------
+
+$(MISC)$/$(SHL1TARGET).flt: makefile.mk
+ @echo CLEAR_THE_FILE > $@